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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #include <plugins/gbp/gbp.h>
17 #include <plugins/gbp/gbp_learn.h>
18 #include <plugins/gbp/gbp_bridge_domain.h>
20 #include <vnet/l2/l2_input.h>
22 gbp_learn_main_t gbp_learn_main;
25 gbp_learn_enable (u32 sw_if_index, gbb_learn_mode_t mode)
27 if (GBP_LEARN_MODE_L2 == mode)
29 l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_GBP_LEARN, 1);
33 vnet_feature_enable_disable ("ip4-unicast",
34 "gbp-learn-ip4", sw_if_index, 1, 0, 0);
35 vnet_feature_enable_disable ("ip6-unicast",
36 "gbp-learn-ip6", sw_if_index, 1, 0, 0);
41 gbp_learn_disable (u32 sw_if_index, gbb_learn_mode_t mode)
43 if (GBP_LEARN_MODE_L2 == mode)
45 l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_GBP_LEARN, 0);
49 vnet_feature_enable_disable ("ip4-unicast",
50 "gbp-learn-ip4", sw_if_index, 0, 0, 0);
51 vnet_feature_enable_disable ("ip6-unicast",
52 "gbp-learn-ip6", sw_if_index, 0, 0, 0);
57 gbp_learn_init (vlib_main_t * vm)
59 gbp_learn_main_t *glm = &gbp_learn_main;
60 vlib_thread_main_t *tm = &vlib_thread_main;
62 vlib_node_t *node = vlib_get_node_by_name (vm, (u8 *) "gbp-learn-l2");
64 /* Initialize the feature next-node indices */
65 feat_bitmap_init_next_nodes (vm,
68 l2input_get_feat_names (),
69 glm->gl_l2_input_feat_next);
71 throttle_init (&glm->gl_l2_throttle,
72 tm->n_vlib_mains, GBP_ENDPOINT_HASH_LEARN_RATE);
74 throttle_init (&glm->gl_l3_throttle,
75 tm->n_vlib_mains, GBP_ENDPOINT_HASH_LEARN_RATE);
77 glm->gl_logger = vlib_log_register_class ("gbp", "learn");
82 VLIB_INIT_FUNCTION (gbp_learn_init);
85 * fd.io coding-style-patch-verification: ON
88 * eval: (c-set-style "gnu")