Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
fib: DPO layout add u64 parameter.
[vpp.git]
/
src
/
vnet
/
dpo
/
dpo.c
diff --git
a/src/vnet/dpo/dpo.c
b/src/vnet/dpo/dpo.c
index
85f2c5d
..
1331b55
100644
(file)
--- a/
src/vnet/dpo/dpo.c
+++ b/
src/vnet/dpo/dpo.c
@@
-16,9
+16,9
@@
* @brief
* A Data-Path Object is an object that represents actions that are
* applied to packets are they are switched through VPP.
* @brief
* A Data-Path Object is an object that represents actions that are
* applied to packets are they are switched through VPP.
- *
+ *
* The DPO is a base class that is specialised by other objects to provide
* The DPO is a base class that is specialised by other objects to provide
- * concre
a
te actions
+ * concrete actions
*
* The VLIB graph nodes are graph of types, the DPO graph is a graph of instances.
*/
*
* The VLIB graph nodes are graph of types, the DPO graph is a graph of instances.
*/
@@
-43,6
+43,7
@@
#include <vnet/dpo/dvr_dpo.h>
#include <vnet/dpo/l3_proxy_dpo.h>
#include <vnet/dpo/ip6_ll_dpo.h>
#include <vnet/dpo/dvr_dpo.h>
#include <vnet/dpo/l3_proxy_dpo.h>
#include <vnet/dpo/ip6_ll_dpo.h>
+#include <vnet/dpo/pw_cw.h>
/**
* Array of char* names for the DPO types and protos
/**
* Array of char* names for the DPO types and protos
@@
-78,7
+79,7
@@
static const char* const * const ** dpo_nodes;
* the third dimension in dpo_nodes is lost, hence, the edge index from each
* node MUST be the same.
* Including both the child and parent protocol is required to support the
* the third dimension in dpo_nodes is lost, hence, the edge index from each
* node MUST be the same.
* Including both the child and parent protocol is required to support the
- * case where it changes as the grap
th is traversed, most notabl
ly when an
+ * case where it changes as the grap
h is traversed, most notab
ly when an
* MPLS label is popped.
*
* Note that this array is child type specific, not child instance specific.
* MPLS label is popped.
*
* Note that this array is child type specific, not child instance specific.
@@
-86,7
+87,7
@@
static const char* const * const ** dpo_nodes;
static u32 ****dpo_edges;
/**
static u32 ****dpo_edges;
/**
- * @brief The DPO type value that can be assig
en
d to the next dynamic
+ * @brief The DPO type value that can be assig
ne
d to the next dynamic
* type registration.
*/
static dpo_type_t dpo_dynamic = DPO_LAST;
* type registration.
*/
static dpo_type_t dpo_dynamic = DPO_LAST;
@@
-153,20
+154,22
@@
format_dpo_id (u8 * s, va_list * args)
if (NULL != dpo_vfts[dpo->dpoi_type].dv_format)
{
if (NULL != dpo_vfts[dpo->dpoi_type].dv_format)
{
-
return (
format(s, "%U",
-
dpo_vfts[dpo->dpoi_type].dv_format,
-
dpo->dpoi_index,
-
indent)
);
+
s =
format(s, "%U",
+ dpo_vfts[dpo->dpoi_type].dv_format,
+ dpo->dpoi_index,
+
indent
);
}
}
-
- switch (dpo->dpoi_type)
+ else
{
{
- case DPO_FIRST:
- s = format(s, "unset");
- break;
- default:
- s = format(s, "unknown");
- break;
+ switch (dpo->dpoi_type)
+ {
+ case DPO_FIRST:
+ s = format(s, "unset");
+ break;
+ default:
+ s = format(s, "unknown");
+ break;
+ }
}
return (s);
}
}
return (s);
}
@@
-259,16
+262,18
@@
void
dpo_copy (dpo_id_t *dst,
const dpo_id_t *src)
{
dpo_copy (dpo_id_t *dst,
const dpo_id_t *src)
{
- dpo_id_t tmp = *dst;
+ dpo_id_t tmp = {
+ .as_u64 = dst->as_u64
+ };
/*
* the destination is written in a single u64 write - hence atomically w.r.t
* any packets inflight.
*/
/*
* the destination is written in a single u64 write - hence atomically w.r.t
* any packets inflight.
*/
- *((u64*)dst) = *(u64*)src;
+ dst->as_u64 = src->as_u64;
dpo_lock(dst);
dpo_lock(dst);
- dpo_unlock(&tmp);
+ dpo_unlock(&tmp);
}
int
}
int
@@
-276,6
+281,9
@@
dpo_is_adj (const dpo_id_t *dpo)
{
return ((dpo->dpoi_type == DPO_ADJACENCY) ||
(dpo->dpoi_type == DPO_ADJACENCY_INCOMPLETE) ||
{
return ((dpo->dpoi_type == DPO_ADJACENCY) ||
(dpo->dpoi_type == DPO_ADJACENCY_INCOMPLETE) ||
+ (dpo->dpoi_type == DPO_ADJACENCY_GLEAN) ||
+ (dpo->dpoi_type == DPO_ADJACENCY_MCAST) ||
+ (dpo->dpoi_type == DPO_ADJACENCY_MCAST_MIDCHAIN) ||
(dpo->dpoi_type == DPO_ADJACENCY_MIDCHAIN) ||
(dpo->dpoi_type == DPO_ADJACENCY_GLEAN));
}
(dpo->dpoi_type == DPO_ADJACENCY_MIDCHAIN) ||
(dpo->dpoi_type == DPO_ADJACENCY_GLEAN));
}
@@
-303,6
+311,18
@@
dpo_default_get_next_node (const dpo_id_t *dpo)
return (node_indices);
}
return (node_indices);
}
+/**
+ * A default variant of the make interpose function that just returns
+ * the original
+ */
+static void
+dpo_default_mk_interpose (const dpo_id_t *original,
+ const dpo_id_t *parent,
+ dpo_id_t *clone)
+{
+ dpo_copy(clone, original);
+}
+
void
dpo_register (dpo_type_t type,
const dpo_vft_t *vft,
void
dpo_register (dpo_type_t type,
const dpo_vft_t *vft,
@@
-314,6
+334,10
@@
dpo_register (dpo_type_t type,
{
dpo_vfts[type].dv_get_next_node = dpo_default_get_next_node;
}
{
dpo_vfts[type].dv_get_next_node = dpo_default_get_next_node;
}
+ if (NULL == dpo_vfts[type].dv_mk_interpose)
+ {
+ dpo_vfts[type].dv_mk_interpose = dpo_default_mk_interpose;
+ }
vec_validate(dpo_nodes, type);
dpo_nodes[type] = nodes;
vec_validate(dpo_nodes, type);
dpo_nodes[type] = nodes;
@@
-330,6
+354,17
@@
dpo_register_new_type (const dpo_vft_t *vft,
return (type);
}
return (type);
}
+void
+dpo_mk_interpose (const dpo_id_t *original,
+ const dpo_id_t *parent,
+ dpo_id_t *clone)
+{
+ if (!dpo_id_is_valid(original))
+ return;
+
+ dpo_vfts[original->dpoi_type].dv_mk_interpose(original, parent, clone);
+}
+
void
dpo_lock (dpo_id_t *dpo)
{
void
dpo_lock (dpo_id_t *dpo)
{
@@
-379,7
+414,7
@@
dpo_get_next_node (dpo_type_t child_type,
parent_proto, ~0);
/*
parent_proto, ~0);
/*
- * if the edge index has not yet been created for this node to node transi
s
tion
+ * if the edge index has not yet been created for this node to node transition
*/
if (~0 == dpo_edges[child_type][child_proto][parent_type][parent_proto])
{
*/
if (~0 == dpo_edges[child_type][child_proto][parent_type][parent_proto])
{
@@
-465,7
+500,7
@@
dpo_stack_i (u32 edge,
dpo_copy(&tmp, parent);
/*
dpo_copy(&tmp, parent);
/*
- * get the edge index for the parent to child VLIB graph transi
si
tion
+ * get the edge index for the parent to child VLIB graph transition
*/
tmp.dpoi_next_node = edge;
*/
tmp.dpoi_next_node = edge;
@@
-536,6
+571,9
@@
dpo_stack_from_node (u32 child_node_index,
}
}
dpo_stack_i(edge, dpo, parent);
}
}
dpo_stack_i(edge, dpo, parent);
+
+ /* should free this local vector to avoid memory leak */
+ vec_free(parent_indices);
}
static clib_error_t *
}
static clib_error_t *
@@
-556,11
+594,17
@@
dpo_module_init (vlib_main_t * vm)
mpls_disp_dpo_module_init();
dvr_dpo_module_init();
l3_proxy_dpo_module_init();
mpls_disp_dpo_module_init();
dvr_dpo_module_init();
l3_proxy_dpo_module_init();
+ pw_cw_dpo_module_init();
return (NULL);
}
return (NULL);
}
-VLIB_INIT_FUNCTION(dpo_module_init);
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION(dpo_module_init) =
+{
+ .runs_before = VLIB_INITS ("ip_main_init"),
+};
+/* *INDENT-ON* */
static clib_error_t *
dpo_memory_show (vlib_main_t * vm,
static clib_error_t *
dpo_memory_show (vlib_main_t * vm,