FD.io VPP  v19.04.2-12-g66b1689
Vector Packet Processing
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
gbp_learn.c
Go to the documentation of this file.
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>
19 
20 #include <vnet/l2/l2_input.h>
21 
23 
24 void
26 {
27  if (GBP_LEARN_MODE_L2 == mode)
28  {
29  l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_GBP_LEARN, 1);
30  }
31  else
32  {
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);
37  }
38 }
39 
40 void
42 {
43  if (GBP_LEARN_MODE_L2 == mode)
44  {
45  l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_GBP_LEARN, 0);
46  }
47  else
48  {
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);
53  }
54 }
55 
56 static clib_error_t *
58 {
61 
62  vlib_node_t *node = vlib_get_node_by_name (vm, (u8 *) "gbp-learn-l2");
63 
64  /* Initialize the feature next-node indices */
66  node->index,
70 
73 
76 
77  glm->gl_logger = vlib_log_register_class ("gbp", "learn");
78 
79  return 0;
80 }
81 
83 
84 /*
85  * fd.io coding-style-patch-verification: ON
86  *
87  * Local Variables:
88  * eval: (c-set-style "gnu")
89  * End:
90  */
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
Definition: log.c:227
u32 sw_if_index
Definition: ipsec_gre.api:37
u32 index
Definition: node.h:279
void throttle_init(throttle_t *t, u32 n_threads, f64 time)
Definition: throttle.c:19
Grouping of global data for the GBP source EPG classification feature.
Definition: gbp_learn.h:35
unsigned char u8
Definition: types.h:56
gbp_learn_main_t gbp_learn_main
Definition: gbp_learn.c:22
throttle_t gl_l3_throttle
Definition: gbp_learn.h:51
vlib_log_class_t gl_logger
logger - VLIB log class
Definition: gbp_learn.h:45
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:163
u32 gl_l2_input_feat_next[32]
Next nodes for L2 output features.
Definition: gbp_learn.h:40
#define GBP_ENDPOINT_HASH_LEARN_RATE
The maximum learning rate per-hashed EP.
Definition: gbp_learn.h:24
unsigned int u32
Definition: types.h:88
void gbp_learn_enable(u32 sw_if_index, gbb_learn_mode_t mode)
Definition: gbp_learn.c:25
vlib_thread_main_t vlib_thread_main
Definition: threads.c:37
enum gbp_learn_mode_t_ gbb_learn_mode_t
vlib_main_t * vm
Definition: buffer.c:312
static void feat_bitmap_init_next_nodes(vlib_main_t *vm, u32 node_index, u32 num_features, char **feat_names, u32 *next_nodes)
Initialize the feature next-node indexes of a graph node.
Definition: feat_bitmap.h:43
static clib_error_t * gbp_learn_init(vlib_main_t *vm)
Definition: gbp_learn.c:57
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:45
char ** l2input_get_feat_names(void)
Return an array of strings containing graph node names of each feature.
Definition: l2_input.c:62
vl_api_vxlan_gbp_api_tunnel_mode_t mode
Definition: vxlan_gbp.api:44
u32 l2input_intf_bitmap_enable(u32 sw_if_index, l2input_feat_masks_t feature_bitmap, u32 enable)
Enable (or disable) the feature in the bitmap for the given interface.
Definition: l2_input.c:536
throttle_t gl_l2_throttle
throttles for the DP leanring
Definition: gbp_learn.h:50
void gbp_learn_disable(u32 sw_if_index, gbb_learn_mode_t mode)
Definition: gbp_learn.c:41
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
Definition: feature.c:274