* [dpdk-dev] [PATCH 0/3] pcap build fixes
@ 2013-11-22 10:24 David Marchand
2013-11-22 10:24 ` [dpdk-dev] [PATCH 1/3] pcap: use pcap-config to guess compilation flags David Marchand
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: David Marchand @ 2013-11-22 10:24 UTC (permalink / raw)
To: dev
Fix build with old pcap library.
Make it possible to specify which pcap library to use.
David Marchand (3):
pcap: use pcap-config to guess compilation flags
pcap: fix build with old libpcap
pcap: fix build when pcap_sendpacket is unavailable
app/test-pmd/Makefile | 4 ----
doc/build-sdk-quick.txt | 2 ++
lib/librte_pmd_pcap/rte_eth_pcap.c | 12 ++++++++++++
lib/librte_pmd_pcap/rte_eth_pcap.h | 8 +++++++-
mk/rte.app.mk | 5 ++++-
mk/rte.sdkbuild.mk | 8 ++++++++
mk/target/generic/rte.vars.mk | 2 +-
7 files changed, 34 insertions(+), 7 deletions(-)
--
1.7.10.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-dev] [PATCH 1/3] pcap: use pcap-config to guess compilation flags
2013-11-22 10:24 [dpdk-dev] [PATCH 0/3] pcap build fixes David Marchand
@ 2013-11-22 10:24 ` David Marchand
2013-11-22 10:24 ` [dpdk-dev] [PATCH 2/3] pcap: fix build with old libpcap David Marchand
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: David Marchand @ 2013-11-22 10:24 UTC (permalink / raw)
To: dev
Use pcap-config to populate CFLAGS and LDFLAGS.
LIBPCAP_CFLAGS and LIBPCAP_LDFLAGS can be used to override this (useful when
cross-compiling).
Signed-off-by: David Marchand <david.marchand@6wind.com>
---
app/test-pmd/Makefile | 4 ----
doc/build-sdk-quick.txt | 2 ++
mk/rte.app.mk | 5 ++++-
mk/rte.sdkbuild.mk | 8 ++++++++
mk/target/generic/rte.vars.mk | 2 +-
5 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile
index cd04ea5..2ced595 100644
--- a/app/test-pmd/Makefile
+++ b/app/test-pmd/Makefile
@@ -39,10 +39,6 @@ APP = testpmd
CFLAGS += -O3
CFLAGS += $(WERROR_FLAGS)
-ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y)
-LDFLAGS += -lpcap
-endif
-
#
# all source are stored in SRCS-y
#
diff --git a/doc/build-sdk-quick.txt b/doc/build-sdk-quick.txt
index 18b0ee6..ca39c33 100644
--- a/doc/build-sdk-quick.txt
+++ b/doc/build-sdk-quick.txt
@@ -11,6 +11,8 @@ Build variables
EXTRA_CPPFLAGS preprocessor options
EXTRA_CFLAGS compiler options
EXTRA_LDFLAGS linker options
+ LIBPCAP_CFLAGS libpcap compiler options
+ LIBPCAP_LDFLAGS libpcap linker options
CROSS toolchain prefix
V verbose
D debug dependencies
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index d2ce5c0..9420f24 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -150,7 +150,10 @@ LDLIBS += -lrte_eal
endif
ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y)
-LDLIBS += -lrte_pmd_pcap -lpcap
+LDLIBS += -lrte_pmd_pcap
+LIBPCAP_LDFLAGS ?= $(shell pcap-config --libs)
+$(if $(LIBPCAP_LDFLAGS),,$(error LIBPCAP_LDFLAGS is undefined))
+LDLIBS += $(LIBPCAP_LDFLAGS)
endif
LDLIBS += $(EXECENV_LDLIBS)
diff --git a/mk/rte.sdkbuild.mk b/mk/rte.sdkbuild.mk
index 0dc23ff..33bed57 100644
--- a/mk/rte.sdkbuild.mk
+++ b/mk/rte.sdkbuild.mk
@@ -40,6 +40,14 @@ else
include $(RTE_SDK)/mk/rte.vars.mk
endif
+ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y)
+LIBPCAP_CFLAGS ?= $(shell pcap-config --cflags)
+$(if $(LIBPCAP_CFLAGS),,$(error LIBPCAP_CFLAGS is undefined))
+EXTERNAL_LIB_CFLAGS += $(LIBPCAP_CFLAGS)
+endif
+
+export EXTERNAL_LIB_CFLAGS
+
#
# include .depdirs and define rules to order priorities between build
# of directories.
diff --git a/mk/target/generic/rte.vars.mk b/mk/target/generic/rte.vars.mk
index 9030f44..22893fc 100644
--- a/mk/target/generic/rte.vars.mk
+++ b/mk/target/generic/rte.vars.mk
@@ -104,7 +104,7 @@ ifeq ($(KERNELRELEASE),)
# merge all CFLAGS
CFLAGS := $(CPU_CFLAGS) $(EXECENV_CFLAGS) $(TOOLCHAIN_CFLAGS) $(MACHINE_CFLAGS)
-CFLAGS += $(TARGET_CFLAGS)
+CFLAGS += $(TARGET_CFLAGS) $(EXTERNAL_LIB_CFLAGS)
# merge all LDFLAGS
LDFLAGS := $(CPU_LDFLAGS) $(EXECENV_LDFLAGS) $(TOOLCHAIN_LDFLAGS) $(MACHINE_LDFLAGS)
--
1.7.10.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-dev] [PATCH 2/3] pcap: fix build with old libpcap
2013-11-22 10:24 [dpdk-dev] [PATCH 0/3] pcap build fixes David Marchand
2013-11-22 10:24 ` [dpdk-dev] [PATCH 1/3] pcap: use pcap-config to guess compilation flags David Marchand
@ 2013-11-22 10:24 ` David Marchand
2013-11-22 10:24 ` [dpdk-dev] [PATCH 3/3] pcap: fix build when pcap_sendpacket is unavailable David Marchand
2013-11-22 12:38 ` [dpdk-dev] [PATCH 0/3] pcap build fixes Thomas Monjalon
3 siblings, 0 replies; 5+ messages in thread
From: David Marchand @ 2013-11-22 10:24 UTC (permalink / raw)
To: dev
For backwards compatibility, pcap.h includes pcap/pcap.h.
Hence, to be compatible with older pcap libraries, we must include pcap.h.
Signed-off-by: David Marchand <david.marchand@6wind.com>
---
lib/librte_pmd_pcap/rte_eth_pcap.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.h b/lib/librte_pmd_pcap/rte_eth_pcap.h
index 7ed68b1..a1bd513 100644
--- a/lib/librte_pmd_pcap/rte_eth_pcap.h
+++ b/lib/librte_pmd_pcap/rte_eth_pcap.h
@@ -37,7 +37,7 @@
#ifdef __cplusplus
extern "C" {
#endif
-#include <pcap/pcap.h>
+#include <pcap.h>
#define RTE_ETH_PCAP_PARAM_NAME "eth_pcap"
--
1.7.10.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-dev] [PATCH 3/3] pcap: fix build when pcap_sendpacket is unavailable
2013-11-22 10:24 [dpdk-dev] [PATCH 0/3] pcap build fixes David Marchand
2013-11-22 10:24 ` [dpdk-dev] [PATCH 1/3] pcap: use pcap-config to guess compilation flags David Marchand
2013-11-22 10:24 ` [dpdk-dev] [PATCH 2/3] pcap: fix build with old libpcap David Marchand
@ 2013-11-22 10:24 ` David Marchand
2013-11-22 12:38 ` [dpdk-dev] [PATCH 0/3] pcap build fixes Thomas Monjalon
3 siblings, 0 replies; 5+ messages in thread
From: David Marchand @ 2013-11-22 10:24 UTC (permalink / raw)
To: dev
Before libpcap 1.0.0, pcap_sendpacket was not available on linux targets (unless
backported).
When using such a library, we won't be able to send packet on the wire, yet we
can still dump packets into a pcap file.
Signed-off-by: David Marchand <david.marchand@6wind.com>
---
lib/librte_pmd_pcap/rte_eth_pcap.c | 12 ++++++++++++
lib/librte_pmd_pcap/rte_eth_pcap.h | 6 ++++++
2 files changed, 18 insertions(+)
diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c b/lib/librte_pmd_pcap/rte_eth_pcap.c
index 50de885..19d19b3 100644
--- a/lib/librte_pmd_pcap/rte_eth_pcap.c
+++ b/lib/librte_pmd_pcap/rte_eth_pcap.c
@@ -199,6 +199,7 @@ eth_pcap_tx_dumper(void *queue,
return num_tx;
}
+#ifdef PCAP_CAN_SEND
/*
* Callback to handle sending packets through a real NIC.
*/
@@ -229,6 +230,17 @@ eth_pcap_tx(void *queue,
tx_queue->err_pkts += nb_pkts - num_tx;
return num_tx;
}
+#else
+static uint16_t
+eth_pcap_tx(__rte_unused void *queue,
+ __rte_unused struct rte_mbuf **bufs,
+ __rte_unused uint16_t nb_pkts)
+{
+ RTE_LOG(ERR, PMD, "pcap library cannot send packets, please rebuild "
+ "with a more up to date libpcap\n");
+ return -1;
+}
+#endif
static int
eth_dev_start(struct rte_eth_dev *dev)
diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.h b/lib/librte_pmd_pcap/rte_eth_pcap.h
index a1bd513..368ed88 100644
--- a/lib/librte_pmd_pcap/rte_eth_pcap.h
+++ b/lib/librte_pmd_pcap/rte_eth_pcap.h
@@ -39,6 +39,12 @@ extern "C" {
#endif
#include <pcap.h>
+#ifdef pcap_sendpacket
+#define PCAP_CAN_SEND
+#else
+#undef PCAP_CAN_SEND
+#endif
+
#define RTE_ETH_PCAP_PARAM_NAME "eth_pcap"
int rte_eth_from_pcaps(pcap_t * const rx_queues[],
--
1.7.10.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH 0/3] pcap build fixes
2013-11-22 10:24 [dpdk-dev] [PATCH 0/3] pcap build fixes David Marchand
` (2 preceding siblings ...)
2013-11-22 10:24 ` [dpdk-dev] [PATCH 3/3] pcap: fix build when pcap_sendpacket is unavailable David Marchand
@ 2013-11-22 12:38 ` Thomas Monjalon
3 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2013-11-22 12:38 UTC (permalink / raw)
To: David Marchand; +Cc: dev
22/11/2013 11:24, David Marchand :
> Fix build with old pcap library.
> Make it possible to specify which pcap library to use.
>
> David Marchand (3):
> pcap: use pcap-config to guess compilation flags
> pcap: fix build with old libpcap
> pcap: fix build when pcap_sendpacket is unavailable
Acked and applied.
Thanks
--
Thomas
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-11-22 12:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-22 10:24 [dpdk-dev] [PATCH 0/3] pcap build fixes David Marchand
2013-11-22 10:24 ` [dpdk-dev] [PATCH 1/3] pcap: use pcap-config to guess compilation flags David Marchand
2013-11-22 10:24 ` [dpdk-dev] [PATCH 2/3] pcap: fix build with old libpcap David Marchand
2013-11-22 10:24 ` [dpdk-dev] [PATCH 3/3] pcap: fix build when pcap_sendpacket is unavailable David Marchand
2013-11-22 12:38 ` [dpdk-dev] [PATCH 0/3] pcap build fixes Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).