vxlan: multiarch optimization of vxlan
[vpp.git] / extras / deprecated / plugins / gbp / gbp_learn.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_learn.h>
18 #include <plugins/gbp/gbp_bridge_domain.h>
19
20 #include <vnet/l2/l2_input.h>
21
22 gbp_learn_main_t gbp_learn_main;
23
24 void
25 gbp_learn_enable (u32 sw_if_index)
26 {
27   vnet_feature_enable_disable ("ip4-unicast",
28                                "gbp-learn-ip4", sw_if_index, 1, 0, 0);
29   vnet_feature_enable_disable ("ip6-unicast",
30                                "gbp-learn-ip6", sw_if_index, 1, 0, 0);
31 }
32
33 void
34 gbp_learn_disable (u32 sw_if_index)
35 {
36   vnet_feature_enable_disable ("ip4-unicast",
37                                "gbp-learn-ip4", sw_if_index, 0, 0, 0);
38   vnet_feature_enable_disable ("ip6-unicast",
39                                "gbp-learn-ip6", sw_if_index, 0, 0, 0);
40 }
41
42 static clib_error_t *
43 gbp_learn_init (vlib_main_t * vm)
44 {
45   gbp_learn_main_t *glm = &gbp_learn_main;
46   vlib_thread_main_t *tm = &vlib_thread_main;
47
48   vlib_node_t *node = vlib_get_node_by_name (vm, (u8 *) "gbp-learn-l2");
49
50   /* Initialize the feature next-node indices */
51   feat_bitmap_init_next_nodes (vm,
52                                node->index,
53                                L2INPUT_N_FEAT,
54                                l2input_get_feat_names (),
55                                glm->gl_l2_input_feat_next);
56
57   throttle_init (&glm->gl_l2_throttle,
58                  tm->n_vlib_mains, GBP_ENDPOINT_HASH_LEARN_RATE);
59
60   throttle_init (&glm->gl_l3_throttle,
61                  tm->n_vlib_mains, GBP_ENDPOINT_HASH_LEARN_RATE);
62
63   glm->gl_logger = vlib_log_register_class ("gbp", "learn");
64
65   return 0;
66 }
67
68 VLIB_INIT_FUNCTION (gbp_learn_init);
69
70 /*
71  * fd.io coding-style-patch-verification: ON
72  *
73  * Local Variables:
74  * eval: (c-set-style "gnu")
75  * End:
76  */