vxlan: multiarch optimization of vxlan
[vpp.git] / src / plugins / gbp / gbp_policy.c
1 /*
2  * Copyright (c) 2018 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #include <plugins/gbp/gbp.h>
17 #include <plugins/gbp/gbp_policy.h>
18 #include <vnet/vxlan-gbp/vxlan_gbp_packet.h>
19
20 gbp_policy_main_t gbp_policy_main;
21
22 /* packet trace format function */
23 u8 *
24 format_gbp_policy_trace (u8 * s, va_list * args)
25 {
26   CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
27   CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
28   gbp_policy_trace_t *t = va_arg (*args, gbp_policy_trace_t *);
29
30   s =
31     format (s,
32             "scope:%d sclass:%d, dclass:%d, action:%U flags:%U acl: %d rule: %d",
33             t->scope, t->sclass, t->dclass, format_gbp_rule_action, t->action,
34             format_vxlan_gbp_header_gpflags, t->flags, t->acl_match,
35             t->rule_match);
36
37   return s;
38 }
39
40 static clib_error_t *
41 gbp_policy_init (vlib_main_t * vm)
42 {
43   gbp_policy_main_t *gpm = &gbp_policy_main;
44   clib_error_t *error = 0;
45
46   /* Initialize the feature next-node indexes */
47   vlib_node_t *node = vlib_get_node_by_name (vm, (u8 *) "gbp-policy-port");
48   feat_bitmap_init_next_nodes (vm,
49                                node->index,
50                                L2OUTPUT_N_FEAT,
51                                l2output_get_feat_names (),
52                                gpm->l2_output_feat_next[GBP_POLICY_PORT]);
53
54   node = vlib_get_node_by_name (vm, (u8 *) "gbp-policy-mac");
55   feat_bitmap_init_next_nodes (vm,
56                                node->index,
57                                L2OUTPUT_N_FEAT,
58                                l2output_get_feat_names (),
59                                gpm->l2_output_feat_next[GBP_POLICY_MAC]);
60
61   node = vlib_get_node_by_name (vm, (u8 *) "gbp-policy-lpm");
62   feat_bitmap_init_next_nodes (vm,
63                                node->index,
64                                L2OUTPUT_N_FEAT,
65                                l2output_get_feat_names (),
66                                gpm->l2_output_feat_next[GBP_POLICY_LPM]);
67
68   return error;
69 }
70
71 VLIB_INIT_FUNCTION (gbp_policy_init);
72
73 /*
74  * fd.io coding-style-patch-verification: ON
75  *
76  * Local Variables:
77  * eval: (c-set-style "gnu")
78  * End:
79  */