} l2_output_config_t;
-
-/*
- * The set of next nodes for features and interface output.
- * Each output feature node should include this.
- */
typedef struct
{
/*
* array of next node index for each output feature, indexed
* by l2output_feat_t. Used to determine next feature node.
*/
- u32 feat_next_node_index[32];
-
-} l2_output_next_nodes_st;
-
-
-typedef struct
-{
- /* Next nodes for features and output interfaces */
- l2_output_next_nodes_st next_nodes;
+ u32 l2_out_feat_next[32];
/* config vector indexed by sw_if_index */
l2_output_config_t *configs;
vnet_main_t *vnet_main;
} l2output_main_t;
-l2output_main_t l2output_main;
+extern l2output_main_t l2output_main;
+
+extern vlib_node_registration_t l2output_node;
/* L2 output features */
-/* Mappings from feature ID to graph node name */
+/* Mappings from feature ID to graph node name in reverse order */
#define foreach_l2output_feat \
- _(SPAN, "feature-bitmap-drop") \
+ _(OUTPUT, "interface-output") \
+ _(SPAN, "span-l2-output") \
+ _(GBP_POLICY, "gbp-policy") \
_(CFM, "feature-bitmap-drop") \
_(QOS, "feature-bitmap-drop") \
_(ACL, "l2-output-acl") \
L2OUTPUT_N_FEAT,
} l2output_feat_t;
+STATIC_ASSERT (L2OUTPUT_N_FEAT <= 32, "too many l2 output features");
+
/* Feature bit masks */
typedef enum
{
_(VTR_DROP, "L2 output tag rewrite drops") \
_(SHG_DROP, "L2 split horizon drops") \
_(DROP, "L2 output drops") \
-_(MAPPING_DROP, "L2 Output interface mapping in progress")
+_(MAPPING_DROP, "L2 Output interface not valid")
typedef enum
{
/* Return an array of strings containing graph node names of each feature */
char **l2output_get_feat_names (void);
+/* arg0 - u32 feature_bitmap */
+u8 *format_l2_output_features (u8 * s, va_list * args);
/**
* The next set of functions is for use by output feature graph nodes.
*/
/* Create a mapping to the output graph node for the given sw_if_index */
-u32 l2output_create_output_node_mapping (vlib_main_t * vlib_main, vnet_main_t * vnet_main, u32 node_index, /* index of current node */
- u32 * output_node_index_vec,
- u32 sw_if_index);
-
-/* Initialize the next node mapping table */
-always_inline void
-l2output_init_output_node_vec (u32 ** output_node_index_vec)
-{
-
- /*
- * Size it at 100 sw_if_indexes initially
- * Uninitialized mappings are set to ~0
- */
- vec_validate_init_empty (*output_node_index_vec, 100, ~0);
-}
-
-
-/**
- * Get a mapping from the output node mapping table,
- * creating the entry if necessary.
- */
-always_inline u32
-l2output_get_output_node (vlib_main_t * vlib_main, vnet_main_t * vnet_main, u32 node_index, /* index of current node */
- u32 sw_if_index, u32 ** output_node_index_vec) /* may be updated */
-{
- u32 next; /* index of next graph node */
-
- /* Insure the vector is big enough */
- vec_validate_init_empty (*output_node_index_vec, sw_if_index, ~0);
-
- /* Get the mapping for the sw_if_index */
- next = vec_elt (*output_node_index_vec, sw_if_index);
-
- if (next == ~0)
- {
- /* Mapping doesn't exist so create it */
- next = l2output_create_output_node_mapping (vlib_main,
- vnet_main,
- node_index,
- *output_node_index_vec,
- sw_if_index);
- }
-
- return next;
-}
-
-
-/** Determine the next L2 node based on the output feature bitmap */
-always_inline void
-l2_output_dispatch (vlib_main_t * vlib_main,
- vnet_main_t * vnet_main,
- vlib_node_runtime_t * node,
- u32 node_index,
- u32 * cached_sw_if_index,
- u32 * cached_next_index,
- l2_output_next_nodes_st * next_nodes,
- vlib_buffer_t * b0,
- u32 sw_if_index, u32 feature_bitmap, u32 * next0)
-{
- if (feature_bitmap)
- {
- /* There are some features to execute */
-
- /* Save bitmap for the next feature graph nodes */
- vnet_buffer (b0)->l2.feature_bitmap = feature_bitmap;
-
- /* Determine the next node */
- *next0 =
- feat_bitmap_get_next_node_index (next_nodes->feat_next_node_index,
- feature_bitmap);
- }
- else
- {
- /*
- * There are no features. Send packet to TX node for sw_if_index0
- * This is a little tricky in that the output interface next node indexes
- * are not precomputed at init time.
- */
-
- if (sw_if_index == *cached_sw_if_index)
- {
- /* We hit in the one-entry cache. Use it. */
- *next0 = *cached_next_index;
- }
- else
- {
- /* Look up the output TX node */
- *next0 = l2output_get_output_node (vlib_main,
- vnet_main,
- node_index,
- sw_if_index,
- &next_nodes->output_node_index_vec);
-
- if (*next0 == L2OUTPUT_NEXT_DROP)
- {
- vnet_hw_interface_t *hw0;
- hw0 = vnet_get_sup_hw_interface (vnet_main, sw_if_index);
-
- if (hw0->flags & VNET_HW_INTERFACE_FLAG_L2OUTPUT_MAPPED)
- b0->error = node->errors[L2OUTPUT_ERROR_MAPPING_DROP];
- }
-
- /* Update the one-entry cache */
- *cached_sw_if_index = sw_if_index;
- *cached_next_index = *next0;
- }
- }
-}
+void l2output_create_output_node_mapping (vlib_main_t * vlib_main,
+ vnet_main_t * vnet_main,
+ u32 sw_if_index);
/** Get a pointer to the config for the given interface */
l2_output_config_t *l2output_intf_config (u32 sw_if_index);