X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fpolicer%2Fnode_funcs.c;h=5c185991e8b5f4cc8349745ab2d5e5650fe7e741;hb=3b81a1e5f205482b8ea30edbfd39559c4368ac4d;hp=fd031d02eeaa9ae74aba2619885a501ab00d422b;hpb=beb0b2e346c63e21ffe892ae0e04b67bb10fba5e;p=vpp.git diff --git a/src/vnet/policer/node_funcs.c b/src/vnet/policer/node_funcs.c index fd031d02eea..5c185991e8b 100644 --- a/src/vnet/policer/node_funcs.c +++ b/src/vnet/policer/node_funcs.c @@ -18,14 +18,13 @@ #include #include #include +#include #include #include #include +#include +#include -#define IP4_NON_DSCP_BITS 0x03 -#define IP4_DSCP_SHIFT 2 -#define IP6_NON_DSCP_BITS 0xf03fffff -#define IP6_DSCP_SHIFT 22 /* Dispatch functions meant to be instantiated elsewhere */ @@ -67,60 +66,6 @@ static char *vnet_policer_error_strings[] = { #undef _ }; -static_always_inline void -vnet_policer_mark (vlib_buffer_t * b, u8 dscp) -{ - ethernet_header_t *eh; - ip4_header_t *ip4h; - ip6_header_t *ip6h; - u16 type; - - eh = (ethernet_header_t *) b->data; - type = clib_net_to_host_u16 (eh->type); - - if (PREDICT_TRUE (type == ETHERNET_TYPE_IP4)) - { - ip4h = (ip4_header_t *) & (b->data[sizeof (ethernet_header_t)]);; - ip4h->tos &= IP4_NON_DSCP_BITS; - ip4h->tos |= dscp << IP4_DSCP_SHIFT; - ip4h->checksum = ip4_header_checksum (ip4h); - } - else - { - if (PREDICT_TRUE (type == ETHERNET_TYPE_IP6)) - { - ip6h = (ip6_header_t *) & (b->data[sizeof (ethernet_header_t)]); - ip6h->ip_version_traffic_class_and_flow_label &= - clib_host_to_net_u32 (IP6_NON_DSCP_BITS); - ip6h->ip_version_traffic_class_and_flow_label |= - clib_host_to_net_u32 (dscp << IP6_DSCP_SHIFT); - } - } -} - -static_always_inline - u8 vnet_policer_police (vlib_main_t * vm, - vlib_buffer_t * b, - u32 policer_index, - u64 time_in_policer_periods, - policer_result_e packet_color) -{ - u8 act; - u32 len; - u32 col; - policer_read_response_type_st *pol; - vnet_policer_main_t *pm = &vnet_policer_main; - - len = vlib_buffer_length_in_chain (vm, b); - pol = &pm->policers[policer_index]; - col = vnet_police_packet (pol, len, packet_color, time_in_policer_periods); - act = pol->action[col]; - if (PREDICT_TRUE (act == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)) - vnet_policer_mark (b, pol->mark_dscp[col]); - - return act; -} - static inline uword vnet_policer_inline (vlib_main_t * vm, vlib_node_runtime_t * node, @@ -898,19 +843,22 @@ l2_policer_classify (vlib_main_t * vm, return policer_classify_inline (vm, node, frame, POLICER_CLASSIFY_TABLE_L2); } -VLIB_REGISTER_NODE (l2_policer_classify_node) = -{ - .function = l2_policer_classify,.name = "l2-policer-classify",.vector_size = - sizeof (u32),.format_trace = format_policer_classify_trace,.n_errors = - ARRAY_LEN (policer_classify_error_strings),.error_strings = - policer_classify_error_strings,.n_next_nodes = - POLICER_CLASSIFY_NEXT_INDEX_N_NEXT,.next_nodes = - { - [POLICER_CLASSIFY_NEXT_INDEX_DROP] = "error-drop",} -,}; +/* *INDENT-OFF* */ +VLIB_REGISTER_NODE (l2_policer_classify_node) = { + .function = l2_policer_classify, + .name = "l2-policer-classify", + .vector_size = sizeof (u32), + .format_trace = format_policer_classify_trace, + .n_errors = ARRAY_LEN (policer_classify_error_strings), + .error_strings = policer_classify_error_strings, + .n_next_nodes = POLICER_CLASSIFY_NEXT_INDEX_N_NEXT, + .next_nodes = { + [POLICER_CLASSIFY_NEXT_INDEX_DROP] = "error-drop", + }, +}; VLIB_NODE_FUNCTION_MULTIARCH (l2_policer_classify_node, l2_policer_classify); - +/* *INDENT-ON* */ static clib_error_t * policer_classify_init (vlib_main_t * vm)