aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vnet/Makefile.am1
-rw-r--r--vnet/vnet/devices/af_packet/node.c17
-rw-r--r--vnet/vnet/devices/devices.h48
-rw-r--r--vnet/vnet/devices/dpdk/dpdk.h13
-rw-r--r--vnet/vnet/devices/dpdk/node.c57
-rw-r--r--vnet/vnet/devices/feature.c4
-rw-r--r--vnet/vnet/devices/netmap/node.c17
-rw-r--r--vnet/vnet/devices/ssvm/node.c2
-rw-r--r--vnet/vnet/devices/virtio/vhost-user.c22
-rw-r--r--vnet/vnet/unix/tuntap.c28
10 files changed, 88 insertions, 121 deletions
diff --git a/vnet/Makefile.am b/vnet/Makefile.am
index 96306dd3..f53a61bf 100644
--- a/vnet/Makefile.am
+++ b/vnet/Makefile.am
@@ -44,6 +44,7 @@ nobase_include_HEADERS += \
vnet/api_errno.h \
vnet/buffer.h \
vnet/config.h \
+ vnet/devices/devices.h \
vnet/global_funcs.h \
vnet/handoff.h \
vnet/interface.h \
diff --git a/vnet/vnet/devices/af_packet/node.c b/vnet/vnet/devices/af_packet/node.c
index f086b8da..8c0d6455 100644
--- a/vnet/vnet/devices/af_packet/node.c
+++ b/vnet/vnet/devices/af_packet/node.c
@@ -23,6 +23,7 @@
#include <vlib/unix/unix.h>
#include <vnet/ip/ip.h>
#include <vnet/ethernet/ethernet.h>
+#include <vnet/devices/devices.h>
#include <vnet/feature/feature.h>
#include <vnet/devices/af_packet/af_packet.h>
@@ -43,13 +44,6 @@ static char *af_packet_input_error_strings[] = {
#undef _
};
-enum
-{
- AF_PACKET_INPUT_NEXT_DROP,
- AF_PACKET_INPUT_NEXT_ETHERNET_INPUT,
- AF_PACKET_INPUT_N_NEXT,
-};
-
typedef struct
{
u32 next_index;
@@ -130,7 +124,7 @@ af_packet_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
af_packet_main_t *apm = &af_packet_main;
af_packet_if_t *apif = pool_elt_at_index (apm->interfaces, device_idx);
struct tpacket2_hdr *tph;
- u32 next_index = AF_PACKET_INPUT_NEXT_ETHERNET_INPUT;
+ u32 next_index = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT;
u32 block = 0;
u32 rx_frame;
u32 n_free_bufs;
@@ -295,11 +289,8 @@ VLIB_REGISTER_NODE (af_packet_input_node) = {
.n_errors = AF_PACKET_INPUT_N_ERROR,
.error_strings = af_packet_input_error_strings,
- .n_next_nodes = AF_PACKET_INPUT_N_NEXT,
- .next_nodes = {
- [AF_PACKET_INPUT_NEXT_DROP] = "error-drop",
- [AF_PACKET_INPUT_NEXT_ETHERNET_INPUT] = "ethernet-input",
- },
+ .n_next_nodes = VNET_DEVICE_INPUT_N_NEXT_NODES,
+ .next_nodes = VNET_DEVICE_INPUT_NEXT_NODES,
};
VLIB_NODE_FUNCTION_MULTIARCH (af_packet_input_node, af_packet_input_fn)
diff --git a/vnet/vnet/devices/devices.h b/vnet/vnet/devices/devices.h
new file mode 100644
index 00000000..9c74dc31
--- /dev/null
+++ b/vnet/vnet/devices/devices.h
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+#ifndef included_vnet_vnet_device_h
+#define included_vnet_vnet_device_h
+
+#include <vnet/unix/pcap.h>
+#include <vnet/l3_types.h>
+
+typedef enum
+{
+ VNET_DEVICE_INPUT_NEXT_IP4_INPUT,
+ VNET_DEVICE_INPUT_NEXT_IP6_INPUT,
+ VNET_DEVICE_INPUT_NEXT_MPLS_INPUT,
+ VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT,
+ VNET_DEVICE_INPUT_NEXT_DROP,
+ VNET_DEVICE_INPUT_N_NEXT_NODES,
+} vnet_device_input_next_t;
+
+#define VNET_DEVICE_INPUT_NEXT_NODES { \
+ [VNET_DEVICE_INPUT_NEXT_DROP] = "error-drop", \
+ [VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT] = "ethernet-input", \
+ [VNET_DEVICE_INPUT_NEXT_IP4_INPUT] = "ip4-input-no-checksum", \
+ [VNET_DEVICE_INPUT_NEXT_IP6_INPUT] = "ip6-input", \
+ [VNET_DEVICE_INPUT_NEXT_MPLS_INPUT] = "mpls-input", \
+}
+
+#endif /* included_vnet_vnet_device_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/devices/dpdk/dpdk.h b/vnet/vnet/devices/dpdk/dpdk.h
index dfbfce50..1d2b4b76 100644
--- a/vnet/vnet/devices/dpdk/dpdk.h
+++ b/vnet/vnet/devices/dpdk/dpdk.h
@@ -50,6 +50,7 @@
#include <rte_sched.h>
#include <vnet/unix/pcap.h>
+#include <vnet/devices/devices.h>
#if CLIB_DEBUG > 0
#define always_inline static inline
@@ -474,16 +475,6 @@ typedef struct
dpdk_main_t dpdk_main;
-typedef enum
-{
- DPDK_RX_NEXT_IP4_INPUT,
- DPDK_RX_NEXT_IP6_INPUT,
- DPDK_RX_NEXT_MPLS_INPUT,
- DPDK_RX_NEXT_ETHERNET_INPUT,
- DPDK_RX_NEXT_DROP,
- DPDK_RX_N_NEXT,
-} dpdk_rx_next_t;
-
typedef struct
{
u32 buffer_index;
@@ -506,8 +497,6 @@ typedef struct
void vnet_buffer_needs_dpdk_mb (vlib_buffer_t * b);
-void dpdk_set_next_node (dpdk_rx_next_t, char *);
-
clib_error_t *dpdk_set_mac_address (vnet_hw_interface_t * hi, char *address);
clib_error_t *dpdk_set_mc_filter (vnet_hw_interface_t * hi,
diff --git a/vnet/vnet/devices/dpdk/node.c b/vnet/vnet/devices/dpdk/node.c
index 01a6094e..bcb4feac 100644
--- a/vnet/vnet/devices/dpdk/node.c
+++ b/vnet/vnet/devices/dpdk/node.c
@@ -23,6 +23,7 @@
#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"
@@ -91,7 +92,7 @@ dpdk_rx_next_and_error_from_mb_flags_x1 (dpdk_device_t * xd,
PKT_RX_IP_CKSUM_BAD | PKT_RX_L4_CKSUM_BAD)))
{
/* some error was flagged. determine the drop reason */
- n0 = DPDK_RX_NEXT_DROP;
+ n0 = VNET_DEVICE_INPUT_NEXT_DROP;
*error0 =
#ifdef RTE_LIBRTE_MBUF_EXT_RX_OLFLAGS
(mb_flags & PKT_EXT_RX_PKT_ERROR) ? DPDK_ERROR_RX_PACKET_ERROR :
@@ -124,17 +125,17 @@ dpdk_rx_next_and_error_from_mb_flags_x1 (dpdk_device_t * xd,
else
if (PREDICT_FALSE ((xd->flags & DPDK_DEVICE_FLAG_HAVE_SUBIF) ||
(mb_flags & PKT_RX_VLAN_PKT)))
- n0 = DPDK_RX_NEXT_ETHERNET_INPUT;
+ n0 = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT;
else
{
if (PREDICT_TRUE (dpdk_mbuf_is_ip4 (mb)))
- n0 = DPDK_RX_NEXT_IP4_INPUT;
+ n0 = VNET_DEVICE_INPUT_NEXT_IP4_INPUT;
else if (PREDICT_TRUE (dpdk_mbuf_is_ip6 (mb)))
- n0 = DPDK_RX_NEXT_IP6_INPUT;
+ n0 = VNET_DEVICE_INPUT_NEXT_IP6_INPUT;
else if (PREDICT_TRUE (vlib_buffer_is_mpls (b0)))
- n0 = DPDK_RX_NEXT_MPLS_INPUT;
+ n0 = VNET_DEVICE_INPUT_NEXT_MPLS_INPUT;
else
- n0 = DPDK_RX_NEXT_ETHERNET_INPUT;
+ n0 = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT;
}
}
*next0 = n0;
@@ -323,7 +324,7 @@ dpdk_device_input (dpdk_main_t * dm,
u32 cpu_index, u16 queue_id, int use_efd)
{
u32 n_buffers;
- u32 next_index = DPDK_RX_NEXT_ETHERNET_INPUT;
+ u32 next_index = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT;
u32 n_left_to_next, *to_next;
u32 mb_index;
vlib_main_t *vm = vlib_get_main ();
@@ -475,9 +476,9 @@ dpdk_device_input (dpdk_main_t * dm,
b0->error = node->errors[error0];
- l3_offset0 = ((next0 == DPDK_RX_NEXT_IP4_INPUT ||
- next0 == DPDK_RX_NEXT_IP6_INPUT ||
- next0 == DPDK_RX_NEXT_MPLS_INPUT) ?
+ l3_offset0 = ((next0 == VNET_DEVICE_INPUT_NEXT_IP4_INPUT ||
+ next0 == VNET_DEVICE_INPUT_NEXT_IP6_INPUT ||
+ next0 == VNET_DEVICE_INPUT_NEXT_MPLS_INPUT) ?
sizeof (ethernet_header_t) : 0);
b0->current_data = l3_offset0;
@@ -717,14 +718,8 @@ VLIB_REGISTER_NODE (dpdk_input_node) = {
.n_errors = DPDK_N_ERROR,
.error_strings = dpdk_error_strings,
- .n_next_nodes = DPDK_RX_N_NEXT,
- .next_nodes = {
- [DPDK_RX_NEXT_DROP] = "error-drop",
- [DPDK_RX_NEXT_ETHERNET_INPUT] = "ethernet-input",
- [DPDK_RX_NEXT_IP4_INPUT] = "ip4-input-no-checksum",
- [DPDK_RX_NEXT_IP6_INPUT] = "ip6-input",
- [DPDK_RX_NEXT_MPLS_INPUT] = "mpls-input",
- },
+ .n_next_nodes = VNET_DEVICE_INPUT_N_NEXT_NODES,
+ .next_nodes = VNET_DEVICE_INPUT_NEXT_NODES,
};
@@ -739,32 +734,6 @@ CLIB_MULTIARCH_SELECT_FN(dpdk_input_rss);
CLIB_MULTIARCH_SELECT_FN(dpdk_input_efd);
/*
- * Override the next nodes for the dpdk input nodes.
- * Must be invoked prior to VLIB_INIT_FUNCTION calls.
- */
-void
-dpdk_set_next_node (dpdk_rx_next_t next, char *name)
-{
- vlib_node_registration_t *r = &dpdk_input_node;
- vlib_node_registration_t *r_handoff = &handoff_dispatch_node;
-
- switch (next)
- {
- case DPDK_RX_NEXT_IP4_INPUT:
- case DPDK_RX_NEXT_IP6_INPUT:
- case DPDK_RX_NEXT_MPLS_INPUT:
- case DPDK_RX_NEXT_ETHERNET_INPUT:
- r->next_nodes[next] = name;
- r_handoff->next_nodes[next] = name;
- break;
-
- default:
- clib_warning ("%s: illegal next %d\n", __FUNCTION__, next);
- break;
- }
-}
-
-/*
* set_efd_bitmap()
* Based on the operation type, set lower/upper bits for the given index value
*/
diff --git a/vnet/vnet/devices/feature.c b/vnet/vnet/devices/feature.c
index 8de78178..f55d1860 100644
--- a/vnet/vnet/devices/feature.c
+++ b/vnet/vnet/devices/feature.c
@@ -19,9 +19,9 @@
VNET_FEATURE_ARC_INIT (device_input, static) = {
.arc_name = "device-input",
#if DPDK > 0
- .start_nodes = VNET_FEATURES ("dpdk-input", "vhost-user-input", "af-packet-input", "netmap-input"),
+ .start_nodes = VNET_FEATURES ("dpdk-input", "vhost-user-input", "af-packet-input", "netmap-input", "tuntap-rx"),
#else
- .start_nodes = VNET_FEATURES ("vhost-user-input", "af-packet-input", "netmap-input"),
+ .start_nodes = VNET_FEATURES ("vhost-user-input", "af-packet-input", "netmap-input", "tuntap-rx"),
#endif
};
diff --git a/vnet/vnet/devices/netmap/node.c b/vnet/vnet/devices/netmap/node.c
index d13fa1bc..fb60fbd6 100644
--- a/vnet/vnet/devices/netmap/node.c
+++ b/vnet/vnet/devices/netmap/node.c
@@ -22,6 +22,7 @@
#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
#include <vnet/ethernet/ethernet.h>
+#include <vnet/devices/devices.h>
#include <vnet/feature/feature.h>
#include <vnet/devices/netmap/net_netmap.h>
@@ -43,13 +44,6 @@ static char *netmap_input_error_strings[] = {
#undef _
};
-enum
-{
- NETMAP_INPUT_NEXT_DROP,
- NETMAP_INPUT_NEXT_ETHERNET_INPUT,
- NETMAP_INPUT_N_NEXT,
-};
-
typedef struct
{
u32 next_index;
@@ -106,7 +100,7 @@ always_inline uword
netmap_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * frame, netmap_if_t * nif)
{
- u32 next_index = NETMAP_INPUT_NEXT_ETHERNET_INPUT;
+ u32 next_index = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT;
uword n_trace = vlib_get_trace_count (vm, node);
netmap_main_t *nm = &netmap_main;
u32 n_rx_packets = 0;
@@ -306,11 +300,8 @@ VLIB_REGISTER_NODE (netmap_input_node) = {
.n_errors = NETMAP_INPUT_N_ERROR,
.error_strings = netmap_input_error_strings,
- .n_next_nodes = NETMAP_INPUT_N_NEXT,
- .next_nodes = {
- [NETMAP_INPUT_NEXT_DROP] = "error-drop",
- [NETMAP_INPUT_NEXT_ETHERNET_INPUT] = "ethernet-input",
- },
+ .n_next_nodes = VNET_DEVICE_INPUT_N_NEXT_NODES,
+ .next_nodes = VNET_DEVICE_INPUT_NEXT_NODES,
};
VLIB_NODE_FUNCTION_MULTIARCH (netmap_input_node, netmap_input_fn)
diff --git a/vnet/vnet/devices/ssvm/node.c b/vnet/vnet/devices/ssvm/node.c
index e613cc9c..5ecccd37 100644
--- a/vnet/vnet/devices/ssvm/node.c
+++ b/vnet/vnet/devices/ssvm/node.c
@@ -78,7 +78,7 @@ ssvm_eth_device_input (ssvm_eth_main_t * em,
u32 n_to_alloc = VLIB_FRAME_SIZE * 2;
u32 n_allocated, n_present_in_cache;
#if DPDK > 0
- u32 next_index = DPDK_RX_NEXT_ETHERNET_INPUT;
+ u32 next_index = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT;
#else
u32 next_index = 0;
#endif
diff --git a/vnet/vnet/devices/virtio/vhost-user.c b/vnet/vnet/devices/virtio/vhost-user.c
index bdac7c24..b55547cd 100644
--- a/vnet/vnet/devices/virtio/vhost-user.c
+++ b/vnet/vnet/devices/virtio/vhost-user.c
@@ -36,6 +36,7 @@
#include <vnet/ip/ip.h>
#include <vnet/ethernet/ethernet.h>
+#include <vnet/devices/devices.h>
#include <vnet/feature/feature.h>
#include <vnet/devices/virtio/vhost-user.h>
@@ -918,14 +919,6 @@ vhost_user_exit (vlib_main_t * vm)
VLIB_MAIN_LOOP_EXIT_FUNCTION (vhost_user_exit);
-enum
-{
- VHOST_USER_RX_NEXT_ETHERNET_INPUT,
- VHOST_USER_RX_NEXT_DROP,
- VHOST_USER_RX_N_NEXT,
-};
-
-
typedef struct
{
u16 virtqueue;
@@ -972,7 +965,7 @@ vhost_user_rx_trace (vlib_main_t * vm,
u32 *b, n_left;
vhost_user_main_t *vum = &vhost_user_main;
- u32 next_index = VHOST_USER_RX_NEXT_ETHERNET_INPUT;
+ u32 next_index = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT;
n_left = vec_len (vui->d_trace_buffers);
b = vui->d_trace_buffers;
@@ -1277,7 +1270,7 @@ vhost_user_if_input (vlib_main_t * vm,
if (PREDICT_FALSE (error))
{
drops++;
- next0 = VHOST_USER_RX_NEXT_DROP;
+ next0 = VNET_DEVICE_INPUT_NEXT_DROP;
}
else
{
@@ -1285,7 +1278,7 @@ vhost_user_if_input (vlib_main_t * vm,
b_head->current_length +
b_head->total_length_not_including_first_buffer;
n_rx_packets++;
- next0 = VHOST_USER_RX_NEXT_ETHERNET_INPUT;
+ next0 = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT;
}
to_next[0] = bi_head;
@@ -1385,11 +1378,8 @@ VLIB_REGISTER_NODE (vhost_user_input_node) = {
.n_errors = VHOST_USER_INPUT_FUNC_N_ERROR,
.error_strings = vhost_user_input_func_error_strings,
- .n_next_nodes = VHOST_USER_RX_N_NEXT,
- .next_nodes = {
- [VHOST_USER_RX_NEXT_DROP] = "error-drop",
- [VHOST_USER_RX_NEXT_ETHERNET_INPUT] = "ethernet-input",
- },
+ .n_next_nodes = VNET_DEVICE_INPUT_N_NEXT_NODES,
+ .next_nodes = VNET_DEVICE_INPUT_NEXT_NODES,
};
VLIB_NODE_FUNCTION_MULTIARCH (vhost_user_input_node, vhost_user_input)
diff --git a/vnet/vnet/unix/tuntap.c b/vnet/vnet/unix/tuntap.c
index e4d05446..13520d27 100644
--- a/vnet/vnet/unix/tuntap.c
+++ b/vnet/vnet/unix/tuntap.c
@@ -47,6 +47,7 @@
#include <vnet/ip/ip.h>
#include <vnet/ethernet/ethernet.h>
+#include <vnet/devices/devices.h>
#include <vnet/feature/feature.h>
#if DPDK == 1
@@ -212,14 +213,6 @@ VLIB_REGISTER_NODE (tuntap_tx_node,static) = {
.vector_size = 4,
};
-enum {
- TUNTAP_RX_NEXT_IP4_INPUT,
- TUNTAP_RX_NEXT_IP6_INPUT,
- TUNTAP_RX_NEXT_ETHERNET_INPUT,
- TUNTAP_RX_NEXT_DROP,
- TUNTAP_RX_N_NEXT,
-};
-
/**
* @brief TUNTAP receive node
* @node tuntap-rx
@@ -370,19 +363,19 @@ tuntap_rx (vlib_main_t * vm,
if (tm->is_ether)
{
- next_index = TUNTAP_RX_NEXT_ETHERNET_INPUT;
+ next_index = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT;
}
else
switch (b->data[0] & 0xf0)
{
case 0x40:
- next_index = TUNTAP_RX_NEXT_IP4_INPUT;
+ next_index = VNET_DEVICE_INPUT_NEXT_IP4_INPUT;
break;
case 0x60:
- next_index = TUNTAP_RX_NEXT_IP6_INPUT;
+ next_index = VNET_DEVICE_INPUT_NEXT_IP6_INPUT;
break;
default:
- next_index = TUNTAP_RX_NEXT_DROP;
+ next_index = VNET_DEVICE_INPUT_NEXT_DROP;
break;
}
@@ -393,7 +386,7 @@ tuntap_rx (vlib_main_t * vm,
vnet_sw_interface_t * si;
si = vnet_get_sw_interface (vnm, tm->sw_if_index);
if (!(si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP))
- next_index = TUNTAP_RX_NEXT_DROP;
+ next_index = VNET_DEVICE_INPUT_NEXT_DROP;
}
vnet_feature_device_input_redirect_x1 (node, tm->hw_if_index, &next_index, b, 0);
@@ -427,13 +420,8 @@ VLIB_REGISTER_NODE (tuntap_rx_node,static) = {
.n_errors = 1,
.error_strings = tuntap_rx_error_strings,
- .n_next_nodes = TUNTAP_RX_N_NEXT,
- .next_nodes = {
- [TUNTAP_RX_NEXT_IP4_INPUT] = "ip4-input-no-checksum",
- [TUNTAP_RX_NEXT_IP6_INPUT] = "ip6-input",
- [TUNTAP_RX_NEXT_DROP] = "error-drop",
- [TUNTAP_RX_NEXT_ETHERNET_INPUT] = "ethernet-input",
- },
+ .n_next_nodes = VNET_DEVICE_INPUT_N_NEXT_NODES,
+ .next_nodes = VNET_DEVICE_INPUT_NEXT_NODES,
};
/**