#include <vnet/mpls/mpls.h>
#include <vnet/dpo/drop_dpo.h>
+// clang-format off
+
+#ifndef CLIB_MARCH_VARIANT
/*
* pool of all MPLS Label DPOs
*/
mpls_label_dpo_alloc (void)
{
mpls_label_dpo_t *mld;
+ vlib_main_t *vm;
+ u8 did_barrier_sync;
+ dpo_pool_barrier_sync (vm, mpls_label_dpo_pool, did_barrier_sync);
pool_get_aligned(mpls_label_dpo_pool, mld, CLIB_CACHE_LINE_BYTES);
+ dpo_pool_barrier_release (vm, did_barrier_sync);
+
clib_memset(mld, 0, sizeof(*mld));
dpo_reset(&mld->mld_dpo);
pool_put(mpls_label_dpo_pool, mld);
}
}
+#endif /* CLIB_MARCH_VARIANT */
/**
* @brief A struct to hold tracing information for the MPLS label imposition
}
else
{
- clib_memcpy(hdr0, mld0->mld_hdr, mld0->mld_n_hdr_bytes);
+ clib_memcpy_fast(hdr0, mld0->mld_hdr, mld0->mld_n_hdr_bytes);
hdr0 = hdr0 + (mld0->mld_n_labels - 1);
}
if (DPO_PROTO_MPLS != dproto)
{
/*
- * These are the non-MPLS payload imposition cases
+ * These are the non-MPLS payload imposition cases.
+ * Save the l3 offset
*/
+ vnet_buffer (b0)->l3_hdr_offset = b0->current_data;
+ vnet_buffer (b1)->l3_hdr_offset = b1->current_data;
+ vnet_buffer (b2)->l3_hdr_offset = b2->current_data;
+ vnet_buffer (b3)->l3_hdr_offset = b3->current_data;
+
if (DPO_PROTO_IP4 == dproto)
{
ip4_header_t * ip0 = vlib_buffer_get_current(b0);
exp2 = ip_dscp_to_mpls_exp(ip2->tos);
exp3 = ip_dscp_to_mpls_exp(ip3->tos);
}
+
+ /* save the payload proto information in mpls opaque */
+ vnet_buffer(b0)->mpls.pyld_proto = DPO_PROTO_IP4;
+ vnet_buffer(b1)->mpls.pyld_proto = DPO_PROTO_IP4;
+ vnet_buffer(b2)->mpls.pyld_proto = DPO_PROTO_IP4;
+ vnet_buffer(b3)->mpls.pyld_proto = DPO_PROTO_IP4;
}
else if (DPO_PROTO_IP6 == dproto)
{
exp3 = ip_dscp_to_mpls_exp(
ip6_traffic_class_network_order(ip3));
}
+
+ /* save the payload proto information in mpls opaque */
+ vnet_buffer(b0)->mpls.pyld_proto = DPO_PROTO_IP6;
+ vnet_buffer(b1)->mpls.pyld_proto = DPO_PROTO_IP6;
+ vnet_buffer(b2)->mpls.pyld_proto = DPO_PROTO_IP6;
+ vnet_buffer(b3)->mpls.pyld_proto = DPO_PROTO_IP6;
}
else
{
if (DPO_PROTO_MPLS != dproto)
{
+ vnet_buffer (b0)->l3_hdr_offset = b0->current_data;
+
if (DPO_PROTO_IP4 == dproto)
{
/*
ttl0 = ip0->ttl;
exp0 = ip_dscp_to_mpls_exp(ip0->tos);
}
+
+ /* save the payload proto information in mpls opaque */
+ vnet_buffer(b0)->mpls.pyld_proto = DPO_PROTO_IP4;
}
else if (DPO_PROTO_IP6 == dproto)
{
exp0 = ip_dscp_to_mpls_exp(
ip6_traffic_class_network_order(ip0));
}
+
+ /* save the payload proto information in mpls opaque */
+ vnet_buffer(b0)->mpls.pyld_proto = DPO_PROTO_IP6;
}
else
{
return (s);
}
-static uword
-mpls_mpls_label_imposition_pipe (vlib_main_t * vm,
+VLIB_NODE_FN (mpls_mpls_label_imposition_pipe_node) (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
}
VLIB_REGISTER_NODE (mpls_mpls_label_imposition_pipe_node) = {
- .function = mpls_mpls_label_imposition_pipe,
.name = "mpls-label-imposition-pipe",
.vector_size = sizeof (u32),
[0] = "mpls-drop",
}
};
-VLIB_NODE_FUNCTION_MULTIARCH (mpls_mpls_label_imposition_pipe_node,
- mpls_mpls_label_imposition_pipe)
-static uword
-ip4_mpls_label_imposition_pipe (vlib_main_t * vm,
+VLIB_NODE_FN (ip4_mpls_label_imposition_pipe_node) (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
}
VLIB_REGISTER_NODE (ip4_mpls_label_imposition_pipe_node) = {
- .function = ip4_mpls_label_imposition_pipe,
.name = "ip4-mpls-label-imposition-pipe",
.vector_size = sizeof (u32),
[0] = "ip4-drop",
}
};
-VLIB_NODE_FUNCTION_MULTIARCH (ip4_mpls_label_imposition_pipe_node,
- ip4_mpls_label_imposition_pipe)
-static uword
-ip6_mpls_label_imposition_pipe (vlib_main_t * vm,
+VLIB_NODE_FN (ip6_mpls_label_imposition_pipe_node) (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
}
VLIB_REGISTER_NODE (ip6_mpls_label_imposition_pipe_node) = {
- .function = ip6_mpls_label_imposition_pipe,
.name = "ip6-mpls-label-imposition-pipe",
.vector_size = sizeof (u32),
[0] = "ip6-drop",
}
};
-VLIB_NODE_FUNCTION_MULTIARCH (ip6_mpls_label_imposition_pipe_node,
- ip6_mpls_label_imposition_pipe)
-static uword
-ethernet_mpls_label_imposition_pipe (vlib_main_t * vm,
+VLIB_NODE_FN (ethernet_mpls_label_imposition_pipe_node) (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
}
VLIB_REGISTER_NODE (ethernet_mpls_label_imposition_pipe_node) = {
- .function = ethernet_mpls_label_imposition_pipe,
.name = "ethernet-mpls-label-imposition-pipe",
.vector_size = sizeof (u32),
}
};
-VLIB_NODE_FUNCTION_MULTIARCH (ethernet_mpls_label_imposition_pipe_node,
- ethernet_mpls_label_imposition_pipe)
-
-static uword
-mpls_mpls_label_imposition_uniform (vlib_main_t * vm,
+VLIB_NODE_FN (mpls_mpls_label_imposition_uniform_node) (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
}
VLIB_REGISTER_NODE (mpls_mpls_label_imposition_uniform_node) = {
- .function = mpls_mpls_label_imposition_uniform,
.name = "mpls-label-imposition-uniform",
.vector_size = sizeof (u32),
[0] = "mpls-drop",
}
};
-VLIB_NODE_FUNCTION_MULTIARCH (mpls_mpls_label_imposition_uniform_node,
- mpls_mpls_label_imposition_uniform)
-static uword
-ip4_mpls_label_imposition_uniform (vlib_main_t * vm,
+VLIB_NODE_FN (ip4_mpls_label_imposition_uniform_node) (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
}
VLIB_REGISTER_NODE (ip4_mpls_label_imposition_uniform_node) = {
- .function = ip4_mpls_label_imposition_uniform,
.name = "ip4-mpls-label-imposition-uniform",
.vector_size = sizeof (u32),
[0] = "ip4-drop",
}
};
-VLIB_NODE_FUNCTION_MULTIARCH (ip4_mpls_label_imposition_uniform_node,
- ip4_mpls_label_imposition_uniform)
-static uword
-ip6_mpls_label_imposition_uniform (vlib_main_t * vm,
+VLIB_NODE_FN (ip6_mpls_label_imposition_uniform_node) (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
}
VLIB_REGISTER_NODE (ip6_mpls_label_imposition_uniform_node) = {
- .function = ip6_mpls_label_imposition_uniform,
.name = "ip6-mpls-label-imposition-uniform",
.vector_size = sizeof (u32),
[0] = "ip6-drop",
}
};
-VLIB_NODE_FUNCTION_MULTIARCH (ip6_mpls_label_imposition_uniform_node,
- ip6_mpls_label_imposition_uniform)
-static uword
-ethernet_mpls_label_imposition_uniform (vlib_main_t * vm,
+VLIB_NODE_FN (ethernet_mpls_label_imposition_uniform_node) (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
}
VLIB_REGISTER_NODE (ethernet_mpls_label_imposition_uniform_node) = {
- .function = ethernet_mpls_label_imposition_uniform,
.name = "ethernet-mpls-label-imposition-uniform",
.vector_size = sizeof (u32),
}
};
-VLIB_NODE_FUNCTION_MULTIARCH (ethernet_mpls_label_imposition_uniform_node,
- ethernet_mpls_label_imposition_uniform)
-static uword
-ip4_mpls_label_imposition_pipe_no_ip_ttl_decr (vlib_main_t * vm,
+VLIB_NODE_FN (ip4_mpls_label_imposition_pipe_no_ip_ttl_decr_node) (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
}
VLIB_REGISTER_NODE (ip4_mpls_label_imposition_pipe_no_ip_ttl_decr_node) = {
- .function = ip4_mpls_label_imposition_pipe_no_ip_ttl_decr,
.name = "ip4-mpls-label-imposition-pipe-no-ip-ttl-decr",
.vector_size = sizeof (u32),
[0] = "ip4-drop",
}
};
-VLIB_NODE_FUNCTION_MULTIARCH (ip4_mpls_label_imposition_pipe_no_ip_ttl_decr_node,
- ip4_mpls_label_imposition_pipe_no_ip_ttl_decr)
-static uword
-ip6_mpls_label_imposition_pipe_no_ip_ttl_decr (vlib_main_t * vm,
+VLIB_NODE_FN (ip6_mpls_label_imposition_pipe_no_ip_ttl_decr_node) (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
}
VLIB_REGISTER_NODE (ip6_mpls_label_imposition_pipe_no_ip_ttl_decr_node) = {
- .function = ip6_mpls_label_imposition_pipe_no_ip_ttl_decr,
.name = "ip6-mpls-label-imposition-pipe-no-ip-ttl-decr",
.vector_size = sizeof (u32),
[0] = "ip6-drop",
}
};
-VLIB_NODE_FUNCTION_MULTIARCH (ip6_mpls_label_imposition_pipe_no_ip_ttl_decr_node,
- ip6_mpls_label_imposition_pipe_no_ip_ttl_decr)
-static uword
-ip4_mpls_label_imposition_uniform_no_ip_ttl_decr (vlib_main_t * vm,
+VLIB_NODE_FN (ip4_mpls_label_imposition_uniform_no_ip_ttl_decr_node) (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
}
VLIB_REGISTER_NODE (ip4_mpls_label_imposition_uniform_no_ip_ttl_decr_node) = {
- .function = ip4_mpls_label_imposition_uniform_no_ip_ttl_decr,
.name = "ip4-mpls-label-imposition-uniform-no-ip-ttl-decr",
.vector_size = sizeof (u32),
[0] = "ip4-drop",
}
};
-VLIB_NODE_FUNCTION_MULTIARCH (ip4_mpls_label_imposition_uniform_no_ip_ttl_decr_node,
- ip4_mpls_label_imposition_uniform_no_ip_ttl_decr)
-static uword
-ip6_mpls_label_imposition_uniform_no_ip_ttl_decr (vlib_main_t * vm,
+VLIB_NODE_FN (ip6_mpls_label_imposition_uniform_no_ip_ttl_decr_node) (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
}
VLIB_REGISTER_NODE (ip6_mpls_label_imposition_uniform_no_ip_ttl_decr_node) = {
- .function = ip6_mpls_label_imposition_uniform_no_ip_ttl_decr,
.name = "ip6-mpls-label-imposition-uniform-no-ip-ttl-decr",
.vector_size = sizeof (u32),
[0] = "ip6-drop",
}
};
-VLIB_NODE_FUNCTION_MULTIARCH (ip6_mpls_label_imposition_uniform_no_ip_ttl_decr_node,
- ip6_mpls_label_imposition_uniform_no_ip_ttl_decr)
+#ifndef CLIB_MARCH_VARIANT
static void
mpls_label_dpo_mem_show (void)
{
mld = mpls_label_dpo_get(original->dpoi_index);
mld_clone->mld_locks = 0;
- clib_memcpy(&mld_clone->mld_hdr,
+ clib_memcpy_fast(&mld_clone->mld_hdr,
&mld->mld_hdr,
sizeof(mld_clone->mld_hdr));
mld_clone->mld_payload_proto = mld->mld_payload_proto;
mpls_label_dpo_get_index(mld_clone));
}
+static u16
+mpls_label_dpo_get_mtu (const dpo_id_t *dpo)
+{
+ mpls_label_dpo_t *mld;
+
+ mld = mpls_label_dpo_get(dpo->dpoi_index);
+
+ /* return the parent's MTU minus the amount of header
+ * this DPO imposes */
+ return (dpo_get_mtu (&mld->mld_dpo) - sizeof(mpls_label_t) * mld->mld_n_labels);
+}
+
const static dpo_vft_t mld_vft = {
.dv_lock = mpls_label_dpo_lock,
.dv_unlock = mpls_label_dpo_unlock,
.dv_format = format_mpls_label_dpo,
.dv_mem_show = mpls_label_dpo_mem_show,
.dv_mk_interpose = mpls_label_interpose,
+ .dv_get_mtu = mpls_label_dpo_get_mtu,
};
const static char* const mpls_label_imp_pipe_ip4_nodes[] =
{
return (mpls_label_dpo_types[flags]);
}
+#endif /* CLIB_MARCH_VARIANT */
+
+// clang-format on