summaryrefslogtreecommitdiffstats
path: root/vnet
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2016-11-03 20:16:04 +0100
committerDave Barach <openvpp@barachs.net>2016-11-03 22:16:15 +0000
commit05ab8cbdd410f32766d184ad87e5f66a2d2426fe (patch)
treee9cf1b65e9efed12e3e1597de55c85901c645604 /vnet
parentbcc889cd0892a4dba9a06fc3c0ba49356c7220a4 (diff)
vlib: add vlib_buffer_copy function
It works with and without DPDK so it allws us to enable lawful-intercept code in vpp_lite images. Change-Id: I08f234cbc652c3ff47a6123a43b9e7f8bdcd5534 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'vnet')
-rw-r--r--vnet/Makefile.am1
-rw-r--r--vnet/vnet/dpdk_replication.h116
-rw-r--r--vnet/vnet/lawful-intercept/lawful_intercept.c3
-rw-r--r--vnet/vnet/lawful-intercept/lawful_intercept.h1
-rw-r--r--vnet/vnet/lawful-intercept/node.c31
-rw-r--r--vnet/vnet/sr/sr_replicate.c1
6 files changed, 1 insertions, 152 deletions
diff --git a/vnet/Makefile.am b/vnet/Makefile.am
index f53a61bfd44..185c08a9627 100644
--- a/vnet/Makefile.am
+++ b/vnet/Makefile.am
@@ -628,7 +628,6 @@ libvnet_la_SOURCES += \
vnet/lawful-intercept/node.c
nobase_include_HEADERS += \
- vnet/dpdk_replication.h \
vnet/lawful-intercept/lawful_intercept.h
########################################
diff --git a/vnet/vnet/dpdk_replication.h b/vnet/vnet/dpdk_replication.h
deleted file mode 100644
index 24c133619e9..00000000000
--- a/vnet/vnet/dpdk_replication.h
+++ /dev/null
@@ -1,116 +0,0 @@
-#ifndef __included_dpdk_replication_h__
-#define __included_dpdk_replication_h__
-#include <vnet/devices/dpdk/dpdk.h>
-
-/*
- * vlib_dpdk_clone_buffer - clone a buffer
- * for port mirroring, lawful intercept, etc.
- * rte_pktmbuf_clone (...) requires that the forwarding path
- * not touch any of the cloned data. The hope is that we'll
- * figure out how to relax that restriction.
- *
- * For the moment, copy packet data.
- */
-
-static inline vlib_buffer_t *
-vlib_dpdk_clone_buffer (vlib_main_t * vm, vlib_buffer_t * b)
-{
- u32 new_buffers_needed = 1;
- unsigned socket_id = rte_socket_id ();
- struct rte_mempool *rmp = vm->buffer_main->pktmbuf_pools[socket_id];
- struct rte_mbuf *rte_mbufs[5];
- vlib_buffer_free_list_t *fl;
- vlib_buffer_t *rv;
- u8 *copy_src, *copy_dst;
- vlib_buffer_t *src_buf, *dst_buf;
-
- fl = vlib_buffer_get_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
-
- if (PREDICT_FALSE (b->flags & VLIB_BUFFER_NEXT_PRESENT))
- {
- vlib_buffer_t *tmp = b;
- int i;
-
- while (tmp->flags & VLIB_BUFFER_NEXT_PRESENT)
- {
- new_buffers_needed++;
- tmp = vlib_get_buffer (vm, tmp->next_buffer);
- }
-
- /* Should never happen... */
- if (PREDICT_FALSE (new_buffers_needed > ARRAY_LEN (rte_mbufs)))
- {
- clib_warning ("need %d buffers", new_buffers_needed);
- return 0;
- }
-
- if (rte_mempool_get_bulk (rmp, (void **) rte_mbufs,
- new_buffers_needed) < 0)
- return 0;
-
- src_buf = b;
- rv = dst_buf = vlib_buffer_from_rte_mbuf (rte_mbufs[0]);
- vlib_buffer_init_for_free_list (dst_buf, fl);
- copy_src = b->data + src_buf->current_data;
- copy_dst = dst_buf->data + src_buf->current_data;
-
- for (i = 0; i < new_buffers_needed; i++)
- {
- clib_memcpy (copy_src, copy_dst, src_buf->current_length);
- dst_buf->current_data = src_buf->current_data;
- dst_buf->current_length = src_buf->current_length;
- dst_buf->flags = src_buf->flags;
-
- if (i == 0)
- {
- dst_buf->total_length_not_including_first_buffer =
- src_buf->total_length_not_including_first_buffer;
- vnet_buffer (dst_buf)->sw_if_index[VLIB_RX] =
- vnet_buffer (src_buf)->sw_if_index[VLIB_RX];
- vnet_buffer (dst_buf)->sw_if_index[VLIB_TX] =
- vnet_buffer (src_buf)->sw_if_index[VLIB_TX];
- vnet_buffer (dst_buf)->l2 = vnet_buffer (b)->l2;
- }
-
- if (i < new_buffers_needed - 1)
- {
- src_buf = vlib_get_buffer (vm, src_buf->next_buffer);
- dst_buf = vlib_buffer_from_rte_mbuf (rte_mbufs[i + 1]);
- vlib_buffer_init_for_free_list (dst_buf, fl);
- copy_src = src_buf->data;
- copy_dst = dst_buf->data;
- }
- }
- return rv;
- }
-
- if (rte_mempool_get_bulk (rmp, (void **) rte_mbufs, 1) < 0)
- return 0;
-
- rte_pktmbuf_refcnt_update (rte_mbufs[0], 1);
- rv = vlib_buffer_from_rte_mbuf (rte_mbufs[0]);
- vlib_buffer_init_for_free_list (rv, fl);
-
- clib_memcpy (rv->data + b->current_data, b->data + b->current_data,
- b->current_length);
- rv->current_data = b->current_data;
- rv->current_length = b->current_length;
- vnet_buffer (rv)->sw_if_index[VLIB_RX] =
- vnet_buffer (b)->sw_if_index[VLIB_RX];
- vnet_buffer (rv)->sw_if_index[VLIB_TX] =
- vnet_buffer (b)->sw_if_index[VLIB_TX];
- vnet_buffer (rv)->l2 = vnet_buffer (b)->l2;
-
- return (rv);
-}
-
-
-#endif /* __included_dpdk_replication_h__ */
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/vnet/vnet/lawful-intercept/lawful_intercept.c b/vnet/vnet/lawful-intercept/lawful_intercept.c
index 6b2f41f4795..ef07a339201 100644
--- a/vnet/vnet/lawful-intercept/lawful_intercept.c
+++ b/vnet/vnet/lawful-intercept/lawful_intercept.c
@@ -13,7 +13,6 @@
* limitations under the License.
*/
-#if DPDK==1
#include <vnet/lawful-intercept/lawful_intercept.h>
static clib_error_t *
@@ -110,6 +109,4 @@ li_init (vlib_main_t * vm)
}
VLIB_INIT_FUNCTION(li_init);
-#else
-#endif /* DPDK */
diff --git a/vnet/vnet/lawful-intercept/lawful_intercept.h b/vnet/vnet/lawful-intercept/lawful_intercept.h
index 6fe6caf7f45..89e699f51a0 100644
--- a/vnet/vnet/lawful-intercept/lawful_intercept.h
+++ b/vnet/vnet/lawful-intercept/lawful_intercept.h
@@ -18,7 +18,6 @@
#include <vnet/vnet.h>
#include <vnet/ip/ip.h>
-#include <vnet/dpdk_replication.h>
typedef struct {
/* LI collector info */
diff --git a/vnet/vnet/lawful-intercept/node.c b/vnet/vnet/lawful-intercept/node.c
index 8701c323358..ea0cd8efcdd 100644
--- a/vnet/vnet/lawful-intercept/node.c
+++ b/vnet/vnet/lawful-intercept/node.c
@@ -17,7 +17,6 @@
#include <vnet/vnet.h>
#include <vppinfra/error.h>
-#if DPDK==1
#include <vnet/lawful-intercept/lawful_intercept.h>
#include <vppinfra/error.h>
@@ -199,7 +198,7 @@ li_hit_node_fn (vlib_main_t * vm,
if (PREDICT_TRUE(to_int_next != 0))
{
/* Make an intercept copy */
- c0 = vlib_dpdk_clone_buffer (vm, b0);
+ c0 = vlib_buffer_copy (vm, b0);
vlib_buffer_advance(c0, -sizeof(*iu0));
@@ -274,31 +273,3 @@ VLIB_REGISTER_NODE (li_hit_node) = {
VLIB_NODE_FUNCTION_MULTIARCH (li_hit_node, li_hit_node_fn)
-#else
-#include <vlib/vlib.h>
-
-static uword
-li_hit_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
-{
- clib_warning ("LI not implemented (no DPDK)");
- return 0;
-}
-
-VLIB_REGISTER_NODE (li_hit_node) = {
- .vector_size = sizeof (u32),
- .function = li_hit_node_fn,
- .name = "li-hit",
-};
-
-static clib_error_t *
-li_init (vlib_main_t * vm)
-{
- return 0;
-}
-
-VLIB_INIT_FUNCTION(li_init);
-
-
-#endif /* DPDK */
diff --git a/vnet/vnet/sr/sr_replicate.c b/vnet/vnet/sr/sr_replicate.c
index 9cc7c5a0dde..9aa57873c8c 100644
--- a/vnet/vnet/sr/sr_replicate.c
+++ b/vnet/vnet/sr/sr_replicate.c
@@ -30,7 +30,6 @@
#include <vnet/pg/pg.h>
#include <vnet/sr/sr.h>
#include <vnet/devices/dpdk/dpdk.h>
-#include <vnet/dpdk_replication.h>
#include <vnet/ip/ip.h>
#include <vnet/fib/ip6_fib.h>