X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fnsh%2Fnsh_output.c;h=9b7014a0ed0c81246b251aae231ba4ad0c84c912;hb=HEAD;hp=f0ac673cf6103898035b635789006aa4c2f94980;hpb=d313f9e6f7c6d50aac189668a67bf13b86dd791c;p=vpp.git diff --git a/src/plugins/nsh/nsh_output.c b/src/plugins/nsh/nsh_output.c index f0ac673cf61..9b7014a0ed0 100644 --- a/src/plugins/nsh/nsh_output.c +++ b/src/plugins/nsh/nsh_output.c @@ -16,7 +16,6 @@ */ #include -#include #include #include @@ -88,13 +87,15 @@ nsh_output_inline (vlib_main_t * vm, nsh_base_header_t *hdr0; ethernet_header_t * eth_hdr0; vlib_buffer_t * p0; - u32 pi0, rw_len0, adj_index0, next0, error0; + u32 pi0, adj_index0, next0, error0; ip_adjacency_t * adj1; nsh_base_header_t *hdr1; ethernet_header_t * eth_hdr1; vlib_buffer_t * p1; - u32 pi1, rw_len1, adj_index1, next1, error1; + u32 pi1, adj_index1, next1, error1; + int pkt_len0, pkt_len1; + word rw_len0, rw_len1; /* Prefetch next iteration. */ { @@ -141,27 +142,27 @@ nsh_output_inline (vlib_main_t * vm, /* Update packet buffer attributes/set output interface. */ rw_len0 = adj0[0].rewrite_header.data_bytes; rw_len1 = adj1[0].rewrite_header.data_bytes; + pkt_len0 = vlib_buffer_length_in_chain (vm, p0); + pkt_len1 = vlib_buffer_length_in_chain (vm, p1); /* Bump the adj counters for packet and bytes */ - vlib_increment_combined_counter - (&adjacency_counters, - thread_index, - adj_index0, - 1, - vlib_buffer_length_in_chain (vm, p0) + rw_len0); - vlib_increment_combined_counter - (&adjacency_counters, - thread_index, - adj_index1, - 1, - vlib_buffer_length_in_chain (vm, p1) + rw_len1); - + if (adj_index0 == adj_index1) + { + vlib_increment_combined_counter (&adjacency_counters, thread_index, adj_index0, 2, + pkt_len0 + rw_len0 + pkt_len1 + rw_len1); + } + else + { + vlib_increment_combined_counter (&adjacency_counters, thread_index, adj_index0, 1, + pkt_len0 + rw_len0); + vlib_increment_combined_counter (&adjacency_counters, thread_index, adj_index1, 1, + pkt_len1 + rw_len1); + } /* Check MTU of outgoing interface. */ - if (PREDICT_TRUE(vlib_buffer_length_in_chain (vm, p0) <= + if (PREDICT_TRUE(pkt_len0 <= adj0[0].rewrite_header.max_l3_packet_bytes)) { - p0->current_data -= rw_len0; - p0->current_length += rw_len0; + vlib_buffer_advance (p0, -rw_len0); vnet_buffer (p0)->sw_if_index[VLIB_TX] = adj0[0].rewrite_header.sw_if_index; @@ -178,11 +179,10 @@ nsh_output_inline (vlib_main_t * vm, error0 = IP4_ERROR_MTU_EXCEEDED; next0 = NSH_OUTPUT_NEXT_DROP; } - if (PREDICT_TRUE(vlib_buffer_length_in_chain (vm, p1) <= + if (PREDICT_TRUE(pkt_len1 <= adj1[0].rewrite_header.max_l3_packet_bytes)) { - p1->current_data -= rw_len1; - p1->current_length += rw_len1; + vlib_buffer_advance (p1, -rw_len1); vnet_buffer (p1)->sw_if_index[VLIB_TX] = adj1[0].rewrite_header.sw_if_index; @@ -236,7 +236,9 @@ nsh_output_inline (vlib_main_t * vm, nsh_base_header_t *hdr0; ethernet_header_t * eth_hdr0; vlib_buffer_t * p0; - u32 pi0, rw_len0, adj_index0, next0, error0; + u32 pi0, adj_index0, next0, error0; + int pkt_len0; + word rw_len0; pi0 = to_next[0] = from[0]; @@ -256,20 +258,15 @@ nsh_output_inline (vlib_main_t * vm, /* Update packet buffer attributes/set output interface. */ rw_len0 = adj0[0].rewrite_header.data_bytes; + pkt_len0 = vlib_buffer_length_in_chain (vm, p0); - vlib_increment_combined_counter - (&adjacency_counters, - thread_index, - adj_index0, - 1, - vlib_buffer_length_in_chain (vm, p0) + rw_len0); + vlib_increment_combined_counter (&adjacency_counters, thread_index, adj_index0, 1, + pkt_len0 + rw_len0); /* Check MTU of outgoing interface. */ - if (PREDICT_TRUE(vlib_buffer_length_in_chain (vm, p0) <= - adj0[0].rewrite_header.max_l3_packet_bytes)) + if (PREDICT_TRUE(pkt_len0 <= adj0[0].rewrite_header.max_l3_packet_bytes)) { - p0->current_data -= rw_len0; - p0->current_length += rw_len0; + vlib_buffer_advance (p0, -rw_len0); vnet_buffer (p0)->sw_if_index[VLIB_TX] = adj0[0].rewrite_header.sw_if_index; @@ -323,8 +320,7 @@ typedef enum nsh_midchain_next_t_ NSH_MIDCHAIN_NEXT_DROP, } nsh_midchain_next_t; -static inline uword -nsh_eth_output (vlib_main_t * vm, +VLIB_NODE_FN (nsh_eth_output_node) (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * from_frame) { @@ -332,7 +328,6 @@ nsh_eth_output (vlib_main_t * vm, } VLIB_REGISTER_NODE (nsh_eth_output_node) = { - .function = nsh_eth_output, .name = "nsh-eth-output", /* Takes a vector of packets. */ .vector_size = sizeof (u32), @@ -346,10 +341,7 @@ VLIB_REGISTER_NODE (nsh_eth_output_node) = { .format_trace = format_nsh_output_trace, }; -VLIB_NODE_FUNCTION_MULTIARCH (nsh_eth_output_node, nsh_eth_output) - -static inline uword -nsh_midchain (vlib_main_t * vm, +VLIB_NODE_FN (nsh_midchain_node) (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * from_frame) { @@ -357,7 +349,6 @@ nsh_midchain (vlib_main_t * vm, } VLIB_REGISTER_NODE (nsh_midchain_node) = { - .function = nsh_midchain, .name = "nsh-midchain", .vector_size = sizeof (u32), .format_trace = format_nsh_output_trace, @@ -367,8 +358,6 @@ VLIB_REGISTER_NODE (nsh_midchain_node) = { }, }; -VLIB_NODE_FUNCTION_MULTIARCH (nsh_midchain_node, nsh_midchain) - /* Built-in nsh tx feature path definition */ VNET_FEATURE_INIT (nsh_interface_output, static) = { .arc_name = "nsh-eth-output", @@ -377,7 +366,6 @@ VNET_FEATURE_INIT (nsh_interface_output, static) = { }; /* Built-in ip4 tx feature path definition */ -/* *INDENT-OFF* */ VNET_FEATURE_ARC_INIT (nsh_eth_output, static) = { .arc_name = "nsh-eth-output", @@ -390,7 +378,6 @@ VNET_FEATURE_INIT (nsh_eth_tx_drop, static) = .node_name = "error-drop", .runs_before = 0, /* not before any other features */ }; -/* *INDENT-ON* */ /** * @brief Next index values from the NSH incomplete adj node */ @@ -423,8 +410,7 @@ typedef struct nsh_adj_incomplete_trace_t_ * We pay a cost for this 'routing' node, but an incomplete adj is the * exception case. */ -static inline uword -nsh_adj_incomplete (vlib_main_t * vm, +VLIB_NODE_FN (nsh_adj_incomplete_node) (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * from_frame) { @@ -503,7 +489,6 @@ format_nsh_adj_incomplete_trace (u8 * s, va_list * args) } VLIB_REGISTER_NODE (nsh_adj_incomplete_node) = { - .function = nsh_adj_incomplete, .name = "nsh-adj-incomplete", .format_trace = format_nsh_adj_incomplete_trace, /* Takes a vector of packets. */ @@ -516,5 +501,3 @@ VLIB_REGISTER_NODE (nsh_adj_incomplete_node) = { }, }; -VLIB_NODE_FUNCTION_MULTIARCH (nsh_adj_incomplete_node, - nsh_adj_incomplete)