summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2017-02-28 19:22:22 +0100
committerDave Barach <openvpp@barachs.net>2017-03-01 22:06:31 +0000
commitc3a814be9dc769be942ff8029c7b6eccd4b3af05 (patch)
treedd152b3e92281ab52f806ed2ad237c9fb0607e8b /src
parentf71ef1dddfc7cf34944c510b85bec074f431bb12 (diff)
dpdk: be a plugin
Change-Id: I238258cdeb77035adc5e88903d824593d0a1da90 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am21
-rw-r--r--src/plugins/Makefile.am5
-rw-r--r--src/plugins/dpdk.am50
-rw-r--r--src/plugins/dpdk/api/dpdk.api (renamed from src/vnet/devices/dpdk/dpdk.api)0
-rw-r--r--src/plugins/dpdk/api/dpdk_all_api_h.h19
-rw-r--r--src/plugins/dpdk/api/dpdk_msg_enum.h31
-rw-r--r--src/plugins/dpdk/api/dpdk_test.c397
-rw-r--r--src/plugins/dpdk/buffer.c (renamed from src/vnet/devices/dpdk/buffer.c)4
-rw-r--r--src/plugins/dpdk/device/cli.c (renamed from src/vnet/devices/dpdk/cli.c)4
-rw-r--r--src/plugins/dpdk/device/device.c (renamed from src/vnet/devices/dpdk/device.c)4
-rw-r--r--src/plugins/dpdk/device/dpdk.h (renamed from src/vnet/devices/dpdk/dpdk.h)3
-rw-r--r--src/plugins/dpdk/device/dpdk_priv.h (renamed from src/vnet/devices/dpdk/dpdk_priv.h)0
-rw-r--r--src/plugins/dpdk/device/format.c (renamed from src/vnet/devices/dpdk/format.c)4
-rw-r--r--src/plugins/dpdk/device/node.c (renamed from src/vnet/devices/dpdk/node.c)4
-rw-r--r--src/plugins/dpdk/dir.dox (renamed from src/vnet/devices/dpdk/dir.dox)0
-rw-r--r--src/plugins/dpdk/hqos/hqos.c (renamed from src/vnet/devices/dpdk/hqos.c)4
-rw-r--r--src/plugins/dpdk/hqos/qos_doc.md (renamed from src/vnet/devices/dpdk/qos_doc.md)0
-rwxr-xr-xsrc/plugins/dpdk/init.c (renamed from src/vnet/devices/dpdk/init.c)277
-rw-r--r--src/plugins/dpdk/ipsec/cli.c (renamed from src/vnet/devices/dpdk/ipsec/cli.c)4
-rw-r--r--src/plugins/dpdk/ipsec/crypto_node.c (renamed from src/vnet/devices/dpdk/ipsec/crypto_node.c)6
-rw-r--r--src/plugins/dpdk/ipsec/dir.dox (renamed from src/vnet/devices/dpdk/ipsec/dir.dox)0
-rw-r--r--src/plugins/dpdk/ipsec/dpdk_crypto_ipsec_doc.md (renamed from src/vnet/devices/dpdk/ipsec/dpdk_crypto_ipsec_doc.md)0
-rw-r--r--src/plugins/dpdk/ipsec/esp.h (renamed from src/vnet/devices/dpdk/ipsec/esp.h)2
-rw-r--r--src/plugins/dpdk/ipsec/esp_decrypt.c (renamed from src/vnet/devices/dpdk/ipsec/esp_decrypt.c)8
-rw-r--r--src/plugins/dpdk/ipsec/esp_encrypt.c (renamed from src/vnet/devices/dpdk/ipsec/esp_encrypt.c)8
-rw-r--r--src/plugins/dpdk/ipsec/ipsec.c (renamed from src/vnet/devices/dpdk/ipsec/ipsec.c)6
-rw-r--r--src/plugins/dpdk/ipsec/ipsec.h (renamed from src/vnet/devices/dpdk/ipsec/ipsec.h)0
-rw-r--r--src/plugins/dpdk/main.c (renamed from src/vnet/devices/dpdk/main.c)14
-rw-r--r--src/plugins/dpdk/thread.c (renamed from src/vnet/devices/dpdk/thread.c)4
-rw-r--r--src/vat/api_format.c320
-rw-r--r--src/vnet.am41
-rw-r--r--src/vnet/devices/dpdk/dpdk_api.c246
-rw-r--r--src/vnet/devices/virtio/vhost-user.h11
-rw-r--r--src/vnet/ipsec/ipsec_api.c4
-rw-r--r--src/vnet/pg/input.c11
-rw-r--r--src/vnet/pg/stream.c5
-rw-r--r--src/vnet/replication.c6
-rw-r--r--src/vnet/vnet_all_api_h.h3
-rw-r--r--src/vpp/api/custom_dump.c64
-rw-r--r--src/vpp/api/gmon.c3
-rw-r--r--src/vpp/api/vpe.api1
-rw-r--r--src/vpp/app/l2t.c562
-rw-r--r--src/vpp/app/l2t_l2.c267
43 files changed, 838 insertions, 1585 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 641707ed122..5daaa48e9df 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -39,27 +39,6 @@ install-data-local:
echo "Command list built, Time taken: $$GREP_TIME"
###############################################################################
-# DPDK
-###############################################################################
-
-if WITH_DPDK
-if ENABLE_DPDK_SHARED
-DPDK_LD_FLAGS = -Wl,--whole-archive,-ldpdk,--no-whole-archive
-else
-DPDK_LD_FLAGS = -Wl,--whole-archive,-l:libdpdk.a,--no-whole-archive,-lm,-ldl
-endif
-if WITH_DPDK_CRYPTO_SW
-DPDK_LD_ADD = -lIPSec_MB -lisal_crypto
-endif
-if WITH_DPDK_MLX5_PMD
-DPDK_LD_FLAGS += -libverbs -lmlx5 -lnuma
-endif
-else
-DPDK_LD_FLAGS =
-DPDK_LD_ADD =
-endif
-
-###############################################################################
# Components
###############################################################################
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 06b575d1cc3..c8877899524 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -24,6 +24,7 @@ vppplugins_LTLIBRARIES =
vppapitestplugins_LTLIBRARIES =
noinst_HEADERS =
nobase_apiinclude_HEADERS =
+nobase_include_HEADERS =
vppapitestpluginsdir = ${libdir}/vpp_api_test_plugins
vpppluginsdir = ${libdir}/vpp_plugins
@@ -32,6 +33,10 @@ if ENABLE_ACL_PLUGIN
include acl.am
endif
+if WITH_DPDK
+include dpdk.am
+endif
+
if ENABLE_FLOWPERPKT_PLUGIN
include flowperpkt.am
endif
diff --git a/src/plugins/dpdk.am b/src/plugins/dpdk.am
new file mode 100644
index 00000000000..212bbb737f5
--- /dev/null
+++ b/src/plugins/dpdk.am
@@ -0,0 +1,50 @@
+# Copyright (c) 2016 Cisco Systems, Inc.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+vppapitestplugins_LTLIBRARIES += dpdk_test_plugin.la
+vppplugins_LTLIBRARIES += dpdk_plugin.la
+
+dpdk_plugin_la_LDFLAGS = $(AM_LDFLAGS) -Wl,--whole-archive,-l:libdpdk.a,--no-whole-archive,-lm,-ldl
+
+dpdk_plugin_la_SOURCES = \
+ dpdk/init.c \
+ dpdk/main.c \
+ dpdk/buffer.c \
+ dpdk/thread.c \
+ dpdk/device/cli.c \
+ dpdk/device/dpdk_priv.h \
+ dpdk/device/device.c \
+ dpdk/device/format.c \
+ dpdk/device/node.c \
+ dpdk/hqos/hqos.c \
+ dpdk/ipsec/esp_encrypt.c \
+ dpdk/ipsec/esp_decrypt.c \
+ dpdk/ipsec/crypto_node.c \
+ dpdk/ipsec/cli.c \
+ dpdk/ipsec/ipsec.c \
+ dpdk/api/dpdk_plugin.api.h
+
+API_FILES += dpdk/api/dpdk.api
+
+nobase_include_HEADERS += \
+ dpdk/device/dpdk.h \
+ dpdk/api/dpdk_all_api_h.h
+
+nobase_include_HEADERS += \
+ dpdk/ipsec/ipsec.h \
+ dpdk/ipsec/esp.h
+
+dpdk_test_plugin_la_SOURCES = \
+ dpdk/api/dpdk_test.c dpdk/api/dpdk_plugin.api.h
+
+# vi:syntax=automake
diff --git a/src/vnet/devices/dpdk/dpdk.api b/src/plugins/dpdk/api/dpdk.api
index 21215d456a3..21215d456a3 100644
--- a/src/vnet/devices/dpdk/dpdk.api
+++ b/src/plugins/dpdk/api/dpdk.api
diff --git a/src/plugins/dpdk/api/dpdk_all_api_h.h b/src/plugins/dpdk/api/dpdk_all_api_h.h
new file mode 100644
index 00000000000..15eb98d6aab
--- /dev/null
+++ b/src/plugins/dpdk/api/dpdk_all_api_h.h
@@ -0,0 +1,19 @@
+
+/*
+ * dpdk_all_api_h.h - skeleton vpp engine plug-in api #include file
+ *
+ * Copyright (c) <current-year> <your-organization>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/* Include the generated file, see BUILT_SOURCES in Makefile.am */
+#include <dpdk/api/dpdk.api.h>
diff --git a/src/plugins/dpdk/api/dpdk_msg_enum.h b/src/plugins/dpdk/api/dpdk_msg_enum.h
new file mode 100644
index 00000000000..952ce6ad5f8
--- /dev/null
+++ b/src/plugins/dpdk/api/dpdk_msg_enum.h
@@ -0,0 +1,31 @@
+
+/*
+ * dpdk_msg_enum.h - skeleton vpp engine plug-in message enumeration
+ *
+ * Copyright (c) <current-year> <your-organization>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef included_dpdk_msg_enum_h
+#define included_dpdk_msg_enum_h
+
+#include <vppinfra/byte_order.h>
+
+#define vl_msg_id(n,h) n,
+typedef enum {
+#include <dpdk/api/dpdk_all_api_h.h>
+ /* We'll want to know how many messages IDs we need... */
+ VL_MSG_FIRST_AVAILABLE,
+} vl_msg_id_t;
+#undef vl_msg_id
+
+#endif /* included_dpdk_msg_enum_h */
diff --git a/src/plugins/dpdk/api/dpdk_test.c b/src/plugins/dpdk/api/dpdk_test.c
new file mode 100644
index 00000000000..9fe0f93486c
--- /dev/null
+++ b/src/plugins/dpdk/api/dpdk_test.c
@@ -0,0 +1,397 @@
+
+/*
+ * dpdk_test.c - skeleton vpp-api-test plug-in
+ *
+ * Copyright (c) <current-year> <your-organization>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <vat/vat.h>
+#include <vlibapi/api.h>
+#include <vlibmemory/api.h>
+#include <vlibsocket/api.h>
+#include <vppinfra/error.h>
+#include <vnet/ip/ip.h>
+
+uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
+
+/* Declare message IDs */
+#include <dpdk/api/dpdk_msg_enum.h>
+
+/* define message structures */
+#define vl_typedefs
+#include <dpdk/api/dpdk.api.h>
+#undef vl_typedefs
+
+/* declare message handlers for each api */
+
+#define vl_endianfun /* define message structures */
+#include <dpdk/api/dpdk.api.h>
+#undef vl_endianfun
+
+/* instantiate all the print functions we know about */
+#define vl_print(handle, ...)
+#define vl_printfun
+#include <dpdk/api/dpdk.api.h>
+#undef vl_printfun
+
+/* Get the API version number. */
+#define vl_api_version(n,v) static u32 api_version=(v);
+#include <dpdk/api/dpdk.api.h>
+#undef vl_api_version
+
+typedef struct {
+ /* API message ID base */
+ u16 msg_id_base;
+ vat_main_t *vat_main;
+} dpdk_test_main_t;
+
+dpdk_test_main_t dpdk_test_main;
+
+#define foreach_standard_reply_retval_handler \
+_(sw_interface_set_dpdk_hqos_pipe_reply) \
+_(sw_interface_set_dpdk_hqos_subport_reply) \
+_(sw_interface_set_dpdk_hqos_tctbl_reply)
+
+#define _(n) \
+ static void vl_api_##n##_t_handler \
+ (vl_api_##n##_t * mp) \
+ { \
+ vat_main_t * vam = dpdk_test_main.vat_main; \
+ i32 retval = ntohl(mp->retval); \
+ if (vam->async_mode) { \
+ vam->async_errors += (retval < 0); \
+ } else { \
+ vam->retval = retval; \
+ vam->result_ready = 1; \
+ } \
+ }
+foreach_standard_reply_retval_handler;
+#undef _
+
+/*
+ * Table of message reply handlers, must include boilerplate handlers
+ * we just generated
+ */
+#define foreach_vpe_api_reply_msg \
+_(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
+ sw_interface_set_dpdk_hqos_pipe_reply) \
+_(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
+ sw_interface_set_dpdk_hqos_subport_reply) \
+_(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
+ sw_interface_set_dpdk_hqos_tctbl_reply)
+
+/* M: construct, but don't yet send a message */
+#define M(T,t) \
+do { \
+ vam->result_ready = 0; \
+ mp = vl_msg_api_alloc(sizeof(*mp)); \
+ memset (mp, 0, sizeof (*mp)); \
+ mp->_vl_msg_id = ntohs (VL_API_##T + dm->msg_id_base); \
+ mp->client_index = vam->my_client_index; \
+} while(0);
+
+#define M2(T,t,n) \
+do { \
+ vam->result_ready = 0; \
+ mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
+ memset (mp, 0, sizeof (*mp)); \
+ mp->_vl_msg_id = ntohs (VL_API_##T + dm->msg_id_base); \
+ mp->client_index = vam->my_client_index; \
+} while(0);
+
+/* S: send a message */
+#define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
+
+/* W: wait for results, with timeout */
+#define W \
+do { \
+ timeout = vat_time_now (vam) + 1.0; \
+ \
+ while (vat_time_now (vam) < timeout) { \
+ if (vam->result_ready == 1) { \
+ return (vam->retval); \
+ } \
+ } \
+ return -99; \
+} while(0);
+
+static int
+api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
+{
+ dpdk_test_main_t * dm = &dpdk_test_main;
+ unformat_input_t *i = vam->input;
+ vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
+ f64 timeout;
+ u32 sw_if_index;
+ u8 sw_if_index_set = 0;
+ u32 subport;
+ u8 subport_set = 0;
+ u32 pipe;
+ u8 pipe_set = 0;
+ u32 profile;
+ u8 profile_set = 0;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "rx sw_if_index %u", &sw_if_index))
+ sw_if_index_set = 1;
+ else if (unformat (i, "subport %u", &subport))
+ subport_set = 1;
+ else if (unformat (i, "pipe %u", &pipe))
+ pipe_set = 1;
+ else if (unformat (i, "profile %u", &profile))
+ profile_set = 1;
+ else
+ break;
+ }
+
+ if (sw_if_index_set == 0)
+ {
+ errmsg ("missing interface name or sw_if_index");
+ return -99;
+ }
+
+ if (subport_set == 0)
+ {
+ errmsg ("missing subport ");
+ return -99;
+ }
+
+ if (pipe_set == 0)
+ {
+ errmsg ("missing pipe");
+ return -99;
+ }
+
+ if (profile_set == 0)
+ {
+ errmsg ("missing profile");
+ return -99;
+ }
+
+ M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe);
+
+ mp->sw_if_index = ntohl (sw_if_index);
+ mp->subport = ntohl (subport);
+ mp->pipe = ntohl (pipe);
+ mp->profile = ntohl (profile);
+
+
+ S;
+ W;
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
+{
+ dpdk_test_main_t * dm = &dpdk_test_main;
+ unformat_input_t *i = vam->input;
+ vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
+ f64 timeout;
+ u32 sw_if_index;
+ u8 sw_if_index_set = 0;
+ u32 subport;
+ u8 subport_set = 0;
+ u32 tb_rate = 1250000000; /* 10GbE */
+ u32 tb_size = 1000000;
+ u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
+ u32 tc_period = 10;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "rx sw_if_index %u", &sw_if_index))
+ sw_if_index_set = 1;
+ else if (unformat (i, "subport %u", &subport))
+ subport_set = 1;
+ else if (unformat (i, "rate %u", &tb_rate))
+ {
+ u32 tc_id;
+
+ for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
+ tc_id++)
+ tc_rate[tc_id] = tb_rate;
+ }
+ else if (unformat (i, "bktsize %u", &tb_size))
+ ;
+ else if (unformat (i, "tc0 %u", &tc_rate[0]))
+ ;
+ else if (unformat (i, "tc1 %u", &tc_rate[1]))
+ ;
+ else if (unformat (i, "tc2 %u", &tc_rate[2]))
+ ;
+ else if (unformat (i, "tc3 %u", &tc_rate[3]))
+ ;
+ else if (unformat (i, "period %u", &tc_period))
+ ;
+ else
+ break;
+ }
+
+ if (sw_if_index_set == 0)
+ {
+ errmsg ("missing interface name or sw_if_index");
+ return -99;
+ }
+
+ if (subport_set == 0)
+ {
+ errmsg ("missing subport ");
+ return -99;
+ }
+
+ M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport);
+
+ mp->sw_if_index = ntohl (sw_if_index);
+ mp->subport = ntohl (subport);
+ mp->tb_rate = ntohl (tb_rate);
+ mp->tb_size = ntohl (tb_size);
+ mp->tc_rate[0] = ntohl (tc_rate[0]);
+ mp->tc_rate[1] = ntohl (tc_rate[1]);
+ mp->tc_rate[2] = ntohl (tc_rate[2]);
+ mp->tc_rate[3] = ntohl (tc_rate[3]);
+ mp->tc_period = ntohl (tc_period);
+
+ S;
+ W;
+ /* NOTREACHED */
+ return 0;
+}
+
+static int
+api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
+{
+ dpdk_test_main_t * dm = &dpdk_test_main;
+ unformat_input_t *i = vam->input;
+ vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
+ f64 timeout;
+ u32 sw_if_index;
+ u8 sw_if_index_set = 0;
+ u8 entry_set = 0;
+ u8 tc_set = 0;
+ u8 queue_set = 0;
+ u32 entry, tc, queue;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "rx sw_if_index %u", &sw_if_index))
+ sw_if_index_set = 1;
+ else if (unformat (i, "entry %d", &entry))
+ entry_set = 1;
+ else if (unformat (i, "tc %d", &tc))
+ tc_set = 1;
+ else if (unformat (i, "queue %d", &queue))
+ queue_set = 1;
+ else
+ break;
+ }
+
+ if (sw_if_index_set == 0)
+ {
+ errmsg ("missing interface name or sw_if_index");
+ return -99;
+ }
+
+ if (entry_set == 0)
+ {
+ errmsg ("missing entry ");
+ return -99;
+ }
+
+ if (tc_set == 0)
+ {
+ errmsg ("missing traffic class ");
+ return -99;
+ }
+
+ if (queue_set == 0)
+ {
+ errmsg ("missing queue ");
+ return -99;
+ }
+
+ M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl);
+
+ mp->sw_if_index = ntohl (sw_if_index);
+ mp->entry = ntohl (entry);
+ mp->tc = ntohl (tc);
+ mp->queue = ntohl (queue);
+
+ S;
+ W;
+ /* NOTREACHED */
+ return 0;
+}
+
+/*
+ * List of messages that the api test plugin sends,
+ * and that the data plane plugin processes
+ */
+#define foreach_vpe_api_msg \
+_(sw_interface_set_dpdk_hqos_pipe, \
+ "rx sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
+ "profile <profile-id>\n") \
+_(sw_interface_set_dpdk_hqos_subport, \
+ "rx sw_if_index <id> subport <subport-id> [rate <n>]\n" \
+ "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
+_(sw_interface_set_dpdk_hqos_tctbl, \
+ "rx sw_if_index <id> entry <n> tc <n> queue <n>\n")
+
+void vat_api_hookup (vat_main_t *vam)
+{
+ dpdk_test_main_t * dm __attribute__((unused)) = &dpdk_test_main;
+ /* Hook up handlers for replies from the data plane plug-in */
+#define _(N,n) \
+ vl_msg_api_set_handlers((VL_API_##N + dm->msg_id_base), \
+ #n, \
+ vl_api_##n##_t_handler, \
+ vl_noop_handler, \
+ vl_api_##n##_t_endian, \
+ vl_api_##n##_t_print, \
+ sizeof(vl_api_##n##_t), 1);
+ foreach_vpe_api_reply_msg;
+#undef _
+
+ /* API messages we can send */
+#define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
+ foreach_vpe_api_msg;
+#undef _
+
+ /* Help strings */
+#define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
+ foreach_vpe_api_msg;
+#undef _
+}
+
+clib_error_t * vat_plugin_register (vat_main_t *vam)
+{
+ dpdk_test_main_t * dm = &dpdk_test_main;
+ u8 * name;
+
+ dm->vat_main = vam;
+
+ /* Ask the vpp engine for the first assigned message-id */
+ name = format (0, "dpdk_%08x%c", api_version, 0);
+ dm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
+
+ if (dm->msg_id_base != (u16) ~0)
+ vat_api_hookup (vam);
+
+ vec_free(name);
+
+ return 0;
+}
diff --git a/src/vnet/devices/dpdk/buffer.c b/src/plugins/dpdk/buffer.c
index f95d4cb5c38..2765c292dee 100644
--- a/src/vnet/devices/dpdk/buffer.c
+++ b/src/plugins/dpdk/buffer.c
@@ -72,8 +72,8 @@
#include <vlib/vlib.h>
#include <vnet/vnet.h>
-#include <vnet/devices/dpdk/dpdk.h>
-#include <vnet/devices/dpdk/dpdk_priv.h>
+#include <dpdk/device/dpdk.h>
+#include <dpdk/device/dpdk_priv.h>
STATIC_ASSERT (VLIB_BUFFER_PRE_DATA_SIZE == RTE_PKTMBUF_HEADROOM,
diff --git a/src/vnet/devices/dpdk/cli.c b/src/plugins/dpdk/device/cli.c
index 999988622b0..d2def2fcd67 100644
--- a/src/vnet/devices/dpdk/cli.c
+++ b/src/plugins/dpdk/device/cli.c
@@ -19,11 +19,11 @@
#include <vppinfra/xxhash.h>
#include <vnet/ethernet/ethernet.h>
-#include <vnet/devices/dpdk/dpdk.h>
+#include <dpdk/device/dpdk.h>
#include <vnet/classify/vnet_classify.h>
#include <vnet/mpls/packet.h>
-#include "dpdk_priv.h"
+#include <dpdk/device/dpdk_priv.h>
/**
* @file
diff --git a/src/vnet/devices/dpdk/device.c b/src/plugins/dpdk/device/device.c
index 17397900c59..50b2668977f 100644
--- a/src/vnet/devices/dpdk/device.c
+++ b/src/plugins/dpdk/device/device.c
@@ -19,9 +19,9 @@
#include <assert.h>
#include <vnet/ethernet/ethernet.h>
-#include <vnet/devices/dpdk/dpdk.h>
+#include <dpdk/device/dpdk.h>
-#include "dpdk_priv.h"
+#include <dpdk/device/dpdk_priv.h>
#include <vppinfra/error.h>
#define foreach_dpdk_tx_func_error \
diff --git a/src/vnet/devices/dpdk/dpdk.h b/src/plugins/dpdk/device/dpdk.h
index bf9f2768e08..2a1a62057c3 100644
--- a/src/vnet/devices/dpdk/dpdk.h
+++ b/src/plugins/dpdk/device/dpdk.h
@@ -390,6 +390,9 @@ typedef struct
/* mempool */
struct rte_mempool **pktmbuf_pools;
+
+ /* API message ID base */
+ u16 msg_id_base;
} dpdk_main_t;
dpdk_main_t dpdk_main;
diff --git a/src/vnet/devices/dpdk/dpdk_priv.h b/src/plugins/dpdk/device/dpdk_priv.h
index dd40ff48510..dd40ff48510 100644
--- a/src/vnet/devices/dpdk/dpdk_priv.h
+++ b/src/plugins/dpdk/device/dpdk_priv.h
diff --git a/src/vnet/devices/dpdk/format.c b/src/plugins/dpdk/device/format.c
index 1558630cc68..25a8c5cbe85 100644
--- a/src/vnet/devices/dpdk/format.c
+++ b/src/plugins/dpdk/device/format.c
@@ -19,9 +19,9 @@
#include <assert.h>
#include <vnet/ethernet/ethernet.h>
-#include <vnet/devices/dpdk/dpdk.h>
+#include <dpdk/device/dpdk.h>
-#include "dpdk_priv.h"
+#include <dpdk/device/dpdk_priv.h>
#include <vppinfra/error.h>
#define foreach_dpdk_counter \
diff --git a/src/vnet/devices/dpdk/node.c b/src/plugins/dpdk/device/node.c
index 0d64ae089e7..8824d78944e 100644
--- a/src/vnet/devices/dpdk/node.c
+++ b/src/plugins/dpdk/device/node.c
@@ -19,14 +19,14 @@
#include <vppinfra/xxhash.h>
#include <vnet/ethernet/ethernet.h>
-#include <vnet/devices/dpdk/dpdk.h>
+#include <dpdk/device/dpdk.h>
#include <vnet/classify/vnet_classify.h>
#include <vnet/mpls/packet.h>
#include <vnet/handoff.h>
#include <vnet/devices/devices.h>
#include <vnet/feature/feature.h>
-#include "dpdk_priv.h"
+#include <dpdk/device/dpdk_priv.h>
static char *dpdk_error_strings[] = {
#define _(n,s) s,
diff --git a/src/vnet/devices/dpdk/dir.dox b/src/plugins/dpdk/dir.dox
index 43e36753245..43e36753245 100644
--- a/src/vnet/devices/dpdk/dir.dox
+++ b/src/plugins/dpdk/dir.dox
diff --git a/src/vnet/devices/dpdk/hqos.c b/src/plugins/dpdk/hqos/hqos.c
index d68bc48f80b..a288fca7e5e 100644
--- a/src/vnet/devices/dpdk/hqos.c
+++ b/src/plugins/dpdk/hqos/hqos.c
@@ -27,7 +27,7 @@
#include <vnet/vnet.h>
#include <vnet/ethernet/ethernet.h>
-#include <vnet/devices/dpdk/dpdk.h>
+#include <dpdk/device/dpdk.h>
#include <vlib/unix/physmem.h>
#include <vlib/pci/pci.h>
@@ -44,7 +44,7 @@
#include <vlibmemory/vl_memory_api_h.h>
#undef vl_printfun
-#include "dpdk_priv.h"
+#include <dpdk/device/dpdk_priv.h>
dpdk_main_t dpdk_main;
diff --git a/src/vnet/devices/dpdk/qos_doc.md b/src/plugins/dpdk/hqos/qos_doc.md
index 7c064246e60..7c064246e60 100644
--- a/src/vnet/devices/dpdk/qos_doc.md
+++ b/src/plugins/dpdk/hqos/qos_doc.md
diff --git a/src/vnet/devices/dpdk/init.c b/src/plugins/dpdk/init.c
index 29423e152c4..e009ef3e296 100755
--- a/src/vnet/devices/dpdk/init.c
+++ b/src/plugins/dpdk/init.c
@@ -19,7 +19,7 @@
#include <vppinfra/bitmap.h>
#include <vnet/ethernet/ethernet.h>
-#include <vnet/devices/dpdk/dpdk.h>
+#include <dpdk/device/dpdk.h>
#include <vlib/unix/physmem.h>
#include <vlib/pci/pci.h>
@@ -31,10 +31,267 @@
#include <string.h>
#include <fcntl.h>
-#include "dpdk_priv.h"
+#include <dpdk/device/dpdk_priv.h>
dpdk_main_t dpdk_main;
+#include <vlibapi/api.h>
+#include <vlibmemory/api.h>
+
+/* define message IDs */
+#include <dpdk/api/dpdk_msg_enum.h>
+
+#define vl_typedefs /* define message structures */
+#include <dpdk/api/dpdk_all_api_h.h>
+#undef vl_typedefs
+
+#define vl_endianfun /* define message structures */
+#include <dpdk/api/dpdk_all_api_h.h>
+#undef vl_endianfun
+
+#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
+
+/* Get the API version number. */
+#define vl_api_version(n,v) static u32 api_version=(v);
+#include <dpdk/api/dpdk_all_api_h.h>
+#undef vl_api_version
+
+/* Macro to finish up custom dump fns */
+#define FINISH \
+ vec_add1 (s, 0); \
+ vl_print (handle, (char *)s); \
+ vec_free (s); \
+ return handle;
+
+#include <vlibapi/api_helper_macros.h>
+
+static void
+ vl_api_sw_interface_set_dpdk_hqos_pipe_t_handler
+ (vl_api_sw_interface_set_dpdk_hqos_pipe_t * mp)
+{
+ vl_api_sw_interface_set_dpdk_hqos_pipe_reply_t *rmp;
+ int rv = 0;
+
+ dpdk_main_t *dm = &dpdk_main;
+ dpdk_device_t *xd;
+
+ u32 sw_if_index = ntohl (mp->sw_if_index);
+ u32 subport = ntohl (mp->subport);
+ u32 pipe = ntohl (mp->pipe);
+ u32 profile = ntohl (mp->profile);
+ vnet_hw_interface_t *hw;
+
+ VALIDATE_SW_IF_INDEX (mp);
+
+ /* hw_if & dpdk device */
+ hw = vnet_get_sup_hw_interface (dm->vnet_main, sw_if_index);
+
+ xd = vec_elt_at_index (dm->devices, hw->dev_instance);
+
+ rv = rte_sched_pipe_config (xd->hqos_ht->hqos, subport, pipe, profile);
+
+ BAD_SW_IF_INDEX_LABEL;
+
+ REPLY_MACRO (VL_API_SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY);
+}
+
+static void *vl_api_sw_interface_set_dpdk_hqos_pipe_t_print
+ (vl_api_sw_interface_set_dpdk_hqos_pipe_t * mp, void *handle)
+{
+ u8 *s;
+
+ s = format (0, "SCRIPT: sw_interface_set_dpdk_hqos_pipe ");
+
+ s = format (s, "sw_if_index %u ", ntohl (mp->sw_if_index));
+
+ s = format (s, "subport %u pipe %u profile %u ",
+ ntohl (mp->subport), ntohl (mp->pipe), ntohl (mp->profile));
+
+ FINISH;
+}
+
+static void
+ vl_api_sw_interface_set_dpdk_hqos_subport_t_handler
+ (vl_api_sw_interface_set_dpdk_hqos_subport_t * mp)
+{
+ vl_api_sw_interface_set_dpdk_hqos_subport_reply_t *rmp;
+ int rv = 0;
+
+ dpdk_main_t *dm = &dpdk_main;
+ dpdk_device_t *xd;
+ struct rte_sched_subport_params p;
+
+ u32 sw_if_index = ntohl (mp->sw_if_index);
+ u32 subport = ntohl (mp->subport);
+ p.tb_rate = ntohl (mp->tb_rate);
+ p.tb_size = ntohl (mp->tb_size);
+ p.tc_rate[0] = ntohl (mp->tc_rate[0]);
+ p.tc_rate[1] = ntohl (mp->tc_rate[1]);
+ p.tc_rate[2] = ntohl (mp->tc_rate[2]);
+ p.tc_rate[3] = ntohl (mp->tc_rate[3]);
+ p.tc_period = ntohl (mp->tc_period);
+
+ vnet_hw_interface_t *hw;
+
+ VALIDATE_SW_IF_INDEX (mp);
+
+ /* hw_if & dpdk device */
+ hw = vnet_get_sup_hw_interface (dm->vnet_main, sw_if_index);
+
+ xd = vec_elt_at_index (dm->devices, hw->dev_instance);
+
+ rv = rte_sched_subport_config (xd->hqos_ht->hqos, subport, &p);
+
+ BAD_SW_IF_INDEX_LABEL;
+
+ REPLY_MACRO (VL_API_SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY);
+}
+
+static void *vl_api_sw_interface_set_dpdk_hqos_subport_t_print
+ (vl_api_sw_interface_set_dpdk_hqos_subport_t * mp, void *handle)
+{
+ u8 *s;
+
+ s = format (0, "SCRIPT: sw_interface_set_dpdk_hqos_subport ");
+
+ s = format (s, "sw_if_index %u ", ntohl (mp->sw_if_index));
+
+ s =
+ format (s,
+ "subport %u rate %u bkt_size %u tc0 %u tc1 %u tc2 %u tc3 %u period %u",
+ ntohl (mp->subport), ntohl (mp->tb_rate), ntohl (mp->tb_size),
+ ntohl (mp->tc_rate[0]), ntohl (mp->tc_rate[1]),
+ ntohl (mp->tc_rate[2]), ntohl (mp->tc_rate[3]),
+ ntohl (mp->tc_period));
+
+ FINISH;
+}
+
+static void
+ vl_api_sw_interface_set_dpdk_hqos_tctbl_t_handler
+ (vl_api_sw_interface_set_dpdk_hqos_tctbl_t * mp)
+{
+ vl_api_sw_interface_set_dpdk_hqos_tctbl_reply_t *rmp;
+ int rv = 0;
+
+ dpdk_main_t *dm = &dpdk_main;
+ vlib_thread_main_t *tm = vlib_get_thread_main ();
+ dpdk_device_t *xd;
+
+ u32 sw_if_index = ntohl (mp->sw_if_index);
+ u32 entry = ntohl (mp->entry);
+ u32 tc = ntohl (mp->tc);
+ u32 queue = ntohl (mp->queue);
+ u32 val, i;
+
+ vnet_hw_interface_t *hw;
+
+ VALIDATE_SW_IF_INDEX (mp);
+
+ /* hw_if & dpdk device */
+ hw = vnet_get_sup_hw_interface (dm->vnet_main, sw_if_index);
+
+ xd = vec_elt_at_index (dm->devices, hw->dev_instance);
+
+ if (tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE)
+ {
+ clib_warning ("invalid traffic class !!");
+ rv = VNET_API_ERROR_INVALID_VALUE;
+ goto done;
+ }
+ if (queue >= RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS)
+ {
+ clib_warning ("invalid queue !!");
+ rv = VNET_API_ERROR_INVALID_VALUE;
+ goto done;
+ }
+
+ /* Detect the set of worker threads */
+ uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
+
+ if (p == 0)
+ {
+ clib_warning ("worker thread registration AWOL !!");
+ rv = VNET_API_ERROR_INVALID_VALUE_2;
+ goto done;
+ }
+
+ vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0];
+ int worker_thread_first = tr->first_index;
+ int worker_thread_count = tr->count;
+
+ val = tc * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + queue;
+ for (i = 0; i < worker_thread_count; i++)
+ xd->hqos_wt[worker_thread_first + i].hqos_tc_table[entry] = val;
+
+ BAD_SW_IF_INDEX_LABEL;
+done:
+
+ REPLY_MACRO (VL_API_SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY);
+}
+
+static void *vl_api_sw_interface_set_dpdk_hqos_tctbl_t_print
+ (vl_api_sw_interface_set_dpdk_hqos_tctbl_t * mp, void *handle)
+{
+ u8 *s;
+
+ s = format (0, "SCRIPT: sw_interface_set_dpdk_hqos_tctbl ");
+
+ s = format (s, "sw_if_index %u ", ntohl (mp->sw_if_index));
+
+ s = format (s, "entry %u tc %u queue %u",
+ ntohl (mp->entry), ntohl (mp->tc), ntohl (mp->queue));
+
+ FINISH;
+}
+
+#define foreach_dpdk_plugin_api_msg \
+_(SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe) \
+_(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport) \
+_(SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl)
+
+/* Set up the API message handling tables */
+static clib_error_t *
+dpdk_plugin_api_hookup (vlib_main_t * vm)
+{
+ dpdk_main_t *dm __attribute__ ((unused)) = &dpdk_main;
+#define _(N,n) \
+ vl_msg_api_set_handlers((VL_API_##N + dm->msg_id_base), \
+ #n, \
+ vl_api_##n##_t_handler, \
+ vl_noop_handler, \
+ vl_api_##n##_t_endian, \
+ vl_api_##n##_t_print, \
+ sizeof(vl_api_##n##_t), 1);
+ foreach_dpdk_plugin_api_msg;
+#undef _
+ return 0;
+}
+
+#define vl_msg_name_crc_list
+#include <dpdk/api/dpdk_all_api_h.h>
+#undef vl_msg_name_crc_list
+
+static void
+setup_message_id_table (dpdk_main_t * dm, api_main_t * am)
+{
+#define _(id,n,crc) \
+ vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + dm->msg_id_base);
+ foreach_vl_msg_name_crc_dpdk;
+#undef _
+}
+
+// TODO
+/*
+static void plugin_custom_dump_configure (dpdk_main_t * dm)
+{
+#define _(n,f) dm->api_main->msg_print_handlers \
+ [VL_API_##n + dm->msg_id_base] \
+ = (void *) vl_api_##f##_t_print;
+ foreach_dpdk_plugin_api_msg;
+#undef _
+}
+*/
/* force linker to link functions used by vlib and declared weak */
void *vlib_weakly_linked_functions[] = {
&rte_pktmbuf_init,
@@ -1753,10 +2010,26 @@ dpdk_init (vlib_main_t * vm)
STATIC_ASSERT (offsetof (frame_queue_trace_t, cacheline0) == 0,
"Cache line marker must be 1st element in frame_queue_trace_t");
+ u8 *name;
+ name = format (0, "dpdk_%08x%c", api_version, 0);
+
+ /* Ask for a correctly-sized block of API message decode slots */
+ dm->msg_id_base = vl_msg_api_get_msg_ids
+ ((char *) name, VL_MSG_FIRST_AVAILABLE);
+ vec_free (name);
+
dm->vlib_main = vm;
dm->vnet_main = vnet_get_main ();
dm->conf = &dpdk_config_main;
+ error = dpdk_plugin_api_hookup (vm);
+
+ /* Add our API messages to the global name_crc hash table */
+ setup_message_id_table (dm, &api_main);
+
+// TODO
+// plugin_custom_dump_configure (dm);
+
ei = vlib_get_node_by_name (vm, (u8 *) "ethernet-input");
if (ei == 0)
return clib_error_return (0, "ethernet-input node AWOL");
diff --git a/src/vnet/devices/dpdk/ipsec/cli.c b/src/plugins/dpdk/ipsec/cli.c
index f9d3a5d082e..40cee39bd68 100644
--- a/src/vnet/devices/dpdk/ipsec/cli.c
+++ b/src/plugins/dpdk/ipsec/cli.c
@@ -14,8 +14,8 @@
*/
#include <vnet/vnet.h>
-#include <vnet/devices/dpdk/dpdk.h>
-#include <vnet/devices/dpdk/ipsec/ipsec.h>
+#include <dpdk/device/dpdk.h>
+#include <dpdk/ipsec/ipsec.h>
static void
dpdk_ipsec_show_mapping (vlib_main_t * vm, u16 detail_display)
diff --git a/src/vnet/devices/dpdk/ipsec/crypto_node.c b/src/plugins/dpdk/ipsec/crypto_node.c
index e8fef23553a..dc3452b286e 100644
--- a/src/vnet/devices/dpdk/ipsec/crypto_node.c
+++ b/src/plugins/dpdk/ipsec/crypto_node.c
@@ -22,9 +22,9 @@
#include <vnet/ethernet/ethernet.h>
#include <vnet/ipsec/ipsec.h>
-#include <vnet/devices/dpdk/dpdk.h>
-#include <vnet/devices/dpdk/dpdk_priv.h>
-#include <vnet/devices/dpdk/ipsec/ipsec.h>
+#include <dpdk/device/dpdk.h>
+#include <dpdk/device/dpdk_priv.h>
+#include <dpdk/ipsec/ipsec.h>
#define foreach_dpdk_crypto_input_next \
_(DROP, "error-drop") \
diff --git a/src/vnet/devices/dpdk/ipsec/dir.dox b/src/plugins/dpdk/ipsec/dir.dox
index ffebfc4d62e..ffebfc4d62e 100644
--- a/src/vnet/devices/dpdk/ipsec/dir.dox
+++ b/src/plugins/dpdk/ipsec/dir.dox
diff --git a/src/vnet/devices/dpdk/ipsec/dpdk_crypto_ipsec_doc.md b/src/plugins/dpdk/ipsec/dpdk_crypto_ipsec_doc.md
index fed2fe0eee8..fed2fe0eee8 100644
--- a/src/vnet/devices/dpdk/ipsec/dpdk_crypto_ipsec_doc.md
+++ b/src/plugins/dpdk/ipsec/dpdk_crypto_ipsec_doc.md
diff --git a/src/vnet/devices/dpdk/ipsec/esp.h b/src/plugins/dpdk/ipsec/esp.h
index d0b276189c8..320295b19e6 100644
--- a/src/vnet/devices/dpdk/ipsec/esp.h
+++ b/src/plugins/dpdk/ipsec/esp.h
@@ -15,7 +15,7 @@
#ifndef __DPDK_ESP_H__
#define __DPDK_ESP_H__
-#include <vnet/devices/dpdk/ipsec/ipsec.h>
+#include <dpdk/ipsec/ipsec.h>
#include <vnet/ipsec/ipsec.h>
#include <vnet/ipsec/esp.h>
diff --git a/src/vnet/devices/dpdk/ipsec/esp_decrypt.c b/src/plugins/dpdk/ipsec/esp_decrypt.c
index 760076093cb..286e03f85da 100644
--- a/src/vnet/devices/dpdk/ipsec/esp_decrypt.c
+++ b/src/plugins/dpdk/ipsec/esp_decrypt.c
@@ -20,10 +20,10 @@
#include <vnet/ip/ip.h>
#include <vnet/ipsec/ipsec.h>
-#include <vnet/devices/dpdk/ipsec/ipsec.h>
-#include <vnet/devices/dpdk/ipsec/esp.h>
-#include <vnet/devices/dpdk/dpdk.h>
-#include <vnet/devices/dpdk/dpdk_priv.h>
+#include <dpdk/ipsec/ipsec.h>
+#include <dpdk/ipsec/esp.h>
+#include <dpdk/device/dpdk.h>
+#include <dpdk/device/dpdk_priv.h>
#define foreach_esp_decrypt_next \
_(DROP, "error-drop") \
diff --git a/src/vnet/devices/dpdk/ipsec/esp_encrypt.c b/src/plugins/dpdk/ipsec/esp_encrypt.c
index 6eb1afc9501..5b03de73bf2 100644
--- a/src/vnet/devices/dpdk/ipsec/esp_encrypt.c
+++ b/src/plugins/dpdk/ipsec/esp_encrypt.c
@@ -20,10 +20,10 @@
#include <vnet/ip/ip.h>
#include <vnet/ipsec/ipsec.h>
-#include <vnet/devices/dpdk/ipsec/ipsec.h>
-#include <vnet/devices/dpdk/ipsec/esp.h>
-#include <vnet/devices/dpdk/dpdk.h>
-#include <vnet/devices/dpdk/dpdk_priv.h>
+#include <dpdk/ipsec/ipsec.h>
+#include <dpdk/ipsec/esp.h>
+#include <dpdk/device/dpdk.h>
+#include <dpdk/device/dpdk_priv.h>
#define foreach_esp_encrypt_next \
_(DROP, "error-drop") \
diff --git a/src/vnet/devices/dpdk/ipsec/ipsec.c b/src/plugins/dpdk/ipsec/ipsec.c
index 05c17c995d8..16bec20ad16 100644
--- a/src/vnet/devices/dpdk/ipsec/ipsec.c
+++ b/src/plugins/dpdk/ipsec/ipsec.c
@@ -18,9 +18,9 @@
#include <vnet/ipsec/ipsec.h>
#include <vlib/node_funcs.h>
-#include <vnet/devices/dpdk/dpdk.h>
-#include <vnet/devices/dpdk/ipsec/ipsec.h>
-#include <vnet/devices/dpdk/ipsec/esp.h>
+#include <dpdk/device/dpdk.h>
+#include <dpdk/ipsec/ipsec.h>
+#include <dpdk/ipsec/esp.h>
#define DPDK_CRYPTO_NB_SESS_OBJS 20000
#define DPDK_CRYPTO_CACHE_SIZE 512
diff --git a/src/vnet/devices/dpdk/ipsec/ipsec.h b/src/plugins/dpdk/ipsec/ipsec.h
index 3465b3618ad..3465b3618ad 100644
--- a/src/vnet/devices/dpdk/ipsec/ipsec.h
+++ b/src/plugins/dpdk/ipsec/ipsec.h
diff --git a/src/vnet/devices/dpdk/main.c b/src/plugins/dpdk/main.c
index 9ea3aa04b09..8073a50ae4e 100644
--- a/src/vnet/devices/dpdk/main.c
+++ b/src/plugins/dpdk/main.c
@@ -14,8 +14,9 @@
*/
#include <vnet/vnet.h>
-#include <vnet/devices/dpdk/dpdk.h>
-
+#include <vnet/plugin/plugin.h>
+#include <dpdk/device/dpdk.h>
+#include <vpp/app/version.h>
/*
* Called by the dpdk driver's rte_delay_us() function.
@@ -70,8 +71,12 @@ rte_delay_us_override_cb (unsigned us)
static clib_error_t * dpdk_main_init (vlib_main_t * vm)
{
+ dpdk_main_t * dm = &dpdk_main;
clib_error_t * error = 0;
+ dm->vlib_main = vm;
+ dm->vnet_main = vnet_get_main ();
+
if ((error = vlib_call_init_function (vm, dpdk_init)))
return error;
@@ -83,3 +88,8 @@ static clib_error_t * dpdk_main_init (vlib_main_t * vm)
VLIB_INIT_FUNCTION (dpdk_main_init);
+/* *INDENT-OFF* */
+VLIB_PLUGIN_REGISTER () = {
+ .version = VPP_BUILD_VER,
+};
+/* *INDENT-ON* */
diff --git a/src/vnet/devices/dpdk/thread.c b/src/plugins/dpdk/thread.c
index 475dd142157..3a3fcc6cea6 100644
--- a/src/vnet/devices/dpdk/thread.c
+++ b/src/plugins/dpdk/thread.c
@@ -42,8 +42,8 @@
#include <vlib/vlib.h>
#include <vnet/vnet.h>
-#include <vnet/devices/dpdk/dpdk.h>
-#include <vnet/devices/dpdk/dpdk_priv.h>
+#include <dpdk/device/dpdk.h>
+#include <dpdk/device/dpdk_priv.h>
static clib_error_t *
dpdk_launch_thread (void *fp, vlib_worker_thread_t * w, unsigned lcore_id)
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 999f986922c..14e78817b61 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -3970,13 +3970,6 @@ _(feature_enable_disable_reply) \
_(sw_interface_tag_add_del_reply) \
_(sw_interface_set_mtu_reply)
-#if DPDK > 0
-#define foreach_standard_dpdk_reply_retval_handler \
-_(sw_interface_set_dpdk_hqos_pipe_reply) \
-_(sw_interface_set_dpdk_hqos_subport_reply) \
-_(sw_interface_set_dpdk_hqos_tctbl_reply)
-#endif
-
#define _(n) \
static void vl_api_##n##_t_handler \
(vl_api_##n##_t * mp) \
@@ -4008,39 +4001,6 @@ foreach_standard_reply_retval_handler;
foreach_standard_reply_retval_handler;
#undef _
-#if DPDK > 0
-#define _(n) \
- static void vl_api_##n##_t_handler \
- (vl_api_##n##_t * mp) \
- { \
- vat_main_t * vam = &vat_main; \
- i32 retval = ntohl(mp->retval); \
- if (vam->async_mode) { \
- vam->async_errors += (retval < 0); \
- } else { \
- vam->retval = retval; \
- vam->result_ready = 1; \
- } \
- }
-foreach_standard_dpdk_reply_retval_handler;
-#undef _
-
-#define _(n) \
- static void vl_api_##n##_t_handler_json \
- (vl_api_##n##_t * mp) \
- { \
- vat_main_t * vam = &vat_main; \
- vat_json_node_t node; \
- vat_json_init_object(&node); \
- vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
- vat_json_print(vam->ofp, &node); \
- vam->retval = ntohl(mp->retval); \
- vam->result_ready = 1; \
- }
-foreach_standard_dpdk_reply_retval_handler;
-#undef _
-#endif
-
/*
* Table of message reply handlers, must include boilerplate handlers
* we just generated
@@ -4272,16 +4232,6 @@ _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
_(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
_(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
-#if DPDK > 0
-#define foreach_vpe_dpdk_api_reply_msg \
-_(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
- sw_interface_set_dpdk_hqos_pipe_reply) \
-_(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
- sw_interface_set_dpdk_hqos_subport_reply) \
-_(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
- sw_interface_set_dpdk_hqos_tctbl_reply)
-#endif
-
typedef struct
{
u8 *name;
@@ -5081,226 +5031,6 @@ api_sw_interface_clear_stats (vat_main_t * vam)
return ret;
}
-#if DPDK >0
-static int
-api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- u32 subport;
- u8 subport_set = 0;
- u32 pipe;
- u8 pipe_set = 0;
- u32 profile;
- u8 profile_set = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %u", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "subport %u", &subport))
- subport_set = 1;
- else
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "pipe %u", &pipe))
- pipe_set = 1;
- else if (unformat (i, "profile %u", &profile))
- profile_set = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- if (subport_set == 0)
- {
- errmsg ("missing subport ");
- return -99;
- }
-
- if (pipe_set == 0)
- {
- errmsg ("missing pipe");
- return -99;
- }
-
- if (profile_set == 0)
- {
- errmsg ("missing profile");
- return -99;
- }
-
- M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->subport = ntohl (subport);
- mp->pipe = ntohl (pipe);
- mp->profile = ntohl (profile);
-
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- u32 subport;
- u8 subport_set = 0;
- u32 tb_rate = 1250000000; /* 10GbE */
- u32 tb_size = 1000000;
- u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
- u32 tc_period = 10;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %u", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "subport %u", &subport))
- subport_set = 1;
- else
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "rate %u", &tb_rate))
- {
- u32 tc_id;
-
- for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
- tc_id++)
- tc_rate[tc_id] = tb_rate;
- }
- else if (unformat (i, "bktsize %u", &tb_size))
- ;
- else if (unformat (i, "tc0 %u", &tc_rate[0]))
- ;
- else if (unformat (i, "tc1 %u", &tc_rate[1]))
- ;
- else if (unformat (i, "tc2 %u", &tc_rate[2]))
- ;
- else if (unformat (i, "tc3 %u", &tc_rate[3]))
- ;
- else if (unformat (i, "period %u", &tc_period))
- ;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- if (subport_set == 0)
- {
- errmsg ("missing subport ");
- return -99;
- }
-
- M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->subport = ntohl (subport);
- mp->tb_rate = ntohl (tb_rate);
- mp->tb_size = ntohl (tb_size);
- mp->tc_rate[0] = ntohl (tc_rate[0]);
- mp->tc_rate[1] = ntohl (tc_rate[1]);
- mp->tc_rate[2] = ntohl (tc_rate[2]);
- mp->tc_rate[3] = ntohl (tc_rate[3]);
- mp->tc_period = ntohl (tc_period);
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- u8 entry_set = 0;
- u8 tc_set = 0;
- u8 queue_set = 0;
- u32 entry, tc, queue;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %u", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "entry %d", &entry))
- entry_set = 1;
- else if (unformat (i, "tc %d", &tc))
- tc_set = 1;
- else if (unformat (i, "queue %d", &queue))
- queue_set = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
-
- if (entry_set == 0)
- {
- errmsg ("missing entry ");
- return -99;
- }
-
- if (tc_set == 0)
- {
- errmsg ("missing traffic class ");
- return -99;
- }
-
- if (queue_set == 0)
- {
- errmsg ("missing queue ");
- return -99;
- }
-
- M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->entry = ntohl (entry);
- mp->tc = ntohl (tc);
- mp->queue = ntohl (queue);
-
- S (mp);
- W (ret);
- return ret;
-}
-#endif
-
static int
api_sw_interface_add_del_address (vat_main_t * vam)
{
@@ -18656,18 +18386,6 @@ _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
_(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
_(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
-#if DPDK > 0
-#define foreach_vpe_dpdk_api_msg \
-_(sw_interface_set_dpdk_hqos_pipe, \
- "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
- "profile <profile-id>\n") \
-_(sw_interface_set_dpdk_hqos_subport, \
- "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
- "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
-_(sw_interface_set_dpdk_hqos_tctbl, \
- "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n")
-#endif
-
/* List of command functions, CLI names map directly to functions */
#define foreach_cli_function \
_(comment, "usage: comment <ignore-rest-of-line>") \
@@ -18705,22 +18423,6 @@ _(unset, "usage: unset <variable-name>")
foreach_vpe_api_reply_msg;
#undef _
-#if DPDK > 0
-#define _(N,n) \
- static void vl_api_##n##_t_handler_uni \
- (vl_api_##n##_t * mp) \
- { \
- vat_main_t * vam = &vat_main; \
- if (vam->json_output) { \
- vl_api_##n##_t_handler_json(mp); \
- } else { \
- vl_api_##n##_t_handler(mp); \
- } \
- }
-foreach_vpe_dpdk_api_reply_msg;
-#undef _
-#endif
-
void
vat_api_hookup (vat_main_t * vam)
{
@@ -18734,18 +18436,6 @@ vat_api_hookup (vat_main_t * vam)
foreach_vpe_api_reply_msg;
#undef _
-#if DPDK > 0
-#define _(N,n) \
- vl_msg_api_set_handlers(VL_API_##N, #n, \
- vl_api_##n##_t_handler_uni, \
- vl_noop_handler, \
- vl_api_##n##_t_endian, \
- vl_api_##n##_t_print, \
- sizeof(vl_api_##n##_t), 1);
- foreach_vpe_dpdk_api_reply_msg;
-#undef _
-#endif
-
#if (VPP_API_TEST_BUILTIN==0)
vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
#endif
@@ -18760,21 +18450,11 @@ vat_api_hookup (vat_main_t * vam)
#define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
foreach_vpe_api_msg;
#undef _
-#if DPDK >0
-#define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
- foreach_vpe_dpdk_api_msg;
-#undef _
-#endif
/* Help strings */
#define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
foreach_vpe_api_msg;
#undef _
-#if DPDK >0
-#define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
- foreach_vpe_dpdk_api_msg;
-#undef _
-#endif
/* CLI functions */
#define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
diff --git a/src/vnet.am b/src/vnet.am
index 923f61d8a0b..84930f05b0a 100644
--- a/src/vnet.am
+++ b/src/vnet.am
@@ -23,8 +23,7 @@ libvnet_la_DEPENDENCIES = \
libvlibmemory.la \
libvlibmemoryclient.la
-libvnet_la_LIBADD = $(libvnet_la_DEPENDENCIES) -lm -lpthread -ldl -lrt $(DPDK_LD_ADD)
-libvnet_la_LDFLAGS = $(DPDK_LD_FLAGS)
+libvnet_la_LIBADD = $(libvnet_la_DEPENDENCIES) -lm -lpthread -ldl -lrt
if WITH_LIBSSL
libvnet_la_LIBADD += -lcrypto
@@ -396,15 +395,6 @@ libvnet_la_SOURCES += \
vnet/ipsec/ipsec_api.c
API_FILES += vnet/ipsec/ipsec.api
-
-if WITH_DPDK
-libvnet_la_SOURCES += \
- vnet/devices/dpdk/ipsec/esp_encrypt.c \
- vnet/devices/dpdk/ipsec/esp_decrypt.c \
- vnet/devices/dpdk/ipsec/crypto_node.c \
- vnet/devices/dpdk/ipsec/cli.c \
- vnet/devices/dpdk/ipsec/ipsec.c
-endif
endif
libvnet_la_SOURCES += \
@@ -416,11 +406,6 @@ nobase_include_HEADERS += \
vnet/ipsec/ikev2.h \
vnet/ipsec/ikev2_priv.h \
vnet/ipsec/ipsec.api.h
-if WITH_DPDK
-nobase_include_HEADERS += \
- vnet/devices/dpdk/ipsec/ipsec.h \
- vnet/devices/dpdk/ipsec/esp.h
-endif
########################################
# Layer 3 protocol: osi
@@ -803,29 +788,7 @@ nobase_include_HEADERS += \
vnet/pg/pg.h \
vnet/pg/edit.h
-########################################
-# DPDK
-########################################
-if WITH_DPDK
-libvnet_la_SOURCES += \
- vnet/devices/dpdk/buffer.c \
- vnet/devices/dpdk/dpdk_priv.h \
- vnet/devices/dpdk/device.c \
- vnet/devices/dpdk/format.c \
- vnet/devices/dpdk/init.c \
- vnet/devices/dpdk/main.c \
- vnet/devices/dpdk/node.c \
- vnet/devices/dpdk/thread.c \
- vnet/devices/dpdk/hqos.c \
- vnet/devices/dpdk/cli.c \
- vnet/devices/dpdk/dpdk_api.c
-
-nobase_include_HEADERS += \
- vnet/devices/dpdk/dpdk.h \
- vnet/devices/dpdk/dpdk.api.h
-
-API_FILES += vnet/devices/dpdk/dpdk.api
-else
+if !WITH_DPDK
libvnet_la_SOURCES += \
vnet/devices/nic/ixge.c \
vnet/devices/nic/ixge.h \
diff --git a/src/vnet/devices/dpdk/dpdk_api.c b/src/vnet/devices/dpdk/dpdk_api.c
deleted file mode 100644
index 8faf5c2cbc4..00000000000
--- a/src/vnet/devices/dpdk/dpdk_api.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- *------------------------------------------------------------------
- * dpdk_api.c - dpdk interface api
- *
- * Copyright (c) 2016 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *------------------------------------------------------------------
- */
-
-#include <vnet/vnet.h>
-#include <vlibmemory/api.h>
-
-#if DPDK > 0
-#include <vnet/devices/dpdk/dpdk.h>
-#endif
-
-#include <vnet/vnet_msg_enum.h>
-
-#define vl_typedefs /* define message structures */
-#include <vnet/vnet_all_api_h.h>
-#undef vl_typedefs
-
-#define vl_endianfun /* define message structures */
-#include <vnet/vnet_all_api_h.h>
-#undef vl_endianfun
-
-/* instantiate all the print functions we know about */
-#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
-#define vl_printfun
-#include <vnet/vnet_all_api_h.h>
-#undef vl_printfun
-
-#include <vlibapi/api_helper_macros.h>
-
-#define foreach_vpe_api_msg \
-_(SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe) \
-_(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport) \
-_(SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl)
-
-static void
- vl_api_sw_interface_set_dpdk_hqos_pipe_t_handler
- (vl_api_sw_interface_set_dpdk_hqos_pipe_t * mp)
-{
- vl_api_sw_interface_set_dpdk_hqos_pipe_reply_t *rmp;
- int rv = 0;
-
-#if DPDK > 0
- dpdk_main_t *dm = &dpdk_main;
- dpdk_device_t *xd;
-
- u32 sw_if_index = ntohl (mp->sw_if_index);
- u32 subport = ntohl (mp->subport);
- u32 pipe = ntohl (mp->pipe);
- u32 profile = ntohl (mp->profile);
- vnet_hw_interface_t *hw;
-
- VALIDATE_SW_IF_INDEX (mp);
-
- /* hw_if & dpdk device */
- hw = vnet_get_sup_hw_interface (dm->vnet_main, sw_if_index);
-
- xd = vec_elt_at_index (dm->devices, hw->dev_instance);
-
- rv = rte_sched_pipe_config (xd->hqos_ht->hqos, subport, pipe, profile);
-
- BAD_SW_IF_INDEX_LABEL;
-#else
- clib_warning ("setting HQoS pipe parameters without DPDK not implemented");
- rv = VNET_API_ERROR_UNIMPLEMENTED;
-#endif /* DPDK */
-
- REPLY_MACRO (VL_API_SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY);
-}
-
-static void
- vl_api_sw_interface_set_dpdk_hqos_subport_t_handler
- (vl_api_sw_interface_set_dpdk_hqos_subport_t * mp)
-{
- vl_api_sw_interface_set_dpdk_hqos_subport_reply_t *rmp;
- int rv = 0;
-
-#if DPDK > 0
- dpdk_main_t *dm = &dpdk_main;
- dpdk_device_t *xd;
- struct rte_sched_subport_params p;
-
- u32 sw_if_index = ntohl (mp->sw_if_index);
- u32 subport = ntohl (mp->subport);
- p.tb_rate = ntohl (mp->tb_rate);
- p.tb_size = ntohl (mp->tb_size);
- p.tc_rate[0] = ntohl (mp->tc_rate[0]);
- p.tc_rate[1] = ntohl (mp->tc_rate[1]);
- p.tc_rate[2] = ntohl (mp->tc_rate[2]);
- p.tc_rate[3] = ntohl (mp->tc_rate[3]);
- p.tc_period = ntohl (mp->tc_period);
-
- vnet_hw_interface_t *hw;
-
- VALIDATE_SW_IF_INDEX (mp);
-
- /* hw_if & dpdk device */
- hw = vnet_get_sup_hw_interface (dm->vnet_main, sw_if_index);
-
- xd = vec_elt_at_index (dm->devices, hw->dev_instance);
-
- rv = rte_sched_subport_config (xd->hqos_ht->hqos, subport, &p);
-
- BAD_SW_IF_INDEX_LABEL;
-#else
- clib_warning
- ("setting HQoS subport parameters without DPDK not implemented");
- rv = VNET_API_ERROR_UNIMPLEMENTED;
-#endif /* DPDK */
-
- REPLY_MACRO (VL_API_SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY);
-}
-
-static void
- vl_api_sw_interface_set_dpdk_hqos_tctbl_t_handler
- (vl_api_sw_interface_set_dpdk_hqos_tctbl_t * mp)
-{
- vl_api_sw_interface_set_dpdk_hqos_tctbl_reply_t *rmp;
- int rv = 0;
-
-#if DPDK > 0
- dpdk_main_t *dm = &dpdk_main;
- vlib_thread_main_t *tm = vlib_get_thread_main ();
- dpdk_device_t *xd;
-
- u32 sw_if_index = ntohl (mp->sw_if_index);
- u32 entry = ntohl (mp->entry);
- u32 tc = ntohl (mp->tc);
- u32 queue = ntohl (mp->queue);
- u32 val, i;
-
- vnet_hw_interface_t *hw;
-
- VALIDATE_SW_IF_INDEX (mp);
-
- /* hw_if & dpdk device */
- hw = vnet_get_sup_hw_interface (dm->vnet_main, sw_if_index);
-
- xd = vec_elt_at_index (dm->devices, hw->dev_instance);
-
- if (tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE)
- {
- clib_warning ("invalid traffic class !!");
- rv = VNET_API_ERROR_INVALID_VALUE;
- goto done;
- }
- if (queue >= RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS)
- {
- clib_warning ("invalid queue !!");
- rv = VNET_API_ERROR_INVALID_VALUE;
- goto done;
- }
-
- /* Detect the set of worker threads */
- uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
-
- if (p == 0)
- {
- clib_warning ("worker thread registration AWOL !!");
- rv = VNET_API_ERROR_INVALID_VALUE_2;
- goto done;
- }
-
- vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0];
- int worker_thread_first = tr->first_index;
- int worker_thread_count = tr->count;
-
- val = tc * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + queue;
- for (i = 0; i < worker_thread_count; i++)
- xd->hqos_wt[worker_thread_first + i].hqos_tc_table[entry] = val;
-
- BAD_SW_IF_INDEX_LABEL;
-done:
-#else
- clib_warning ("setting HQoS DSCP table entry without DPDK not implemented");
- rv = VNET_API_ERROR_UNIMPLEMENTED;
-#endif /* DPDK */
-
- REPLY_MACRO (VL_API_SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY);
-}
-
-/*
- * dpdk_api_hookup
- * Add vpe's API message handlers to the table.
- * vlib has alread mapped shared memory and
- * added the client registration handlers.
- * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
- */
-#define vl_msg_name_crc_list
-#include <vnet/vnet_all_api_h.h>
-#undef vl_msg_name_crc_list
-
-static void
-setup_message_id_table (api_main_t * am)
-{
-#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
- foreach_vl_msg_name_crc_dpdk;
-#undef _
-}
-
-static clib_error_t *
-dpdk_api_hookup (vlib_main_t * vm)
-{
- api_main_t *am = &api_main;
-
-#define _(N,n) \
- vl_msg_api_set_handlers(VL_API_##N, #n, \
- vl_api_##n##_t_handler, \
- vl_noop_handler, \
- vl_api_##n##_t_endian, \
- vl_api_##n##_t_print, \
- sizeof(vl_api_##n##_t), 1);
- foreach_vpe_api_msg;
-#undef _
-
- /*
- * Set up the (msg_name, crc, message-id) table
- */
- setup_message_id_table (am);
-
- return 0;
-}
-
-VLIB_API_INIT_FUNCTION (dpdk_api_hookup);
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/src/vnet/devices/virtio/vhost-user.h b/src/vnet/devices/virtio/vhost-user.h
index 3083b614016..dd23a909bfa 100644
--- a/src/vnet/devices/virtio/vhost-user.h
+++ b/src/vnet/devices/virtio/vhost-user.h
@@ -328,17 +328,6 @@ typedef struct
int vhost_user_dump_ifs (vnet_main_t * vnm, vlib_main_t * vm,
vhost_user_intf_details_t ** out_vuids);
-// CLI commands to be used from dpdk
-clib_error_t *vhost_user_connect_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd);
-clib_error_t *vhost_user_delete_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd);
-clib_error_t *show_vhost_user_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd);
-
#endif
/*
diff --git a/src/vnet/ipsec/ipsec_api.c b/src/vnet/ipsec/ipsec_api.c
index 49b475cf3b6..e37bcceef71 100644
--- a/src/vnet/ipsec/ipsec_api.c
+++ b/src/vnet/ipsec/ipsec_api.c
@@ -79,11 +79,7 @@ static void vl_api_ipsec_spd_add_del_t_handler
vl_api_ipsec_spd_add_del_reply_t *rmp;
int rv;
-#if DPDK > 0
rv = ipsec_add_del_spd (vm, ntohl (mp->spd_id), mp->is_add);
-#else
- rv = VNET_API_ERROR_UNIMPLEMENTED;
-#endif
REPLY_MACRO (VL_API_IPSEC_SPD_ADD_DEL_REPLY);
#endif
diff --git a/src/vnet/pg/input.c b/src/vnet/pg/input.c
index e15faeb8564..4a65b024f6c 100644
--- a/src/vnet/pg/input.c
+++ b/src/vnet/pg/input.c
@@ -1212,10 +1212,10 @@ pg_stream_fill_helper (pg_main_t * pg,
/*
* Historically, the pg maintained its own free lists and
- * device drivers tx paths would return pkts. With the DPDK,
- * that doesn't happen.
+ * device drivers tx paths would return pkts.
*/
- if (DPDK == 0 && !(s->flags & PG_STREAM_FLAGS_DISABLE_BUFFER_RECYCLE))
+ if (vm->buffer_main->extern_buffer_mgmt == 0 &&
+ !(s->flags & PG_STREAM_FLAGS_DISABLE_BUFFER_RECYCLE))
f->buffer_init_function = pg_buffer_init;
f->buffer_init_function_opaque =
(s - pg->streams) | ((bi - s->buffer_indices) << 24);
@@ -1238,7 +1238,7 @@ pg_stream_fill_helper (pg_main_t * pg,
n_alloc = n_allocated;
/* Reinitialize buffers */
- if (DPDK == 0 || CLIB_DEBUG > 0
+ if (vm->buffer_main->extern_buffer_mgmt == 0 || CLIB_DEBUG > 0
|| (s->flags & PG_STREAM_FLAGS_DISABLE_BUFFER_RECYCLE))
init_buffers_inline
(vm, s,
@@ -1246,7 +1246,8 @@ pg_stream_fill_helper (pg_main_t * pg,
n_alloc, (bi - s->buffer_indices) * s->buffer_bytes /* data offset */ ,
s->buffer_bytes,
/* set_data */
- DPDK == 1 || (s->flags & PG_STREAM_FLAGS_DISABLE_BUFFER_RECYCLE) != 0);
+ vm->buffer_main->extern_buffer_mgmt != 0
+ || (s->flags & PG_STREAM_FLAGS_DISABLE_BUFFER_RECYCLE) != 0);
if (next_buffers)
pg_set_next_buffer_pointers (pg, s, buffers, next_buffers, n_alloc);
diff --git a/src/vnet/pg/stream.c b/src/vnet/pg/stream.c
index c46875e11ad..560c4b07d6f 100644
--- a/src/vnet/pg/stream.c
+++ b/src/vnet/pg/stream.c
@@ -442,9 +442,8 @@ pg_stream_add (pg_main_t * pg, pg_stream_t * s_init)
pg_buffer_index_t *bi;
int n;
-#if DPDK > 0
- s->buffer_bytes = VLIB_BUFFER_DATA_SIZE;
-#endif
+ if (vm->buffer_main->extern_buffer_mgmt)
+ s->buffer_bytes = VLIB_BUFFER_DATA_SIZE;
if (!s->buffer_bytes)
s->buffer_bytes = s->max_packet_bytes;
diff --git a/src/vnet/replication.c b/src/vnet/replication.c
index 02755195ac9..86d922b5e7a 100644
--- a/src/vnet/replication.c
+++ b/src/vnet/replication.c
@@ -214,9 +214,9 @@ replication_recycle_callback (vlib_main_t * vm, vlib_buffer_free_list_t * fl)
b0->flags |= VLIB_BUFFER_IS_RECYCLED;
#if (CLIB_DEBUG > 0)
-#if DPDK == 0
- vlib_buffer_set_known_state (vm, bi0, VLIB_BUFFER_KNOWN_ALLOCATED);
-#endif
+ if (vm->buffer_main->extern_buffer_mgmt == 0)
+ vlib_buffer_set_known_state (vm, bi0,
+ VLIB_BUFFER_KNOWN_ALLOCATED);
#endif
/* If buffer is traced, mark frame as traced */
diff --git a/src/vnet/vnet_all_api_h.h b/src/vnet/vnet_all_api_h.h
index c4075db65c3..9d3abae55c3 100644
--- a/src/vnet/vnet_all_api_h.h
+++ b/src/vnet/vnet_all_api_h.h
@@ -30,9 +30,6 @@
#endif /* included_from_layer_3 */
#include <vnet/devices/af_packet/af_packet.api.h>
-#if DPDK > 0
-#include <vnet/devices/dpdk/dpdk.api.h>
-#endif
#include <vnet/devices/netmap/netmap.api.h>
#include <vnet/devices/virtio/vhost_user.api.h>
#include <vnet/gre/gre.api.h>
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index 4cc6aa731ec..3871601bcbb 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -237,58 +237,6 @@ static void *vl_api_sw_interface_set_l2_bridge_t_print
FINISH;
}
-#if DPDK > 0
-static void *vl_api_sw_interface_set_dpdk_hqos_pipe_t_print
- (vl_api_sw_interface_set_dpdk_hqos_pipe_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: sw_interface_set_dpdk_hqos_pipe ");
-
- s = format (s, "sw_if_index %u ", ntohl (mp->sw_if_index));
-
- s = format (s, "subport %u pipe %u profile %u ",
- ntohl (mp->subport), ntohl (mp->pipe), ntohl (mp->profile));
-
- FINISH;
-}
-
-static void *vl_api_sw_interface_set_dpdk_hqos_subport_t_print
- (vl_api_sw_interface_set_dpdk_hqos_subport_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: sw_interface_set_dpdk_hqos_subport ");
-
- s = format (s, "sw_if_index %u ", ntohl (mp->sw_if_index));
-
- s =
- format (s,
- "subport %u rate %u bkt_size %u tc0 %u tc1 %u tc2 %u tc3 %u period %u",
- ntohl (mp->subport), ntohl (mp->tb_rate), ntohl (mp->tb_size),
- ntohl (mp->tc_rate[0]), ntohl (mp->tc_rate[1]),
- ntohl (mp->tc_rate[2]), ntohl (mp->tc_rate[3]),
- ntohl (mp->tc_period));
-
- FINISH;
-}
-
-static void *vl_api_sw_interface_set_dpdk_hqos_tctbl_t_print
- (vl_api_sw_interface_set_dpdk_hqos_tctbl_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: sw_interface_set_dpdk_hqos_tctbl ");
-
- s = format (s, "sw_if_index %u ", ntohl (mp->sw_if_index));
-
- s = format (s, "entry %u tc %u queue %u",
- ntohl (mp->entry), ntohl (mp->tc), ntohl (mp->queue));
-
- FINISH;
-}
-#endif
-
static void *vl_api_bridge_domain_add_del_t_print
(vl_api_bridge_domain_add_del_t * mp, void *handle)
{
@@ -3036,18 +2984,6 @@ vl_msg_api_custom_dump_configure (api_main_t * am)
= (void *) vl_api_##f##_t_print;
foreach_custom_print_function;
#undef _
-
-#if DPDK > 0
- /*
- * manually add DPDK hqos print handlers
- */
- am->msg_print_handlers[VL_API_SW_INTERFACE_SET_DPDK_HQOS_PIPE] =
- (void *) vl_api_sw_interface_set_dpdk_hqos_pipe_t_print;
- am->msg_print_handlers[VL_API_SW_INTERFACE_SET_DPDK_HQOS_SUBPORT] =
- (void *) vl_api_sw_interface_set_dpdk_hqos_subport_t_print;
- am->msg_print_handlers[VL_API_SW_INTERFACE_SET_DPDK_HQOS_TCTBL] =
- (void *) vl_api_sw_interface_set_dpdk_hqos_tctbl_t_print;
-#endif
}
/*
diff --git a/src/vpp/api/gmon.c b/src/vpp/api/gmon.c
index b28608f0890..610f40eddbf 100644
--- a/src/vpp/api/gmon.c
+++ b/src/vpp/api/gmon.c
@@ -137,7 +137,8 @@ gmon_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
*gm->vector_rate_ptr = vector_rate;
now = vlib_time_now (vm);
dt = now - last_runtime;
- input_packets = vnet_get_aggregate_rx_packets ();
+ // TODO
+ //input_packets = vnet_get_aggregate_rx_packets ();
*gm->input_rate_ptr = (f64) (input_packets - last_input_packets) / dt;
last_runtime = now;
last_input_packets = input_packets;
diff --git a/src/vpp/api/vpe.api b/src/vpp/api/vpe.api
index 2d6e4f3716c..7f9c203807c 100644
--- a/src/vpp/api/vpe.api
+++ b/src/vpp/api/vpe.api
@@ -41,7 +41,6 @@
* SESSION APIs: .../vnet/session/{session.api session_api.c}
* MPLS APIs: see .../src/vnet/mpls/{mpls.api, mpls_api.c}
* SR APIs: see .../src/vnet/sr/{sr.api, sr_api.c}
- * DPDK APIs: see ... /src/vnet/devices/dpdk/{dpdk.api, dpdk_api.c}
* CLASSIFY APIs: see ... /src/vnet/classify/{classify.api, classify_api.c}
* FLOW APIs: see ... /src/vnet/flow/{flow.api, flow_api.c}
* DHCP APIs: see ... /src/vnet/dhcp/{dhcpk.api, dhcp_api.c}
diff --git a/src/vpp/app/l2t.c b/src/vpp/app/l2t.c
deleted file mode 100644
index e1eda155745..00000000000
--- a/src/vpp/app/l2t.c
+++ /dev/null
@@ -1,562 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <vnet/vnet.h>
-#include <vnet/ip/ip.h>
-#include <vnet/ethernet/ethernet.h>
-
-#if DPDK == 0
-#include <vnet/devices/pci/ixge.h>
-#else
-#include <vnet/devices/dpdk/dpdk.h>
-#endif
-
-#include <vppinfra/error.h>
-#include <vppinfra/hash.h>
-#include <app/l2t.h>
-
-l2t_main_t l2t_main;
-
-/* $$$$ unused?
- * get_interface_ethernet_address
- * paints the ethernet address for a given interface
- * into the supplied destination
- */
-void
-get_interface_ethernet_address (l2t_main_t * lm, u8 * dst, u32 sw_if_index)
-{
- ethernet_main_t *em = ethernet_get_main (lm->vlib_main);
- ethernet_interface_t *ei;
- vnet_hw_interface_t *hi;
-
- hi = vnet_get_sup_hw_interface (lm->vnet_main, sw_if_index);
- ei = pool_elt_at_index (em->interfaces, hi->hw_instance);
- clib_memcpy (dst, ei->address, sizeof (ei->address));
-}
-
-/* packet trace format function */
-u8 *
-format_l2t_trace (u8 * s, va_list * args)
-{
- CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
- CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- l2t_trace_t *t = va_arg (*args, l2t_trace_t *);
-
- if (t->is_user_to_network)
- s = format (s, "L2T: %U (client) -> %U (our) session %d",
- format_ip6_address, &t->client_address,
- format_ip6_address, &t->our_address, t->session_index);
- else
- s = format (s, "L2T: %U (our) -> %U (client) session %d)",
- format_ip6_address, &t->our_address,
- format_ip6_address, &t->client_address, t->session_index);
- return s;
-}
-
-u8 *
-format_l2t_session (u8 * s, va_list * args)
-{
- l2t_session_t *session = va_arg (*args, l2t_session_t *);
- l2t_main_t *lm = &l2t_main;
- u32 counter_index;
- vlib_counter_t v;
-
- s = format (s, "[%d] %U (our) %U (client) vlan-id %d rx_sw_if_index %d\n",
- session - lm->sessions,
- format_ip6_address, &session->our_address,
- format_ip6_address, &session->client_address,
- clib_net_to_host_u16 (session->vlan_id), session->sw_if_index);
-
- s = format (s, " local cookie %llx remote cookie %llx\n",
- clib_net_to_host_u64 (session->local_cookie),
- clib_net_to_host_u64 (session->remote_cookie));
-
- if (session->cookie_flags & L2TP_COOKIE_ROLLOVER_LOCAL)
- {
- s = format (s, " local rollover cookie %llx\n",
- clib_net_to_host_u64 (session->lcl_ro_cookie));
- }
-
- s = format (s, " local session-id %d remote session-id %d\n",
- clib_net_to_host_u32 (session->local_session_id),
- clib_net_to_host_u32 (session->remote_session_id));
-
- s = format (s, " l2 specific sublayer %s\n",
- session->l2_sublayer_present ? "preset" : "absent");
-
- counter_index =
- session_index_to_counter_index (session - lm->sessions,
- SESSION_COUNTER_USER_TO_NETWORK);
-
- vlib_get_combined_counter (&lm->counter_main, counter_index, &v);
- if (v.packets != 0)
- s = format (s, " user-to-net: %llu pkts %llu bytes\n",
- v.packets, v.bytes);
-
- vlib_get_combined_counter (&lm->counter_main, counter_index + 1, &v);
-
- if (v.packets != 0)
- s = format (s, " net-to-user: %llu pkts %llu bytes\n",
- v.packets, v.bytes);
- return s;
-}
-
-static clib_error_t *
-show_session_summary_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- l2t_main_t *lm = &l2t_main;
-
- vlib_cli_output (vm, "%d active sessions\n", pool_elts (lm->sessions));
-
- return 0;
-}
-
-/* *INDENT-OFF* */
-static VLIB_CLI_COMMAND (show_session_summary_command) = {
- .path = "show session",
- .short_help = "show session summary",
- .function = show_session_summary_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-show_session_detail_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- l2t_session_t *session;
- l2t_main_t *lm = &l2t_main;
-
- /* *INDENT-OFF* */
- pool_foreach (session, lm->sessions,
- ({
- vlib_cli_output (vm, "%U", format_l2t_session, session);
- }));
- /* *INDENT-ON* */
-
- return 0;
-}
-
-/* *INDENT-OFF* */
-static VLIB_CLI_COMMAND (show_session_detail_command) = {
- .path = "show session detail",
- .short_help = "show session table detail",
- .function = show_session_detail_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-test_counters_command_fn (vlib_main_t * vm,
- unformat_input_t * input, vlib_cli_command_t * cmd)
-{
- l2t_session_t *session;
- l2t_main_t *lm = &l2t_main;
- u32 session_index;
- u32 counter_index;
- u32 nincr = 0;
-
- /* *INDENT-OFF* */
- pool_foreach (session, lm->sessions,
- ({
- session_index = session - lm->sessions;
- counter_index =
- session_index_to_counter_index (session_index,
- SESSION_COUNTER_USER_TO_NETWORK);
- vlib_increment_combined_counter (&lm->counter_main,
- counter_index,
- 1/*pkt*/, 1111 /*bytes*/);
- vlib_increment_combined_counter (&lm->counter_main,
- counter_index+1,
- 1/*pkt*/, 2222 /*bytes*/);
- nincr++;
- }));
- /* *INDENT-ON* */
- vlib_cli_output (vm, "Incremented %d active counters\n", nincr);
-
- return 0;
-}
-
-/* *INDENT-OFF* */
-static VLIB_CLI_COMMAND (test_counters_command) = {
- .path = "test counters",
- .short_help = "increment all active counters",
- .function = test_counters_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-clear_counters_command_fn (vlib_main_t * vm,
- unformat_input_t * input, vlib_cli_command_t * cmd)
-{
- l2t_session_t *session;
- l2t_main_t *lm = &l2t_main;
- u32 session_index;
- u32 counter_index;
- u32 nincr = 0;
-
- /* *INDENT-OFF* */
- pool_foreach (session, lm->sessions,
- ({
- session_index = session - lm->sessions;
- counter_index =
- session_index_to_counter_index (session_index,
- SESSION_COUNTER_USER_TO_NETWORK);
- vlib_zero_combined_counter (&lm->counter_main, counter_index);
- vlib_zero_combined_counter (&lm->counter_main, counter_index+1);
- nincr++;
- }));
- /* *INDENT-ON* */
- vlib_cli_output (vm, "Cleared %d active counters\n", nincr);
-
- return 0;
-}
-
-/* *INDENT-OFF* */
-static VLIB_CLI_COMMAND (clear_counters_command) = {
- .path = "clear counters",
- .short_help = "clear all active counters",
- .function = clear_counters_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-l2tp_session_add_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- ip6_address_t client_address, our_address;
- ip6_address_t *dst_address_copy, *src_address_copy;
- unformat_input_t _line_input, *line_input = &_line_input;
- u32 vlan_id;
- u32 sw_if_index = (u32) ~ 0;
- l2t_main_t *lm = &l2t_main;
- l2t_session_t *s;
- uword *p;
- vnet_hw_interface_t *hi;
- vnet_sw_interface_t *si;
- u32 next_index;
- uword vlan_and_sw_if_index_key;
- u32 counter_index;
- u64 local_cookie = (u64) ~ 0, remote_cookie = (u64) ~ 0;
- u32 local_session_id = 1, remote_session_id = 1;
- int our_address_set = 0, client_address_set = 0;
- int l2_sublayer_present = 0;
- clib_error_t *error = NULL;
-
- /* Get a line of input. */
- if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
-
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (line_input, "client %U",
- unformat_ip6_address, &client_address))
- client_address_set = 1;
- else if (unformat (line_input, "our %U",
- unformat_ip6_address, &our_address))
- our_address_set = 1;
- else if (unformat (line_input, "vlan %d", &vlan_id))
- ;
- else if (unformat (line_input, "l2-interface %U",
- unformat_vnet_sw_interface,
- vnet_get_main (), &sw_if_index))
- ;
- else if (unformat (line_input, "interface %U",
- unformat_vnet_sw_interface,
- vnet_get_main (), &sw_if_index))
- ;
- else if (unformat (line_input, "local-cookie %llx", &local_cookie))
- ;
- else if (unformat (line_input, "remote-cookie %llx", &remote_cookie))
- ;
- else if (unformat (line_input, "local-session-id %d",
- &local_session_id))
- ;
- else if (unformat (line_input, "remote-session-id %d",
- &remote_session_id))
- ;
- else if (unformat (line_input, "l2-sublayer-present"))
- l2_sublayer_present = 1;
- else
- {
- error = clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
- unformat_free (line_input);
- return error;
- }
- }
-
- unformat_free (line_input);
-
- if (sw_if_index == (u32) ~ 0)
- return clib_error_return (0, "l2-interface not specified");
- if (our_address_set == 0)
- return clib_error_return (0, "our address not specified");
- if (client_address_set == 0)
- return clib_error_return (0, "client address not specified");
-
- remote_session_id = clib_host_to_net_u32 (remote_session_id);
- local_session_id = clib_host_to_net_u32 (local_session_id);
-
- switch (lm->lookup_type)
- {
- case L2T_LOOKUP_SRC_ADDRESS:
- p = hash_get_mem (lm->session_by_src_address, &client_address);
- if (p)
- return clib_error_return
- (0, "Session w/ client address %U already exists",
- format_ip6_address, &client_address);
- break;
-
- case L2T_LOOKUP_DST_ADDRESS:
- p = hash_get_mem (lm->session_by_dst_address, &our_address);
- if (p)
- return clib_error_return
- (0, "Session w/ our address %U already exists",
- format_ip6_address, &our_address);
- break;
-
- case L2T_LOOKUP_SESSION_ID:
- p = hash_get (lm->session_by_session_id, local_session_id);
- if (p)
- return clib_error_return
- (0,
- "Session w/ local session id %d already exists",
- clib_net_to_host_u32 (local_session_id));
- break;
-
- default:
- ASSERT (0);
- }
-
- pool_get (lm->sessions, s);
- memset (s, 0, sizeof (*s));
- clib_memcpy (&s->our_address, &our_address, sizeof (s->our_address));
- clib_memcpy (&s->client_address, &client_address,
- sizeof (s->client_address));
- s->sw_if_index = sw_if_index;
- s->vlan_id = clib_host_to_net_u16 (vlan_id);
- s->local_cookie = clib_host_to_net_u64 (local_cookie);
- l2tp_session_set_remote_cookie (s, remote_cookie);
- s->local_session_id = local_session_id;
- s->remote_session_id = remote_session_id;
- s->l2_sublayer_present = l2_sublayer_present;
-
- hi = vnet_get_sup_hw_interface (lm->vnet_main, sw_if_index);
- si = vnet_get_sup_sw_interface (lm->vnet_main, sw_if_index);
-
- next_index = vlib_node_add_next (vm, l2t_ip6_node.index,
- hi->output_node_index);
- s->l2_output_next_index = next_index;
- s->l2_output_sw_if_index = si->sw_if_index;
-
- /* Setup hash table entries */
- switch (lm->lookup_type)
- {
- case L2T_LOOKUP_SRC_ADDRESS:
- src_address_copy = clib_mem_alloc (sizeof (*src_address_copy));
- clib_memcpy (src_address_copy, &client_address,
- sizeof (*src_address_copy));
- hash_set_mem (lm->session_by_src_address, src_address_copy,
- s - lm->sessions);
- break;
- case L2T_LOOKUP_DST_ADDRESS:
- dst_address_copy = clib_mem_alloc (sizeof (*dst_address_copy));
- clib_memcpy (dst_address_copy, &our_address,
- sizeof (*dst_address_copy));
- hash_set_mem (lm->session_by_dst_address, dst_address_copy,
- s - lm->sessions);
- break;
- case L2T_LOOKUP_SESSION_ID:
- hash_set (lm->session_by_session_id, local_session_id,
- s - lm->sessions);
- break;
-
- default:
- ASSERT (0);
- }
-
- vlan_and_sw_if_index_key = ((uword) (s->vlan_id) << 32) | sw_if_index;
- hash_set (lm->session_by_vlan_and_rx_sw_if_index,
- vlan_and_sw_if_index_key, s - lm->sessions);
-
- /* validate counters */
- counter_index =
- session_index_to_counter_index (s - lm->sessions,
- SESSION_COUNTER_USER_TO_NETWORK);
- vlib_validate_counter (&lm->counter_main, counter_index);
- vlib_validate_counter (&lm->counter_main, counter_index + 1);
-
- /* Set promiscuous mode on the l2 interface */
- ethernet_set_flags (lm->vnet_main, hi->hw_if_index,
- ETHERNET_INTERFACE_FLAG_ACCEPT_ALL);
- vnet_hw_interface_rx_redirect_to_node (lm->vnet_main, hi->hw_if_index,
- l2t_l2_node.index);
- return 0;
-}
-
-/* *INDENT-OFF* */
-static VLIB_CLI_COMMAND (l2tp_session_add_command) = {
- .path = "l2tp session add",
- .short_help =
- "l2tp session add client <ip6> our <ip6> vlan <id> local-cookie <hex> remote-cookie <hex> local-session <dec> remote-session <dec> l2-interface <int>",
- .function = l2tp_session_add_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-l2tp_session_del_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- l2t_main_t *lm = &l2t_main;
- u32 session_index;
- l2t_session_t *s;
- hash_pair_t *hp;
- void *key;
- uword vlan_and_sw_if_index_key;
-
- if (!unformat (input, "%d", &session_index))
- return clib_error_return (0, "missing session index: '%U'",
- format_unformat_error, input);
-
- if (pool_is_free_index (lm->sessions, session_index))
- return clib_error_return (0, "session %d not in use", session_index);
-
- s = pool_elt_at_index (lm->sessions, session_index);
-
- switch (lm->lookup_type)
- {
- case L2T_LOOKUP_SRC_ADDRESS:
- hp = hash_get_pair_mem (lm->session_by_src_address, &s->client_address);
- if (hp)
- {
- key = (void *) (hp->key);
- hash_unset_mem (lm->session_by_src_address, &s->client_address);
- clib_mem_free (key);
- }
- else
- clib_warning ("session %d src address key %U AWOL",
- s - lm->sessions,
- format_ip6_address, &s->client_address);
- break;
-
- case L2T_LOOKUP_DST_ADDRESS:
- hp = hash_get_pair_mem (lm->session_by_dst_address, &s->our_address);
- if (hp)
- {
- key = (void *) (hp->key);
- hash_unset_mem (lm->session_by_dst_address, &s->our_address);
- clib_mem_free (key);
- }
- else
- clib_warning ("session %d dst address key %U AWOL",
- s - lm->sessions, format_ip6_address, &s->our_address);
- break;
-
- case L2T_LOOKUP_SESSION_ID:
- hash_unset (lm->session_by_session_id, s->local_session_id);
- break;
-
- default:
- ASSERT (0);
- }
-
- vlan_and_sw_if_index_key = ((uword) (s->vlan_id) << 32) | s->sw_if_index;
-
- hash_unset (lm->session_by_vlan_and_rx_sw_if_index,
- vlan_and_sw_if_index_key);
-
- pool_put (lm->sessions, s);
- return 0;
-}
-
-/* *INDENT-OFF* */
-static VLIB_CLI_COMMAND (l2tp_session_del_command) = {
- .path = "l2tp session delete",
- .short_help =
- "l2tp session delete <session-id>",
- .function = l2tp_session_del_command_fn,
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-l2tp_session_cookie_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- l2t_main_t *lm = &l2t_main;
- u32 session_index;
- l2t_session_t *s;
- u64 lcl_ro_cookie = (u64) ~ 0, rem_ro_cookie = (u64) ~ 0;
- u8 cookie_flags = 0;
-
- if (!unformat (input, "%d", &session_index))
- return clib_error_return (0, "missing session index: '%U'",
- format_unformat_error, input);
-
- if (pool_is_free_index (lm->sessions, session_index))
- return clib_error_return (0, "session %d not in use", session_index);
-
- s = pool_elt_at_index (lm->sessions, session_index);
-
- if (unformat (input, "commit"))
- {
- if (!s->cookie_flags)
- {
- return clib_error_return (0, "no rollover cookie ready to commit");
- }
- else
- {
- l2tp_session_cookie_commit (s);
- return 0;
- }
- }
- if (!unformat (input, "rollover"))
- return clib_error_return (0, "missing 'commit|rollover': '%U'",
- format_unformat_error, input);
- if (unformat (input, "local %llx", &lcl_ro_cookie))
- {
- cookie_flags |= L2TP_COOKIE_ROLLOVER_LOCAL;
- l2tp_session_set_local_rollover_cookie (s, lcl_ro_cookie);
- }
- if (unformat (input, "remote %llx", &rem_ro_cookie))
- {
- cookie_flags |= L2TP_COOKIE_ROLLOVER_REMOTE;
- l2tp_session_set_remote_cookie (s, rem_ro_cookie);
- }
- if (!cookie_flags)
- return clib_error_return (0, "no rollover cookie specified");
-
- return 0;
-}
-
-/* *INDENT-OFF* */
-static VLIB_CLI_COMMAND (l2tp_session_cookie_command) = {
- .path = "l2tp session cookie",
- .short_help =
- "l2tp session cookie <session id> commit|rollover [local <hex>] [remote <hex>]",
- .function = l2tp_session_cookie_command_fn,
-};
-/* *INDENT-ON* */
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/src/vpp/app/l2t_l2.c b/src/vpp/app/l2t_l2.c
deleted file mode 100644
index 07d30d9a2f2..00000000000
--- a/src/vpp/app/l2t_l2.c
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <vnet/vnet.h>
-#include <vnet/ip/ip.h>
-#include <vnet/ethernet/ethernet.h>
-
-#if DPDK == 0
-#include <vnet/devices/pci/ixgev.h>
-#include <vnet/devices/pci/ixge.h>
-#include <vnet/devices/pci/ige.h>
-#else
-#include <vnet/devices/dpdk/dpdk.h>
-#endif
-
-#include <vppinfra/error.h>
-#include <vppinfra/hash.h>
-#include <app/l2t.h>
-
-l2t_main_t l2t_main;
-
-/* Statistics (not really errors) */
-#define foreach_l2t_l2_error \
-_(NETWORK_TO_USER, "L2 network to user (ip6) pkts")
-
-static char *l2t_l2_error_strings[] = {
-#define _(sym,string) string,
- foreach_l2t_l2_error
-#undef _
-};
-
-typedef enum
-{
-#define _(sym,str) L2T_L2_ERROR_##sym,
- foreach_l2t_l2_error
-#undef _
- L2T_L2_N_ERROR,
-} l2t_l2_error_t;
-
-/*
- * Packets go to ethernet-input when they don't match a mapping
- */
-typedef enum
-{
- L2T_L2_NEXT_DROP,
- L2T_L2_NEXT_ETHERNET_INPUT,
- L2T_L2_NEXT_IP6_LOOKUP,
- L2T_L2_N_NEXT,
-} l2t_l2_next_t;
-
-vlib_node_registration_t l2t_l2_node;
-
-#define NSTAGES 3
-
-static inline void
-stage0 (vlib_main_t * vm, vlib_node_runtime_t * node, u32 buffer_index)
-{
- vlib_buffer_t *b = vlib_get_buffer (vm, buffer_index);
- vlib_prefetch_buffer_header (b, STORE);
- CLIB_PREFETCH (b->data, 2 * CLIB_CACHE_LINE_BYTES, STORE);
-}
-
-static inline void
-stage1 (vlib_main_t * vm, vlib_node_runtime_t * node, u32 bi)
-{
- vlib_buffer_t *b = vlib_get_buffer (vm, bi);
- l2t_main_t *lm = &l2t_main;
- ethernet_header_t *eh;
- ethernet_vlan_header_t *vh;
- u32 session_index;
- uword *p;
- uword vlan_and_sw_if_index_key;
-
- /* just in case, needed to test with the tun/tap device */
- vlib_buffer_reset (b);
-
- eh = vlib_buffer_get_current (b);
-
- /* Not a VLAN pkt? send to ethernet-input... */
- if (PREDICT_FALSE (eh->type != clib_host_to_net_u16 (0x8100)))
- {
- vnet_buffer (b)->l2t.next_index = L2T_L2_NEXT_ETHERNET_INPUT;
- return;
- }
- vh = (ethernet_vlan_header_t *) (eh + 1);
-
- /* look up session */
- vlan_and_sw_if_index_key = ((uword) (vh->priority_cfi_and_id) << 32)
- | vnet_buffer (b)->sw_if_index[VLIB_RX];
-
- p = hash_get (lm->session_by_vlan_and_rx_sw_if_index,
- vlan_and_sw_if_index_key);
-
- if (PREDICT_FALSE (p == 0))
- {
- /* $$$ drop here if not for our MAC? */
- vnet_buffer (b)->l2t.next_index = L2T_L2_NEXT_ETHERNET_INPUT;
- return;
- }
- else
- {
- session_index = p[0];
- }
-
- /* Remember mapping index, prefetch the mini counter */
- vnet_buffer (b)->l2t.next_index = L2T_L2_NEXT_IP6_LOOKUP;
- vnet_buffer (b)->l2t.session_index = session_index;
-
- /* Each mapping has 2 x (pkt, byte) counters, hence the shift */
- CLIB_PREFETCH (lm->counter_main.mini + (p[0] << 1), CLIB_CACHE_LINE_BYTES,
- STORE);
-}
-
-static inline u32
-last_stage (vlib_main_t * vm, vlib_node_runtime_t * node, u32 bi)
-{
- vlib_buffer_t *b = vlib_get_buffer (vm, bi);
- l2t_main_t *lm = &l2t_main;
- ethernet_header_t *eh = vlib_buffer_get_current (b);
- vlib_node_t *n = vlib_get_node (vm, l2t_l2_node.index);
- u32 node_counter_base_index = n->error_heap_index;
- vlib_error_main_t *em = &vm->error_main;
- l2tpv3_header_t *l2t; /* l2 header */
- ethernet_vlan_header_t *vh; /* 802.1q vlan header */
- u32 counter_index;
- l2t_session_t *s;
- ip6_header_t *ip6;
- u16 payload_ethertype;
- u8 dst_mac_address[6];
- u8 src_mac_address[6];
- u16 payload_length;
- i32 backup;
-
- /* Other-than-output pkt? We're done... */
- if (vnet_buffer (b)->l2t.next_index != L2T_L2_NEXT_IP6_LOOKUP)
- return vnet_buffer (b)->l2t.next_index;
-
- vh = (ethernet_vlan_header_t *) (eh + 1);
-
- em->counters[node_counter_base_index + L2T_L2_ERROR_NETWORK_TO_USER] += 1;
-
- counter_index =
- session_index_to_counter_index (vnet_buffer (b)->l2t.session_index,
- SESSION_COUNTER_NETWORK_TO_USER);
-
- /* per-mapping byte stats include the ethernet header */
- vlib_increment_combined_counter (&lm->counter_main, counter_index,
- 1 /* packet_increment */ ,
- vlib_buffer_length_in_chain (vm, b) +
- sizeof (ethernet_header_t));
-
- s = pool_elt_at_index (lm->sessions, vnet_buffer (b)->l2t.session_index);
-
- /* Save src/dst MAC addresses */
-#define _(i) dst_mac_address[i] = eh->dst_address[i];
- _(0) _(1) _(2) _(3) _(4) _(5);
-#undef _
-#define _(i) src_mac_address[i] = eh->src_address[i];
- _(0) _(1) _(2) _(3) _(4) _(5);
-#undef _
-
- payload_ethertype = vh->type;
-
- /* Splice out the 802.1q vlan tag */
- vlib_buffer_advance (b, 4);
- eh = vlib_buffer_get_current (b);
-
- /* restore src/dst MAC addresses */
-#define _(i) eh->dst_address[i] = dst_mac_address[i];
- _(0) _(1) _(2) _(3) _(4) _(5);
-#undef _
-#define _(i) eh->src_address[i] = src_mac_address[i];
- _(0) _(1) _(2) _(3) _(4) _(5);
-#undef _
- eh->type = payload_ethertype;
-
- /* Paint on an l2tpv3 hdr */
- backup = sizeof (*l2t);
-#if 0
- /* back up 4 bytes less if no l2 sublayer */
- backup -= s->l2_sublayer_present ? 0 : 4;
-#endif
-
- vlib_buffer_advance (b, -backup);
- l2t = vlib_buffer_get_current (b);
-
- l2t->session_id = s->remote_session_id;
- l2t->cookie = s->remote_cookie;
-
-#if 0
- if (s->l2_sublayer_present)
- l2t->l2_specific_sublayer = 0;
-#endif
-
- /* Paint on an ip6 header */
- vlib_buffer_advance (b, -(sizeof (*ip6)));
- ip6 = vlib_buffer_get_current (b);
-
- ip6->ip_version_traffic_class_and_flow_label =
- clib_host_to_net_u32 (0x6 << 28);
-
- /* calculate ip6 payload length */
- payload_length = vlib_buffer_length_in_chain (vm, b);
- payload_length -= sizeof (*ip6);
-
- ip6->payload_length = clib_host_to_net_u16 (payload_length);
- ip6->protocol = 0x73; /* l2tpv3 */
- ip6->hop_limit = 0xff;
- ip6->src_address.as_u64[0] = s->our_address.as_u64[0];
- ip6->src_address.as_u64[1] = s->our_address.as_u64[1];
- ip6->dst_address.as_u64[0] = s->client_address.as_u64[0];
- ip6->dst_address.as_u64[1] = s->client_address.as_u64[1];
-
- return L2T_L2_NEXT_IP6_LOOKUP;
-}
-
-#include <vnet/pipeline.h>
-
-static uword
-l2t_l2_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
-{
- return dispatch_pipeline (vm, node, frame);
-}
-
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (l2t_l2_node) = {
- .function = l2t_l2_node_fn,
- .name = "l2t-l2-input",
- .vector_size = sizeof (u32),
- .format_trace = format_l2t_trace,
- .type = VLIB_NODE_TYPE_INTERNAL,
-
- .n_errors = ARRAY_LEN(l2t_l2_error_strings),
- .error_strings = l2t_l2_error_strings,
-
- .n_next_nodes = L2T_L2_N_NEXT,
-
- /* edit / add dispositions here */
- .next_nodes = {
- [L2T_L2_NEXT_IP6_LOOKUP] = "ip6-lookup",
- [L2T_L2_NEXT_ETHERNET_INPUT] = "ethernet-input",
- [L2T_L2_NEXT_DROP] = "error-drop",
- },
-};
-/* *INDENT-ON* */
-
-VLIB_NODE_FUNCTION_MULTIARCH (l2t_l2_node, l2t_l2_node_fn);
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */