Add option to link DPDK dynamically

Change-Id: Ie2b47f9020c8260b199d141103318a0261e16832
Signed-off-by: Damjan Marion <damarion@cisco.com>
This commit is contained in:
Damjan Marion
2016-04-01 12:34:24 +02:00
parent 102ec52bc4
commit aa04a0ff8e
5 changed files with 117 additions and 79 deletions

View File

@ -575,4 +575,87 @@ format_function_t format_dpdk_rte_mbuf;
format_function_t format_dpdk_rx_rte_mbuf;
unformat_function_t unformat_socket_mem;
static inline void
dpdk_pmd_constructor_init()
{
/* Add references to DPDK Driver Constructor functions to get the dynamic
* loader to pull in the driver library & run the constructors.
*/
#define _(d) \
do { \
void devinitfn_ ##d(void); \
__attribute__((unused)) void (* volatile pf)(void); \
pf = devinitfn_ ##d; \
} while(0);
#ifdef RTE_LIBRTE_EM_PMD
_(em_pmd_drv)
#endif
#ifdef RTE_LIBRTE_IGB_PMD
_(pmd_igb_drv)
#endif
#ifdef RTE_LIBRTE_IXGBE_PMD
_(rte_ixgbe_driver)
#endif
#ifdef RTE_LIBRTE_I40E_PMD
_(rte_i40e_driver)
_(rte_i40evf_driver)
#endif
#ifdef RTE_LIBRTE_FM10K_PMD
_(rte_fm10k_driver)
#endif
#ifdef RTE_LIBRTE_VIRTIO_PMD
_(rte_virtio_driver)
#endif
#ifdef RTE_LIBRTE_VMXNET3_PMD
_(rte_vmxnet3_driver)
#endif
#ifdef RTE_LIBRTE_VICE_PMD
_(rte_vice_driver)
#endif
#ifdef RTE_LIBRTE_ENIC_PMD
_(rte_enic_driver)
#endif
#ifdef RTE_LIBRTE_PMD_AF_PACKET
_(pmd_af_packet_drv)
#endif
#ifdef RTE_LIBRTE_CXGBE_PMD
_(rte_cxgbe_driver)
#endif
#ifdef RTE_LIBRTE_PMD_BOND
_(bond_drv)
#endif
#undef _
/*
* At the moment, the ThunderX NIC driver doesn't have
* an entry point named "devinitfn_rte_xxx_driver"
*/
#define _(d) \
do { \
void d(void); \
__attribute__((unused)) void (* volatile pf)(void); \
pf = d; \
} while(0);
#ifdef RTE_LIBRTE_THUNDERVNIC_PMD
_(rte_nicvf_pmd_init)
#endif
#undef _
}
#endif /* __included_dpdk_h__ */

View File

@ -1720,83 +1720,6 @@ dpdk_init (vlib_main_t * vm)
ASSERT(offsetof(dpdk_worker_t, cacheline0) == 0);
ASSERT(offsetof(frame_queue_trace_t, cacheline0) == 0);
/* Add references to DPDK Driver Constructor functions to get the dynamic
* loader to pull in the driver library & run the constructors.
*/
#define _(d) \
do { \
void devinitfn_ ##d(void); \
__attribute__((unused)) void (* volatile pf)(void); \
pf = devinitfn_ ##d; \
} while(0);
#ifdef RTE_LIBRTE_EM_PMD
_(em_pmd_drv)
#endif
#ifdef RTE_LIBRTE_IGB_PMD
_(pmd_igb_drv)
#endif
#ifdef RTE_LIBRTE_IXGBE_PMD
_(rte_ixgbe_driver)
#endif
#ifdef RTE_LIBRTE_I40E_PMD
_(rte_i40e_driver)
_(rte_i40evf_driver)
#endif
#ifdef RTE_LIBRTE_FM10K_PMD
_(rte_fm10k_driver)
#endif
#ifdef RTE_LIBRTE_VIRTIO_PMD
_(rte_virtio_driver)
#endif
#ifdef RTE_LIBRTE_VMXNET3_PMD
_(rte_vmxnet3_driver)
#endif
#ifdef RTE_LIBRTE_VICE_PMD
_(rte_vice_driver)
#endif
#ifdef RTE_LIBRTE_ENIC_PMD
_(rte_enic_driver)
#endif
#ifdef RTE_LIBRTE_PMD_AF_PACKET
_(pmd_af_packet_drv)
#endif
#ifdef RTE_LIBRTE_CXGBE_PMD
_(rte_cxgbe_driver)
#endif
#ifdef RTE_LIBRTE_PMD_BOND
_(bond_drv)
#endif
#undef _
/*
* At the moment, the ThunderX NIC driver doesn't have
* an entry point named "devinitfn_rte_xxx_driver"
*/
#define _(d) \
do { \
void d(void); \
__attribute__((unused)) void (* volatile pf)(void); \
pf = d; \
} while(0);
#ifdef RTE_LIBRTE_THUNDERVNIC_PMD
_(rte_nicvf_pmd_init)
#endif
#undef _
dm->vlib_main = vm;
dm->vnet_main = vnet_get_main();

View File

@ -71,8 +71,12 @@ vpp_LDADD += -lsvm -lsvmdb -lrt
vpp_LDADD += -lvnetplugin
if WITH_DPDK
if ENABLE_DPDK_SHARED
vpp_LDADD += -ldpdk
else
vpp_LDADD += -l:libdpdk.a
endif
endif
vpp_LDADD += -lvppinfra -lm -lpthread -ldl

View File

@ -11,6 +11,11 @@ AC_ARG_WITH(dpdk,
[with_dpdk=1],
[with_dpdk=0])
AC_ARG_ENABLE(dpdk-shared,
AC_HELP_STRING([--enable-dpdk-shared],[Link with DPDK shared lib]),
[enable_dpdk_shared=1],
[enable_dpdk_shared=0])
AC_ARG_WITH(ipsec,
AC_HELP_STRING([--without-ipsec],[Disable ipsec]),
[with_ipsec=0],
@ -27,7 +32,22 @@ AC_ARG_WITH(ipv6sr,
[with_ipv6sr=1])
AM_CONDITIONAL(WITH_DPDK, test "$with_dpdk" = "1")
AC_SUBST(DPDK,[-DDPDK=${with_dpdk}])
AM_CONDITIONAL(ENABLE_DPDK_SHARED, test "$enable_dpdk_shared" = "1")
AC_SUBST(DPDK,["-DDPDK=${with_dpdk} -DDPDK_SHARED_LIB=${enable_dpdk_shared}"])
AM_COND_IF(
[ENABLE_DPDK_SHARED],
[
AC_CHECK_HEADERS(
[rte_config.h],
[], [AC_MSG_ERROR([DPDK header files not found])],
)
AC_CHECK_LIB(
[dpdk], [rte_eal_init],
[], [AC_MSG_ERROR([DPDK shared library not found])],
)
],
)
AM_CONDITIONAL(WITH_IPSEC, test "$with_ipsec" = "1")
AC_SUBST(IPSEC,[-DIPSEC=${with_ipsec}])

View File

@ -19,6 +19,10 @@
#include <api/vpe_msg_enum.h>
#if DPDK
#include <vnet/devices/dpdk/dpdk.h>
#endif
/** \mainpage Virtual Packet Edge Documentation
* \section intro_sec Introduction
*
@ -197,7 +201,11 @@ defaulted:
if (clib_mem_init (0, main_heap_size)) {
vm->init_functions_called = hash_create (0, /* value bytes */ 0);
vpe_main_init(vm);
#if ! DPDK
#if DPDK
#if !DPDK_SHARED_LIB
dpdk_pmd_constructor_init();
#endif
#else
unix_physmem_init(vm, 0 /* fail_if_physical_memory_not_present */);
#endif
vlib_set_get_handoff_structure_cb (&vnet_get_handoff_structure);