set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${dpdk_LIBRARIES})
set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-dpdk.c)
set(PCAP_SUPPORT_DPDK TRUE)
+
+ #
+ # Check whether the rte_ether.h file defines
+ # struct ether_addr or struct rte_ether_addr.
+ #
+ # ("API compatibility? That's for losers!")
+ #
+ cmake_push_check_state()
+ set(CMAKE_REQUIRED_INCLUDES ${dpdk_INCLUDE_DIRS})
+ set(CMAKE_EXTRA_INCLUDE_FILES rte_ether.h)
+ check_type_size("struct rte_ether_addr" STRUCT_RTE_ETHER_ADDR)
+ cmake_pop_check_state()
endif()
endif()
endif()
/* Define to 1 if `msg_flags' is a member of `struct msghdr'. */
#cmakedefine HAVE_STRUCT_MSGHDR_MSG_FLAGS 1
+/* Define to 1 if the system has the type `struct rte_ether_addr'. */
+#cmakedefine HAVE_STRUCT_RTE_ETHER_ADDR 1
+
/* Define to 1 if `hci_channel' is a member of `struct sockaddr_hci'. */
#cmakedefine HAVE_STRUCT_SOCKADDR_HCI_HCI_CHANNEL 1
/* Define to 1 if `msg_flags' is a member of `struct msghdr'. */
#undef HAVE_STRUCT_MSGHDR_MSG_FLAGS
+/* Define to 1 if the system has the type `struct rte_ether_addr'. */
+#undef HAVE_STRUCT_RTE_ETHER_ADDR
+
/* Define to 1 if `hci_channel' is a member of `struct sockaddr_hci'. */
#undef HAVE_STRUCT_SOCKADDR_HCI_HCI_CHANNEL
if test $V_PCAP != dpdk ; then
MODULE_C_SRC="$MODULE_C_SRC pcap-dpdk.c"
fi
+
+ #
+ # Check whether the rte_ether.h file defines
+ # struct ether_addr or struct rte_ether_addr.
+ #
+ # ("API compatibility? That's for losers!")
+ #
+ ac_fn_c_check_type "$LINENO" "struct rte_ether_addr" "ac_cv_type_struct_rte_ether_addr" "
+ #include <rte_ether.h>
+
+"
+if test "x$ac_cv_type_struct_rte_ether_addr" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_RTE_ETHER_ADDR 1
+_ACEOF
+
+
+fi
+
else
if test "$V_PCAP" = dpdk; then
# User requested DPDK-only capture support, but
if test $V_PCAP != dpdk ; then
MODULE_C_SRC="$MODULE_C_SRC pcap-dpdk.c"
fi
+
+ #
+ # Check whether the rte_ether.h file defines
+ # struct ether_addr or struct rte_ether_addr.
+ #
+ # ("API compatibility? That's for losers!")
+ #
+ AC_CHECK_TYPES(struct rte_ether_addr,,,
+ [
+ #include <rte_ether.h>
+ ])
else
if test "$V_PCAP" = dpdk; then
# User requested DPDK-only capture support, but
#include "pcap-int.h"
#include "pcap-dpdk.h"
+/*
+ * Deal with API changes that break source compatibility.
+ */
+
+#ifdef HAVE_STRUCT_RTE_ETHER_ADDR
+#define ETHER_ADDR_TYPE struct rte_ether_addr
+#else
+#define ETHER_ADDR_TYPE struct ether_addr
+#endif
+
#define DPDK_DEF_LOG_LEV RTE_LOG_ERR
//
// This is set to 0 if we haven't initialized DPDK yet, 1 if we've
static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT;
static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;
+#ifdef RTE_ETHER_MAX_JUMBO_FRAME_LEN
+#define RTE_ETH_PCAP_SNAPLEN RTE_ETHER_MAX_JUMBO_FRAME_LEN
+#else
#define RTE_ETH_PCAP_SNAPLEN ETHER_MAX_JUMBO_FRAME_LEN
+#endif
static struct rte_eth_dev_tx_buffer *tx_buffer;
uint64_t bps;
struct rte_mempool * pktmbuf_pool;
struct dpdk_ts_helper ts_helper;
- struct ether_addr eth_addr;
+ ETHER_ADDR_TYPE eth_addr;
char mac_addr[DPDK_MAC_ADDR_SIZE];
char pci_addr[DPDK_PCI_ADDR_SIZE];
unsigned char pcap_tmp_buf[RTE_ETH_PCAP_SNAPLEN];
bp = rte_pktmbuf_mtod(m, u_char *);
}else{
// use fast buffer pcap_tmp_buf if pkt_len is small, no need to call malloc and free
- if ( pkt_len <= ETHER_MAX_JUMBO_FRAME_LEN)
+ if ( pkt_len <= RTE_ETH_PCAP_SNAPLEN)
{
gather_len = dpdk_gather_data(pd->pcap_tmp_buf, RTE_ETH_PCAP_SNAPLEN, m);
bp = pd->pcap_tmp_buf;
rte_eth_link_get(portid, plink);
return plink->link_status == ETH_LINK_UP;
}
-static void eth_addr_str(struct ether_addr *addrp, char* mac_str, int len)
+static void eth_addr_str(ETHER_ADDR_TYPE *addrp, char* mac_str, int len)
{
int offset=0;
if (addrp == NULL){
unsigned int nb_ports = 0;
char dpdk_name[DPDK_DEV_NAME_MAX];
char dpdk_desc[DPDK_DEV_DESC_MAX];
- struct ether_addr eth_addr;
+ ETHER_ADDR_TYPE eth_addr;
char mac_addr[DPDK_MAC_ADDR_SIZE];
char pci_addr[DPDK_PCI_ADDR_SIZE];
do{