Merge "Move rpc handler where it belongs, related cleanup"
This commit is contained in:
@ -109,8 +109,6 @@ static inline u32 vl_msg_api_handle_from_index_and_epoch (u32 index, u32 epoch)
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *vl_msg_api_alloc(int nbytes);
|
||||
void *vl_msg_api_alloc_as_if_client (int nbytes);
|
||||
void vl_msg_api_free(void *a);
|
||||
@ -136,4 +134,6 @@ int vl_client_connect_to_vlib_no_rx_pthread (char *svm_name, char *client_name,
|
||||
int rx_queue_size);
|
||||
u16 vl_client_get_first_plugin_msg_id (char * plugin_name);
|
||||
|
||||
void vl_api_rpc_call_main_thread (void *fp, u8 * data, u32 data_length);
|
||||
|
||||
#endif /* included_vlibmemory_api_h */
|
||||
|
@ -14,26 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
*------------------------------------------------------------------
|
||||
* memclnt.api - API message(s) to hook up clients, pass traffic
|
||||
* to client processes on the same system element
|
||||
*
|
||||
* Copyright (c) 2009 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.
|
||||
*------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* Create a client registration
|
||||
*/
|
||||
|
@ -1122,3 +1122,88 @@ VLIB_CLI_COMMAND (cli_show_api_plugin_command, static) = {
|
||||
.short_help = "show api plugin",
|
||||
.function = vl_api_show_plugin_command,
|
||||
};
|
||||
|
||||
static void vl_api_rpc_call_t_handler (vl_api_rpc_call_t * mp)
|
||||
{
|
||||
vl_api_rpc_reply_t * rmp;
|
||||
int (*fp)(void *);
|
||||
i32 rv = 0;
|
||||
vlib_main_t * vm = vlib_get_main();
|
||||
|
||||
if (mp->function == 0)
|
||||
{
|
||||
rv = -1;
|
||||
clib_warning ("rpc NULL function pointer");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (mp->need_barrier_sync)
|
||||
vlib_worker_thread_barrier_sync (vm);
|
||||
|
||||
fp = (void *)(mp->function);
|
||||
rv = (*fp)(mp->data);
|
||||
|
||||
if (mp->need_barrier_sync)
|
||||
vlib_worker_thread_barrier_release (vm);
|
||||
}
|
||||
|
||||
if (mp->send_reply)
|
||||
{
|
||||
unix_shared_memory_queue_t * q =
|
||||
vl_api_client_index_to_input_queue (mp->client_index);
|
||||
if (q)
|
||||
{
|
||||
rmp = vl_msg_api_alloc_as_if_client (sizeof (*rmp));
|
||||
rmp->_vl_msg_id = ntohs (VL_API_RPC_REPLY);
|
||||
rmp->context = mp->context;
|
||||
rmp->retval = rv;
|
||||
vl_msg_api_send_shmem (q, (u8 *)&rmp);
|
||||
}
|
||||
}
|
||||
if (mp->multicast)
|
||||
{
|
||||
clib_warning ("multicast not yet implemented...");
|
||||
}
|
||||
}
|
||||
|
||||
static void vl_api_rpc_reply_t_handler (vl_api_rpc_reply_t * mp)
|
||||
{ clib_warning ("unimplemented"); }
|
||||
|
||||
void vl_api_rpc_call_main_thread (void *fp, u8 * data, u32 data_length)
|
||||
{
|
||||
vl_api_rpc_call_t * mp;
|
||||
api_main_t *am = &api_main;
|
||||
vl_shmem_hdr_t *shmem_hdr = am->shmem_hdr;
|
||||
|
||||
mp = vl_msg_api_alloc_as_if_client (sizeof (*mp) + data_length);
|
||||
memset (mp, 0, sizeof (*mp));
|
||||
memcpy (mp->data, data, data_length);
|
||||
mp->_vl_msg_id = ntohs (VL_API_RPC_CALL);
|
||||
mp->function = (u64)fp;
|
||||
mp->need_barrier_sync = 1;
|
||||
|
||||
/* Use the "normal" control-plane mechanism for the main thread */
|
||||
vl_msg_api_send_shmem (shmem_hdr->vl_input_queue, (u8 *)&mp);
|
||||
}
|
||||
|
||||
#define foreach_rpc_api_msg \
|
||||
_(RPC_CALL,rpc_call) \
|
||||
_(RPC_REPLY,rpc_reply)
|
||||
|
||||
static clib_error_t *
|
||||
rpc_api_hookup (vlib_main_t *vm)
|
||||
{
|
||||
#define _(N,n) \
|
||||
vl_msg_api_set_handlers(VL_API_##N, #n, \
|
||||
vl_api_##n##_t_handler, \
|
||||
vl_noop_handler, \
|
||||
vl_noop_handler, \
|
||||
vl_api_##n##_t_print, \
|
||||
sizeof(vl_api_##n##_t), 0 /* do not trace */);
|
||||
foreach_rpc_api_msg;
|
||||
#undef _
|
||||
return 0;
|
||||
}
|
||||
|
||||
VLIB_API_INIT_FUNCTION(rpc_api_hookup);
|
||||
|
@ -18,6 +18,7 @@ AM_CFLAGS = -Wall @DPDK@ @VIRL@
|
||||
libvnet_la_SOURCES =
|
||||
libvnetplugin_la_SOURCES =
|
||||
nobase_include_HEADERS =
|
||||
noinst_PROGRAMS =
|
||||
|
||||
########################################
|
||||
# Generic stuff
|
||||
@ -608,20 +609,12 @@ nobase_include_HEADERS += \
|
||||
|
||||
lib_LTLIBRARIES = libvnet.la libvnetplugin.la
|
||||
|
||||
noinst_PROGRAMS = vnet_unix
|
||||
|
||||
vnet_unix_SOURCES = \
|
||||
example/main_stub.c
|
||||
|
||||
vnet_unix_LDFLAGS = -static
|
||||
dpdk_libs =
|
||||
|
||||
if WITH_DPDK
|
||||
dpdk_libs += -l:libdpdk.a
|
||||
endif
|
||||
|
||||
vnet_unix_LDADD = libvnet.la -l:libvlib_unix.a -l:libvlib.a -l:libvppinfra.a -lpthread -lvlibapi -lvlibmemory -lsvm -lm -ldl $(dpdk_libs) -lrt
|
||||
|
||||
pcap2pg_SOURCES = \
|
||||
vnet/unix/pcap2pg.c \
|
||||
vnet/unix/pcap.h
|
||||
|
@ -93,6 +93,7 @@ PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
noinst_PROGRAMS = pcap2pg$(EXEEXT)
|
||||
|
||||
########################################
|
||||
# Layer 3 protocol: IPSec
|
||||
@ -139,7 +140,6 @@ host_triplet = @host@
|
||||
@WITH_DPDK_TRUE@am__append_4 = vnet/devices/dpdk/dpdk.h \
|
||||
@WITH_DPDK_TRUE@ vnet/devices/dpdk/threads.h \
|
||||
@WITH_DPDK_TRUE@ vnet/devices/virtio/vhost-user.h
|
||||
noinst_PROGRAMS = vnet_unix$(EXEEXT) pcap2pg$(EXEEXT)
|
||||
@WITH_DPDK_TRUE@am__append_5 = -l:libdpdk.a
|
||||
subdir = .
|
||||
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
|
||||
@ -382,14 +382,6 @@ pcap2pg_DEPENDENCIES = libvnet.la
|
||||
pcap2pg_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(pcap2pg_LDFLAGS) $(LDFLAGS) -o $@
|
||||
am_vnet_unix_OBJECTS = example/main_stub.$(OBJEXT)
|
||||
vnet_unix_OBJECTS = $(am_vnet_unix_OBJECTS)
|
||||
am__DEPENDENCIES_1 =
|
||||
am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
|
||||
vnet_unix_DEPENDENCIES = libvnet.la $(am__DEPENDENCIES_2)
|
||||
vnet_unix_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(vnet_unix_LDFLAGS) $(LDFLAGS) -o $@
|
||||
AM_V_P = $(am__v_P_@AM_V@)
|
||||
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
|
||||
am__v_P_0 = false
|
||||
@ -425,10 +417,9 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
|
||||
am__v_CCLD_0 = @echo " CCLD " $@;
|
||||
am__v_CCLD_1 =
|
||||
SOURCES = $(libvnet_la_SOURCES) $(libvnetplugin_la_SOURCES) \
|
||||
$(pcap2pg_SOURCES) $(vnet_unix_SOURCES)
|
||||
$(pcap2pg_SOURCES)
|
||||
DIST_SOURCES = $(am__libvnet_la_SOURCES_DIST) \
|
||||
$(libvnetplugin_la_SOURCES) $(pcap2pg_SOURCES) \
|
||||
$(vnet_unix_SOURCES)
|
||||
$(libvnetplugin_la_SOURCES) $(pcap2pg_SOURCES)
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
@ -908,12 +899,7 @@ nobase_include_HEADERS = vnet/api_errno.h vnet/buffer.h vnet/config.h \
|
||||
vnet/unix/pcap.h vnet/unix/tuntap.h vnet/unix/tapcli.h \
|
||||
vnet/plugin/plugin.h
|
||||
lib_LTLIBRARIES = libvnet.la libvnetplugin.la
|
||||
vnet_unix_SOURCES = \
|
||||
example/main_stub.c
|
||||
|
||||
vnet_unix_LDFLAGS = -static
|
||||
dpdk_libs = $(am__append_5)
|
||||
vnet_unix_LDADD = libvnet.la -l:libvlib_unix.a -l:libvlib.a -l:libvppinfra.a -lpthread -lvlibapi -lvlibmemory -lsvm -lm -ldl $(dpdk_libs) -lrt
|
||||
pcap2pg_SOURCES = \
|
||||
vnet/unix/pcap2pg.c \
|
||||
vnet/unix/pcap.h
|
||||
@ -1583,22 +1569,9 @@ vnet/unix/pcap2pg.$(OBJEXT): vnet/unix/$(am__dirstamp) \
|
||||
pcap2pg$(EXEEXT): $(pcap2pg_OBJECTS) $(pcap2pg_DEPENDENCIES) $(EXTRA_pcap2pg_DEPENDENCIES)
|
||||
@rm -f pcap2pg$(EXEEXT)
|
||||
$(AM_V_CCLD)$(pcap2pg_LINK) $(pcap2pg_OBJECTS) $(pcap2pg_LDADD) $(LIBS)
|
||||
example/$(am__dirstamp):
|
||||
@$(MKDIR_P) example
|
||||
@: > example/$(am__dirstamp)
|
||||
example/$(DEPDIR)/$(am__dirstamp):
|
||||
@$(MKDIR_P) example/$(DEPDIR)
|
||||
@: > example/$(DEPDIR)/$(am__dirstamp)
|
||||
example/main_stub.$(OBJEXT): example/$(am__dirstamp) \
|
||||
example/$(DEPDIR)/$(am__dirstamp)
|
||||
|
||||
vnet_unix$(EXEEXT): $(vnet_unix_OBJECTS) $(vnet_unix_DEPENDENCIES) $(EXTRA_vnet_unix_DEPENDENCIES)
|
||||
@rm -f vnet_unix$(EXEEXT)
|
||||
$(AM_V_CCLD)$(vnet_unix_LINK) $(vnet_unix_OBJECTS) $(vnet_unix_LDADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
-rm -f example/*.$(OBJEXT)
|
||||
-rm -f vnet/*.$(OBJEXT)
|
||||
-rm -f vnet/*.lo
|
||||
-rm -f vnet/classify/*.$(OBJEXT)
|
||||
@ -1669,7 +1642,6 @@ mostlyclean-compile:
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@example/$(DEPDIR)/main_stub.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@vnet/$(DEPDIR)/config.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@vnet/$(DEPDIR)/interface.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@vnet/$(DEPDIR)/interface_cli.Plo@am__quote@
|
||||
@ -2203,8 +2175,6 @@ clean-generic:
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
-rm -f example/$(DEPDIR)/$(am__dirstamp)
|
||||
-rm -f example/$(am__dirstamp)
|
||||
-rm -f vnet/$(DEPDIR)/$(am__dirstamp)
|
||||
-rm -f vnet/$(am__dirstamp)
|
||||
-rm -f vnet/classify/$(DEPDIR)/$(am__dirstamp)
|
||||
@ -2282,7 +2252,7 @@ clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -rf example/$(DEPDIR) vnet/$(DEPDIR) vnet/classify/$(DEPDIR) vnet/devices/dpdk/$(DEPDIR) vnet/devices/ssvm/$(DEPDIR) vnet/devices/virtio/$(DEPDIR) vnet/dhcp/$(DEPDIR) vnet/dhcpv6/$(DEPDIR) vnet/ethernet/$(DEPDIR) vnet/flow/$(DEPDIR) vnet/gre/$(DEPDIR) vnet/hdlc/$(DEPDIR) vnet/ip/$(DEPDIR) vnet/ipsec/$(DEPDIR) vnet/l2/$(DEPDIR) vnet/l2tp/$(DEPDIR) vnet/lawful-intercept/$(DEPDIR) vnet/lisp-gpe/$(DEPDIR) vnet/llc/$(DEPDIR) vnet/map/$(DEPDIR) vnet/mpls-gre/$(DEPDIR) vnet/nsh-gre/$(DEPDIR) vnet/nsh-vxlan-gpe/$(DEPDIR) vnet/osi/$(DEPDIR) vnet/pg/$(DEPDIR) vnet/plugin/$(DEPDIR) vnet/policer/$(DEPDIR) vnet/ppp/$(DEPDIR) vnet/snap/$(DEPDIR) vnet/sr/$(DEPDIR) vnet/srp/$(DEPDIR) vnet/unix/$(DEPDIR) vnet/vcgn/$(DEPDIR) vnet/vxlan/$(DEPDIR)
|
||||
-rm -rf vnet/$(DEPDIR) vnet/classify/$(DEPDIR) vnet/devices/dpdk/$(DEPDIR) vnet/devices/ssvm/$(DEPDIR) vnet/devices/virtio/$(DEPDIR) vnet/dhcp/$(DEPDIR) vnet/dhcpv6/$(DEPDIR) vnet/ethernet/$(DEPDIR) vnet/flow/$(DEPDIR) vnet/gre/$(DEPDIR) vnet/hdlc/$(DEPDIR) vnet/ip/$(DEPDIR) vnet/ipsec/$(DEPDIR) vnet/l2/$(DEPDIR) vnet/l2tp/$(DEPDIR) vnet/lawful-intercept/$(DEPDIR) vnet/lisp-gpe/$(DEPDIR) vnet/llc/$(DEPDIR) vnet/map/$(DEPDIR) vnet/mpls-gre/$(DEPDIR) vnet/nsh-gre/$(DEPDIR) vnet/nsh-vxlan-gpe/$(DEPDIR) vnet/osi/$(DEPDIR) vnet/pg/$(DEPDIR) vnet/plugin/$(DEPDIR) vnet/policer/$(DEPDIR) vnet/ppp/$(DEPDIR) vnet/snap/$(DEPDIR) vnet/sr/$(DEPDIR) vnet/srp/$(DEPDIR) vnet/unix/$(DEPDIR) vnet/vcgn/$(DEPDIR) vnet/vxlan/$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-libtool distclean-tags
|
||||
@ -2330,7 +2300,7 @@ installcheck-am:
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -rf $(top_srcdir)/autom4te.cache
|
||||
-rm -rf example/$(DEPDIR) vnet/$(DEPDIR) vnet/classify/$(DEPDIR) vnet/devices/dpdk/$(DEPDIR) vnet/devices/ssvm/$(DEPDIR) vnet/devices/virtio/$(DEPDIR) vnet/dhcp/$(DEPDIR) vnet/dhcpv6/$(DEPDIR) vnet/ethernet/$(DEPDIR) vnet/flow/$(DEPDIR) vnet/gre/$(DEPDIR) vnet/hdlc/$(DEPDIR) vnet/ip/$(DEPDIR) vnet/ipsec/$(DEPDIR) vnet/l2/$(DEPDIR) vnet/l2tp/$(DEPDIR) vnet/lawful-intercept/$(DEPDIR) vnet/lisp-gpe/$(DEPDIR) vnet/llc/$(DEPDIR) vnet/map/$(DEPDIR) vnet/mpls-gre/$(DEPDIR) vnet/nsh-gre/$(DEPDIR) vnet/nsh-vxlan-gpe/$(DEPDIR) vnet/osi/$(DEPDIR) vnet/pg/$(DEPDIR) vnet/plugin/$(DEPDIR) vnet/policer/$(DEPDIR) vnet/ppp/$(DEPDIR) vnet/snap/$(DEPDIR) vnet/sr/$(DEPDIR) vnet/srp/$(DEPDIR) vnet/unix/$(DEPDIR) vnet/vcgn/$(DEPDIR) vnet/vxlan/$(DEPDIR)
|
||||
-rm -rf vnet/$(DEPDIR) vnet/classify/$(DEPDIR) vnet/devices/dpdk/$(DEPDIR) vnet/devices/ssvm/$(DEPDIR) vnet/devices/virtio/$(DEPDIR) vnet/dhcp/$(DEPDIR) vnet/dhcpv6/$(DEPDIR) vnet/ethernet/$(DEPDIR) vnet/flow/$(DEPDIR) vnet/gre/$(DEPDIR) vnet/hdlc/$(DEPDIR) vnet/ip/$(DEPDIR) vnet/ipsec/$(DEPDIR) vnet/l2/$(DEPDIR) vnet/l2tp/$(DEPDIR) vnet/lawful-intercept/$(DEPDIR) vnet/lisp-gpe/$(DEPDIR) vnet/llc/$(DEPDIR) vnet/map/$(DEPDIR) vnet/mpls-gre/$(DEPDIR) vnet/nsh-gre/$(DEPDIR) vnet/nsh-vxlan-gpe/$(DEPDIR) vnet/osi/$(DEPDIR) vnet/pg/$(DEPDIR) vnet/plugin/$(DEPDIR) vnet/policer/$(DEPDIR) vnet/ppp/$(DEPDIR) vnet/snap/$(DEPDIR) vnet/sr/$(DEPDIR) vnet/srp/$(DEPDIR) vnet/unix/$(DEPDIR) vnet/vcgn/$(DEPDIR) vnet/vxlan/$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
|
@ -1,203 +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 <vlib/vlib.h>
|
||||
#include <vlib/unix/unix.h>
|
||||
#include <vnet/pg/pg.h>
|
||||
#include <vnet/ethernet/ethernet.h>
|
||||
#include <vnet/ip/ip.h>
|
||||
#include <vnet/ip/tcp.h>
|
||||
|
||||
#include <vlib/unix/cj.h>
|
||||
|
||||
DECLARE_CJ_GLOBAL_LOG
|
||||
|
||||
static clib_error_t *
|
||||
vnet_example_init (vlib_main_t * vm)
|
||||
{
|
||||
clib_error_t * error = 0;
|
||||
|
||||
/* Due to crude comment-out of eliot's smp stuff */
|
||||
vm->heap_size = 256<<20;
|
||||
|
||||
if ((error = vlib_call_init_function (vm, pg_init)))
|
||||
return error;
|
||||
if ((error = vlib_call_init_function (vm, ip_main_init)))
|
||||
return error;
|
||||
if ((error = vlib_call_init_function (vm, ethernet_init)))
|
||||
return error;
|
||||
if ((error = vlib_call_init_function (vm, ethernet_arp_init)))
|
||||
return error;
|
||||
if ((error = vlib_call_init_function (vm, osi_init)))
|
||||
return error;
|
||||
if ((error = vlib_call_init_function (vm, srp_init)))
|
||||
return error;
|
||||
#if DPDK == 0
|
||||
if ((error = vlib_call_init_function (vm, ixge_init)))
|
||||
return error;
|
||||
if ((error = vlib_call_init_function (vm, ixgev_init)))
|
||||
return error;
|
||||
if ((error = vlib_call_init_function (vm, ige_init)))
|
||||
return error;
|
||||
#else
|
||||
if ((error = vlib_call_init_function (vm, dpdk_init)))
|
||||
return error;
|
||||
#endif
|
||||
|
||||
if ((error = vlib_call_init_function (vm, dhcp_proxy_init)))
|
||||
return error;
|
||||
if ((error = vlib_call_init_function (vm, mpls_init)))
|
||||
return error;
|
||||
if ((error = vlib_call_init_function (vm, mpls_interface_init)))
|
||||
return error;
|
||||
|
||||
if ((error = vlib_call_init_function (vm, l2_init)))
|
||||
return error;
|
||||
if ((error = vlib_call_init_function (vm, l2tp_init)))
|
||||
return error;
|
||||
|
||||
if ((error = unix_physmem_init (vm, /* physical_memory_required */ 0)))
|
||||
return error;
|
||||
|
||||
if ((error = unix_physmem_init (vm, /* physical_memory_required */ 0)))
|
||||
return error;
|
||||
|
||||
if ((error = vlib_call_init_function (vm, tuntap_init)))
|
||||
return error;
|
||||
|
||||
vlib_unix_cli_set_prompt ("VNET: ");
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
VLIB_INIT_FUNCTION (vnet_example_init);
|
||||
|
||||
int main (int argc, char * argv[])
|
||||
{
|
||||
clib_mem_init (0, (2ULL << 30));
|
||||
return vlib_unix_main (argc, argv);
|
||||
}
|
||||
|
||||
#if 0
|
||||
#define foreach_tcp_test_error \
|
||||
_ (SEGMENTS_RECEIVED, "segments received")
|
||||
|
||||
typedef enum {
|
||||
#define _(sym,str) TCP_TEST_ERROR_##sym,
|
||||
foreach_tcp_test_error
|
||||
#undef _
|
||||
TCP_TEST_N_ERROR,
|
||||
} tcp_test_error_t;
|
||||
|
||||
static char * tcp_test_error_strings[] = {
|
||||
#define _(sym,string) string,
|
||||
foreach_tcp_test_error
|
||||
#undef _
|
||||
};
|
||||
|
||||
static uword
|
||||
tcp_test (vlib_main_t * vm,
|
||||
vlib_node_runtime_t * node,
|
||||
vlib_frame_t * frame)
|
||||
{
|
||||
uword n_packets = frame->n_vectors;
|
||||
u32 * from, * to_next;
|
||||
u32 n_left_from, n_left_to_next, next;
|
||||
|
||||
from = vlib_frame_vector_args (frame);
|
||||
n_left_from = n_packets;
|
||||
next = node->cached_next_index;
|
||||
|
||||
while (n_left_from > 0)
|
||||
{
|
||||
vlib_get_next_frame (vm, node, next, to_next, n_left_to_next);
|
||||
|
||||
while (n_left_from > 0 && n_left_to_next > 0)
|
||||
{
|
||||
vlib_buffer_t * p0;
|
||||
u32 bi0;
|
||||
u8 error0, next0;
|
||||
|
||||
bi0 = to_next[0] = from[0];
|
||||
|
||||
from += 1;
|
||||
n_left_from -= 1;
|
||||
to_next += 1;
|
||||
n_left_to_next -= 1;
|
||||
|
||||
p0 = vlib_get_buffer (vm, bi0);
|
||||
|
||||
clib_warning ("got '%U'", format_vlib_buffer_contents, vm, p0);
|
||||
|
||||
error0 = next0 = 0;
|
||||
p0->error = node->errors[error0];
|
||||
|
||||
if (PREDICT_FALSE (next0 != next))
|
||||
{
|
||||
to_next -= 1;
|
||||
n_left_to_next += 1;
|
||||
|
||||
vlib_put_next_frame (vm, node, next, n_left_to_next);
|
||||
|
||||
next = next0;
|
||||
vlib_get_next_frame (vm, node, next, to_next, n_left_to_next);
|
||||
to_next[0] = bi0;
|
||||
to_next += 1;
|
||||
n_left_to_next -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
vlib_put_next_frame (vm, node, next, n_left_to_next);
|
||||
}
|
||||
|
||||
return frame->n_vectors;
|
||||
}
|
||||
|
||||
VLIB_REGISTER_NODE (tcp_test_node) = {
|
||||
.function = tcp_test,
|
||||
.name = "tcp-test",
|
||||
|
||||
.vector_size = sizeof (u32),
|
||||
|
||||
.n_next_nodes = 1,
|
||||
.next_nodes = {
|
||||
[0] = "error-drop",
|
||||
},
|
||||
|
||||
.n_errors = TCP_TEST_N_ERROR,
|
||||
.error_strings = tcp_test_error_strings,
|
||||
};
|
||||
|
||||
static clib_error_t *
|
||||
tcp_test_init (vlib_main_t * vm)
|
||||
{
|
||||
clib_error_t * error = 0;
|
||||
|
||||
{
|
||||
tcp_listener_registration_t r = {
|
||||
.port = 1234,
|
||||
.flags = TCP_LISTENER_IP4,
|
||||
.data_node_index = tcp_test_node.index,
|
||||
.event_function = 0,
|
||||
};
|
||||
|
||||
tcp_register_listener (vm, &r);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
VLIB_INIT_FUNCTION (tcp_test_init);
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -291,88 +291,10 @@ VLIB_REGISTER_THREAD (io_thread_reg, static) = {
|
||||
};
|
||||
#endif
|
||||
|
||||
static void vl_api_rpc_call_t_handler (vl_api_rpc_call_t * mp)
|
||||
{
|
||||
vl_api_rpc_reply_t * rmp;
|
||||
int (*fp)(void *);
|
||||
i32 rv = 0;
|
||||
vlib_main_t * vm = vlib_get_main();
|
||||
|
||||
if (mp->function == 0)
|
||||
{
|
||||
rv = -1;
|
||||
clib_warning ("rpc NULL function pointer");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (mp->need_barrier_sync)
|
||||
vlib_worker_thread_barrier_sync (vm);
|
||||
|
||||
fp = (void *)(mp->function);
|
||||
rv = (*fp)(mp->data);
|
||||
|
||||
if (mp->need_barrier_sync)
|
||||
vlib_worker_thread_barrier_release (vm);
|
||||
}
|
||||
|
||||
if (mp->send_reply)
|
||||
{
|
||||
unix_shared_memory_queue_t * q =
|
||||
vl_api_client_index_to_input_queue (mp->client_index);
|
||||
if (q)
|
||||
{
|
||||
rmp = vl_msg_api_alloc_as_if_client (sizeof (*rmp));
|
||||
rmp->_vl_msg_id = ntohs (VL_API_RPC_REPLY);
|
||||
rmp->context = mp->context;
|
||||
rmp->retval = rv;
|
||||
vl_msg_api_send_shmem (q, (u8 *)&rmp);
|
||||
}
|
||||
}
|
||||
if (mp->multicast)
|
||||
{
|
||||
clib_warning ("multicast not yet implemented...");
|
||||
}
|
||||
}
|
||||
|
||||
static void vl_api_rpc_reply_t_handler (vl_api_rpc_reply_t * mp)
|
||||
{ clib_warning ("unimplemented"); }
|
||||
|
||||
void vl_api_rpc_call_main_thread (void *fp, u8 * data, u32 data_length)
|
||||
{
|
||||
vl_api_rpc_call_t * mp;
|
||||
api_main_t *am = &api_main;
|
||||
vl_shmem_hdr_t *shmem_hdr = am->shmem_hdr;
|
||||
|
||||
mp = vl_msg_api_alloc_as_if_client (sizeof (*mp) + data_length);
|
||||
memset (mp, 0, sizeof (*mp));
|
||||
memcpy (mp->data, data, data_length);
|
||||
mp->_vl_msg_id = ntohs (VL_API_RPC_CALL);
|
||||
mp->function = (u64)fp;
|
||||
mp->need_barrier_sync = 1;
|
||||
|
||||
/* Use the "normal" control-plane mechanism for the main thread */
|
||||
vl_msg_api_send_shmem (shmem_hdr->vl_input_queue, (u8 *)&mp);
|
||||
}
|
||||
|
||||
|
||||
#define foreach_rpc_api_msg \
|
||||
_(RPC_CALL,rpc_call) \
|
||||
_(RPC_REPLY,rpc_reply)
|
||||
|
||||
static clib_error_t *
|
||||
rpc_api_hookup (vlib_main_t *vm)
|
||||
dpdk_thread_init (vlib_main_t *vm)
|
||||
{
|
||||
#define _(N,n) \
|
||||
vl_msg_api_set_handlers(VL_API_##N, #n, \
|
||||
vl_api_##n##_t_handler, \
|
||||
vl_noop_handler, \
|
||||
vl_noop_handler, \
|
||||
vl_api_##n##_t_print, \
|
||||
sizeof(vl_api_##n##_t), 0 /* do not trace */);
|
||||
foreach_rpc_api_msg;
|
||||
#undef _
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
VLIB_API_INIT_FUNCTION(rpc_api_hookup);
|
||||
VLIB_INIT_FUNCTION(dpdk_thread_init);
|
||||
|
@ -17,8 +17,6 @@
|
||||
|
||||
#include <vnet/vnet.h>
|
||||
|
||||
void vl_api_rpc_call_main_thread (void *fp, u8 * data, u32 data_length);
|
||||
|
||||
typedef void (*dpdk_worker_thread_callback_t) (vlib_main_t *vm);
|
||||
|
||||
void dpdk_worker_thread (vlib_worker_thread_t * w,
|
||||
|
@ -65,18 +65,11 @@ vpe_main_init (vlib_main_t * vm)
|
||||
if ((error = vlib_call_init_function (vm, lisp_gpe_init)))
|
||||
return error;
|
||||
|
||||
#if DPDK == 0
|
||||
if ((error = vlib_call_init_function (vm, ixge_init)))
|
||||
return error;
|
||||
if ((error = vlib_call_init_function (vm, ixgev_init)))
|
||||
return error;
|
||||
if ((error = vlib_call_init_function (vm, ige_init)))
|
||||
return error;
|
||||
if ((error = vlib_call_init_function (vm, vice_init)))
|
||||
return error;
|
||||
#else
|
||||
#if DPDK == 1
|
||||
if ((error = vlib_call_init_function (vm, dpdk_init)))
|
||||
return error;
|
||||
if ((error = vlib_call_init_function (vm, dpdk_thread_init)))
|
||||
return error;
|
||||
if ((error = vlib_call_init_function (vm, vhost_user_init)))
|
||||
return error;
|
||||
if ((error = vlib_call_init_function (vm, ipsec_init)))
|
||||
|
Reference in New Issue
Block a user