aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohammad Abdul Awal <mohammad.abdul.awal@intel.com>2016-09-06 16:58:57 +0100
committerMohammad Abdul Awal <mohammad.abdul.awal@intel.com>2016-09-09 16:42:15 +0100
commit55aba2fc5df4dbff80c3eb5c38b0b965cd826936 (patch)
treec73492caacc957f21b5cf5f01ee7687e1e8a9949
parent8ae38dfb285ab9843312964b3081b2c52ba857dc (diff)
makefile: allow using DPDK from git and OS distributions
User can use DPDK_VERSION to download a specific DPDK version from git. If no DPDK_VERSION is given, the master branch will be downloaded. User can also provide RTE_SDK path for DPDK from OS disctibution or any other location. Change-Id: I7bbc30984cfc48c70d13b51d8fb6c1928d94a821 Signed-off-by: Mohammad Abdul Awal <mohammad.abdul.awal@intel.com>
-rw-r--r--Makefile7
-rw-r--r--dpdk/Makefile55
-rw-r--r--examples/udpfwd/dpdk_version.h33
-rw-r--r--examples/udpfwd/main.c149
-rw-r--r--examples/udpfwd/main_dpdk_legacy.h176
-rw-r--r--examples/udpfwd/pkt.c107
-rw-r--r--examples/udpfwd/pkt_dpdk_legacy.h145
7 files changed, 386 insertions, 286 deletions
diff --git a/Makefile b/Makefile
index 072b466..474ada6 100644
--- a/Makefile
+++ b/Makefile
@@ -14,14 +14,12 @@
TLDK_ROOT := $(CURDIR)
export TLDK_ROOT
-DPDK_VERSION=16.04
-LOCAL_RTE_SDK=$(TLDK_ROOT)/dpdk/_build/dpdk-$(DPDK_VERSION)/
+LOCAL_RTE_SDK=$(TLDK_ROOT)/dpdk/_build/dpdk
ifeq ($(RTE_SDK),)
export RTE_SDK=$(LOCAL_RTE_SDK)
endif
-# Default target, can be overriden by command line or environment
RTE_TARGET ?= x86_64-native-linuxapp-gcc
DIRS-y += lib
@@ -53,7 +51,6 @@ $(DIRS-y): $(RTE_SDK)/mk/rte.vars.mk
$(filter-out $(DIRS-y),$(MAKECMDGOALS))
$(RTE_SDK)/mk/rte.vars.mk:
-ifeq ($(RTE_SDK),$(LOCAL_RTE_SDK))
+ifeq ($(RTE_SDK),$(LOCAL_RTE_SDK))
@make RTE_TARGET=$(RTE_TARGET) config all -C $(TLDK_ROOT)/dpdk/
endif
-
diff --git a/dpdk/Makefile b/dpdk/Makefile
index 7653a4e..5613d8e 100644
--- a/dpdk/Makefile
+++ b/dpdk/Makefile
@@ -16,22 +16,16 @@ SHELL := /bin/bash
DPDK_VERSION ?= 16.04
DPDK_BUILD_DIR ?= $(CURDIR)/_build
-DPDK_INSTALL_DIR ?= $(DPDK_BUILD_DIR)/dpdk-$(DPDK_VERSION)/$(RTE_TARGET)
+DPDK_INSTALL_DIR ?= $(DPDK_BUILD_DIR)/dpdk/$(RTE_TARGET)
DPDK_PKTMBUF_HEADROOM ?= 128
-DPDK_DOWNLOAD_DIR ?= $(HOME)/Downloads
DPDK_MARCH ?= native
DPDK_TUNE ?= generic
DPDK_DEBUG ?= n
B := $(DPDK_BUILD_DIR)
I := $(DPDK_INSTALL_DIR)
-DPDK_BASE_URL ?= https://nexus.fd.io/content/repositories/thirdparty/
-DPDK_TARBALL := dpdk-$(DPDK_VERSION).tar.gz
-DPDK_TAR_URL := $(DPDK_BASE_URL)/$(DPDK_TARBALL)
-DPDK_2.1.0_TARBALL_MD5_CKSUM := 205a0d12bfd6eb717d57506272f43519
-DPDK_2.2.0_TARBALL_MD5_CKSUM := 22e2fd68cd5504f43fe9a5a6fd6dd938
-DPDK_16.04_TARBALL_MD5_CKSUM := 0728d506d7f56eb64233e824fa3c098a
-DPDK_SOURCE := $(B)/dpdk-$(DPDK_VERSION)
+DPDK_GIT_REPO ?= http://dpdk.org/git/dpdk
+DPDK_SOURCE := $(B)/dpdk
ifneq (,$(findstring clang,$(CC)))
DPDK_CC=clang
@@ -39,7 +33,6 @@ else
DPDK_CC=gcc
endif
-
ifeq (,$(DPDK_TARGET))
DPDK_TARGET := x86_64-native-linuxapp-$(DPDK_CC)
endif
@@ -87,7 +80,8 @@ DPDK_MAKE_ARGS := -C $(DPDK_SOURCE) -j $(JOBS) \
CPU_LDFLAGS="$(DPDK_CPU_LDFLAGS)" \
$(DPDK_MAKE_EXTRA_ARGS)
-DPDK_SOURCE_FILES := $(shell [ -e $(DPDK_SOURCE) ] && find $(DPDK_SOURCE) -name "*.[chS]")
+DPDK_SOURCE_FILES := $(shell [ -e $(DPDK_SOURCE) ] && \
+ find $(DPDK_SOURCE) -name "*.[chS]")
define set
@if grep -q CONFIG_$1 $@ ; \
@@ -99,8 +93,10 @@ endef
all: build
$(B)/custom-config: $(B)/.patch.ok Makefile
- @echo --- generating custom config from $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) ---
- @cpp -undef -ffreestanding -x assembler-with-cpp $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) $@
+ @echo --- generating custom config from \
+ $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) --- $@
+ @cpp -undef -ffreestanding -x assembler-with-cpp \
+ $(DPDK_SOURCE)/config/defconfig_$(DPDK_TARGET) $@
$(call set,RTE_MACHINE,$(DPDK_MACHINE))
@# modify options
$(call set,RTE_MAX_LCORE,256)
@@ -131,33 +127,22 @@ $(B)/custom-config: $(B)/.patch.ok Makefile
$(call set,RTE_KNI_KMOD,n)
@rm -f .config.ok
-$(CURDIR)/$(DPDK_TARBALL):
+$(B)/.download.ok:
@mkdir -p $(B)
- @if [ -e $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) ] ; \
- then cp $(DPDK_DOWNLOAD_DIR)/$(DPDK_TARBALL) $(CURDIR) ; \
- else curl -o $(CURDIR)/$(DPDK_TARBALL) -LO $(DPDK_TAR_URL) ; \
+ @if [ -e $(DPDK_SOURCE) ] ; \
+ then rm -rf $(DPDK_SOURCE) ; \
fi
- @rm -f $(B)/.download.ok
-
-$(B)/.download.ok: $(CURDIR)/$(DPDK_TARBALL)
- @openssl md5 $< | cut -f 2 -d " " - > $(B)/$(DPDK_TARBALL).md5sum
- @([ "$$(<$(B)/$(DPDK_TARBALL).md5sum)" = "$(DPDK_$(DPDK_VERSION)_TARBALL_MD5_CKSUM)" ] || \
- ( echo "Bad Checksum! Please remove $< and retry" && \
- rm $(B)/$(DPDK_TARBALL).md5sum && false ))
+ifeq ($(DPDK_VERSION),master)
+ @git clone $(DPDK_GIT_REPO) --branch $(DPDK_VERSION) $(DPDK_SOURCE)
+else
+ @git clone $(DPDK_GIT_REPO) --branch v$(DPDK_VERSION) $(DPDK_SOURCE)
+endif
@touch $@
.PHONY: download
download: $(B)/.download.ok
-$(B)/.extract.ok: $(B)/.download.ok
- @echo --- extracting $(DPDK_TARBALL) ---
- @tar --directory $(B) --extract --file $(CURDIR)/$(DPDK_TARBALL) --gzip
- @touch $@
-
-.PHONY: extract
-extract: $(B)/.extract.ok
-
-$(B)/.patch.ok: $(B)/.extract.ok
+$(B)/.patch.ok: $(B)/.download.ok
ifneq ($(wildcard $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch),)
@echo --- patching ---
for f in $(CURDIR)/dpdk-$(DPDK_VERSION)_patches/*.patch ; do \
@@ -178,7 +163,8 @@ $(B)/.config.ok: $(B)/.patch.ok $(B)/custom-config
config: $(B)/.config.ok
$(B)/.build.ok: $(DPDK_SOURCE_FILES)
- @if [ ! -e $(B)/.config.ok ] ; then echo 'Please run "make config" first' && false ; fi
+ @if [ ! -e $(B)/.config.ok ] ; then echo 'Please run "make config" \
+ first' && false ; fi
@make $(DPDK_MAKE_ARGS) install
@cp $(I)/.config $(B)/.config
@touch $@
@@ -189,4 +175,3 @@ build: $(B)/.build.ok
.PHONY: clean
clean:
@rm -rf $(B) $(I)
-
diff --git a/examples/udpfwd/dpdk_version.h b/examples/udpfwd/dpdk_version.h
new file mode 100644
index 0000000..1d2f837
--- /dev/null
+++ b/examples/udpfwd/dpdk_version.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2016 Intel Corporation.
+ * 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 DPDK_VERSION_H_
+#define DPDK_VERSION_H_
+
+#include <rte_version.h>
+
+#ifdef RTE_VER_MAJOR
+#if RTE_VER_MAJOR >= 16 && RTE_VER_MINOR >= 4
+#define DPDK_VERSION_GE_1604
+#endif
+#elif defined(RTE_VER_YEAR)
+#if RTE_VER_YEAR >= 16 && RTE_VER_MONTH >= 4
+#define DPDK_VERSION_GE_1604
+#endif
+#else
+#error "RTE_VER_MAJOR and RTE_VER_YEAR are undefined!"
+#endif
+
+#endif /* DPDK_VERSION_H_ */
diff --git a/examples/udpfwd/main.c b/examples/udpfwd/main.c
index 3daeb30..96150b0 100644
--- a/examples/udpfwd/main.c
+++ b/examples/udpfwd/main.c
@@ -116,6 +116,7 @@ static const struct rte_eth_conf port_conf_default = {
};
#include "parse.h"
+#include "main_dpdk_legacy.h"
static void
sig_handle(int signum)
@@ -580,29 +581,6 @@ netbe_port_init(struct netbe_cfg *cfg, int argc, char *argv[])
}
/*
- * UDP IPv4 destination lookup callback.
- */
-static int
-lpm4_dst_lookup(void *data, const struct in_addr *addr,
- struct tle_udp_dest *res)
-{
- int32_t rc;
- uint32_t idx;
- struct netbe_lcore *lc;
- struct tle_udp_dest *dst;
-
- lc = data;
-
- rc = rte_lpm_lookup(lc->lpm4, rte_be_to_cpu_32(addr->s_addr), &idx);
- if (rc == 0) {
- dst = &lc->dst4[idx];
- rte_memcpy(res, dst, dst->l2_len + dst->l3_len +
- offsetof(struct tle_udp_dest, hdr));
- }
- return rc;
-}
-
-/*
* UDP IPv6 destination lookup callback.
*/
static int
@@ -680,39 +658,6 @@ netbe_add_ipv6_route(struct netbe_lcore *lc, const struct netbe_dest *dst,
return rc;
}
-static int
-lcore_lpm_init(struct netbe_lcore *lc)
-{
- int32_t sid;
- char str[RTE_LPM_NAMESIZE];
- const struct rte_lpm_config lpm4_cfg = {
- .max_rules = MAX_RULES,
- .number_tbl8s = MAX_TBL8,
- };
- const struct rte_lpm6_config lpm6_cfg = {
- .max_rules = MAX_RULES,
- .number_tbl8s = MAX_TBL8,
- };
-
- sid = rte_lcore_to_socket_id(lc->id);
-
- snprintf(str, sizeof(str), "LPM4%u\n", lc->id);
- lc->lpm4 = rte_lpm_create(str, sid, &lpm4_cfg);
- RTE_LOG(NOTICE, USER1, "%s(lcore=%u): lpm4=%p;\n",
- __func__, lc->id, lc->lpm4);
- if (lc->lpm4 == NULL)
- return -ENOMEM;
-
- snprintf(str, sizeof(str), "LPM6%u\n", lc->id);
- lc->lpm6 = rte_lpm6_create(str, sid, &lpm6_cfg);
- RTE_LOG(NOTICE, USER1, "%s(lcore=%u): lpm6=%p;\n",
- __func__, lc->id, lc->lpm6);
- if (lc->lpm6 == NULL)
- return -ENOMEM;
-
- return 0;
-}
-
static void
fill_dst(struct tle_udp_dest *dst, struct netbe_dev *bed,
const struct netbe_dest *bdp, uint16_t l3_type, int32_t sid)
@@ -756,8 +701,7 @@ fill_dst(struct tle_udp_dest *dst, struct netbe_dev *bed,
}
static int
-create_context(struct netbe_lcore *lc,
- const struct tle_udp_ctx_param *ctx_prm)
+create_context(struct netbe_lcore *lc, const struct tle_udp_ctx_param *ctx_prm)
{
uint32_t rc = 0, sid;
uint64_t frag_cycles;
@@ -1860,89 +1804,6 @@ netfe_lcore_cmp(const void *s1, const void *s2)
return p1->lcore - p2->lcore;
}
-/*
- * Helper functions, verify the queue for corresponding UDP port.
- */
-static uint8_t
-varify_queue_for_port(const struct netbe_dev *prtq, const uint16_t lport)
-{
- uint32_t align_nb_q, qid;
-
- align_nb_q = rte_align32pow2(prtq->port.nb_lcore);
- qid = (lport % align_nb_q) % prtq->port.nb_lcore;
- if (prtq->rxqid == qid)
- return 1;
-
- return 0;
-}
-
-/*
- * Helper functions, finds BE by given local and remote addresses.
- */
-static int
-netbe_find4(const struct in_addr *laddr, const uint16_t lport,
- const struct in_addr *raddr, const uint32_t be_lc)
-{
- uint32_t i, j;
- uint32_t idx;
- struct netbe_lcore *bc;
-
- /* we have exactly one BE, use it for all traffic */
- if (becfg.cpu_num == 1)
- return 0;
-
- /* search by provided be_lcore */
- if (be_lc != LCORE_ID_ANY) {
- for (i = 0; i != becfg.cpu_num; i++) {
- bc = becfg.cpu + i;
- if (be_lc == bc->id)
- return i;
- }
- RTE_LOG(NOTICE, USER1, "%s: no stream with be_lcore=%u\n",
- __func__, be_lc);
- return -ENOENT;
- }
-
- /* search by local address */
- if (laddr->s_addr != INADDR_ANY) {
- for (i = 0; i != becfg.cpu_num; i++) {
- bc = becfg.cpu + i;
- /* search by queue for the local port */
- for (j = 0; j != bc->prtq_num; j++) {
- if (laddr->s_addr == bc->prtq[j].port.ipv4) {
-
- if (lport == 0)
- return i;
-
- if (varify_queue_for_port(bc->prtq + j, lport) != 0)
- return i;
- }
- }
- }
- }
-
- /* search by remote address */
- if (raddr->s_addr != INADDR_ANY) {
- for (i = 0; i != becfg.cpu_num; i++) {
- bc = becfg.cpu + i;
- if (rte_lpm_lookup(bc->lpm4,
- rte_be_to_cpu_32(raddr->s_addr),
- &idx) == 0) {
-
- if (lport == 0)
- return i;
-
- /* search by queue for the local port */
- for (j = 0; j != bc->prtq_num; j++)
- if (varify_queue_for_port(bc->prtq + j, lport) != 0)
- return i;
- }
- }
- }
-
- return -ENOENT;
-}
-
static int
netbe_find6(const struct in6_addr *laddr, uint16_t lport,
const struct in6_addr *raddr, uint32_t be_lc)
@@ -1979,7 +1840,8 @@ netbe_find6(const struct in6_addr *laddr, uint16_t lport,
if (lport == 0)
return i;
- if (varify_queue_for_port(bc->prtq + j, lport) != 0)
+ if (verify_queue_for_port(bc->prtq + j,
+ lport) != 0)
return i;
}
}
@@ -1999,7 +1861,8 @@ netbe_find6(const struct in6_addr *laddr, uint16_t lport,
/* search by queue for the local port */
for (j = 0; j != bc->prtq_num; j++)
- if (varify_queue_for_port(bc->prtq + j, lport) != 0)
+ if (verify_queue_for_port(bc->prtq + j,
+ lport) != 0)
return i;
}
}
diff --git a/examples/udpfwd/main_dpdk_legacy.h b/examples/udpfwd/main_dpdk_legacy.h
new file mode 100644
index 0000000..e4bff24
--- /dev/null
+++ b/examples/udpfwd/main_dpdk_legacy.h
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2016 Intel Corporation.
+ * 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 MAIN_DPDK_LEGACY_H_
+#define MAIN_DPDK_LEGACY_H_
+
+#include "dpdk_version.h"
+
+/*
+ * Helper functions, verify the queue for corresponding UDP port.
+ */
+static uint8_t
+verify_queue_for_port(const struct netbe_dev *prtq, const uint16_t lport)
+{
+ uint32_t align_nb_q, qid;
+
+ align_nb_q = rte_align32pow2(prtq->port.nb_lcore);
+ qid = (lport % align_nb_q) % prtq->port.nb_lcore;
+ if (prtq->rxqid == qid)
+ return 1;
+
+ return 0;
+}
+
+/*
+ * UDP IPv4 destination lookup callback.
+ */
+static int
+lpm4_dst_lookup(void *data, const struct in_addr *addr,
+ struct tle_udp_dest *res)
+{
+ int32_t rc;
+#ifdef DPDK_VERSION_GE_1604
+ uint32_t idx;
+#else
+ uint8_t idx;
+#endif
+ struct netbe_lcore *lc;
+ struct tle_udp_dest *dst;
+
+ lc = data;
+
+ rc = rte_lpm_lookup(lc->lpm4, rte_be_to_cpu_32(addr->s_addr), &idx);
+ if (rc == 0) {
+ dst = &lc->dst4[idx];
+ rte_memcpy(res, dst, dst->l2_len + dst->l3_len +
+ offsetof(struct tle_udp_dest, hdr));
+ }
+ return rc;
+}
+
+static int
+lcore_lpm_init(struct netbe_lcore *lc)
+{
+ int32_t sid;
+ char str[RTE_LPM_NAMESIZE];
+#ifdef DPDK_VERSION_GE_1604
+ const struct rte_lpm_config lpm4_cfg = {
+ .max_rules = MAX_RULES,
+ .number_tbl8s = MAX_TBL8,
+ };
+#endif
+ const struct rte_lpm6_config lpm6_cfg = {
+ .max_rules = MAX_RULES,
+ .number_tbl8s = MAX_TBL8,
+ };
+
+ sid = rte_lcore_to_socket_id(lc->id);
+
+ snprintf(str, sizeof(str), "LPM4%u\n", lc->id);
+#ifdef DPDK_VERSION_GE_1604
+ lc->lpm4 = rte_lpm_create(str, sid, &lpm4_cfg);
+#else
+ lc->lpm4 = rte_lpm_create(str, sid, MAX_RULES, 0);
+#endif
+ RTE_LOG(NOTICE, USER1, "%s(lcore=%u): lpm4=%p;\n",
+ __func__, lc->id, lc->lpm4);
+ if (lc->lpm4 == NULL)
+ return -ENOMEM;
+
+ snprintf(str, sizeof(str), "LPM6%u\n", lc->id);
+ lc->lpm6 = rte_lpm6_create(str, sid, &lpm6_cfg);
+ RTE_LOG(NOTICE, USER1, "%s(lcore=%u): lpm6=%p;\n",
+ __func__, lc->id, lc->lpm6);
+ if (lc->lpm6 == NULL)
+ return -ENOMEM;
+
+ return 0;
+}
+
+/*
+ * Helper functions, finds BE by given local and remote addresses.
+ */
+static int
+netbe_find4(const struct in_addr *laddr, const uint16_t lport,
+ const struct in_addr *raddr, const uint32_t be_lc)
+{
+ uint32_t i, j;
+#ifdef DPDK_VERSION_GE_1604
+ uint32_t idx;
+#else
+ uint8_t idx;
+#endif
+ struct netbe_lcore *bc;
+
+ /* we have exactly one BE, use it for all traffic */
+ if (becfg.cpu_num == 1)
+ return 0;
+
+ /* search by provided be_lcore */
+ if (be_lc != LCORE_ID_ANY) {
+ for (i = 0; i != becfg.cpu_num; i++) {
+ bc = becfg.cpu + i;
+ if (be_lc == bc->id)
+ return i;
+ }
+ RTE_LOG(NOTICE, USER1, "%s: no stream with be_lcore=%u\n",
+ __func__, be_lc);
+ return -ENOENT;
+ }
+
+ /* search by local address */
+ if (laddr->s_addr != INADDR_ANY) {
+ for (i = 0; i != becfg.cpu_num; i++) {
+ bc = becfg.cpu + i;
+ /* search by queue for the local port */
+ for (j = 0; j != bc->prtq_num; j++) {
+ if (laddr->s_addr == bc->prtq[j].port.ipv4) {
+
+ if (lport == 0)
+ return i;
+
+ if (verify_queue_for_port(bc->prtq + j,
+ lport) != 0)
+ return i;
+ }
+ }
+ }
+ }
+
+ /* search by remote address */
+ if (raddr->s_addr != INADDR_ANY) {
+ for (i = 0; i != becfg.cpu_num; i++) {
+ bc = becfg.cpu + i;
+ if (rte_lpm_lookup(bc->lpm4,
+ rte_be_to_cpu_32(raddr->s_addr),
+ &idx) == 0) {
+
+ if (lport == 0)
+ return i;
+
+ /* search by queue for the local port */
+ for (j = 0; j != bc->prtq_num; j++)
+ if (verify_queue_for_port(bc->prtq + j,
+ lport) != 0)
+ return i;
+ }
+ }
+ }
+
+ return -ENOENT;
+}
+
+#endif /* MAIN_DPDK_LEGACY_H_ */
diff --git a/examples/udpfwd/pkt.c b/examples/udpfwd/pkt.c
index 6832b9a..a68e428 100644
--- a/examples/udpfwd/pkt.c
+++ b/examples/udpfwd/pkt.c
@@ -293,8 +293,8 @@ compress_pkt_list(struct rte_mbuf *pkt[], uint32_t nb_pkt, uint32_t nb_zero)
/*
* HW can recognise L2/L3 with/without extentions/L4 (ixgbe/igb/fm10k)
*/
-static uint16_t
-type0_rx_callback(__rte_unused uint8_t port, __rte_unused uint16_t queue,
+static uint16_t __rte_unused
+type0_rx_callback(uint8_t port, __rte_unused uint16_t queue,
struct rte_mbuf *pkt[], uint16_t nb_pkts,
__rte_unused uint16_t max_pkts, void *user_param)
{
@@ -384,7 +384,7 @@ type0_rx_callback(__rte_unused uint8_t port, __rte_unused uint16_t queue,
/*
* HW can recognise L2/L3/L4 and fragments (i40e).
*/
-static uint16_t
+static uint16_t __rte_unused
type1_rx_callback(uint8_t port, __rte_unused uint16_t queue,
struct rte_mbuf *pkt[], uint16_t nb_pkts,
__rte_unused uint16_t max_pkts, void *user_param)
@@ -506,103 +506,4 @@ typen_rx_callback(uint8_t port, __rte_unused uint16_t queue,
return compress_pkt_list(pkt, nb_pkts, x);
}
-int
-setup_rx_cb(const struct netbe_port *uprt, struct netbe_lcore *lc,
- uint16_t qid)
-{
- int32_t i, rc;
- uint32_t smask;
- void *cb;
-
- const uint32_t pmask = RTE_PTYPE_L2_MASK | RTE_PTYPE_L3_MASK |
- RTE_PTYPE_L4_MASK;
-
- enum {
- ETHER_PTYPE = 0x1,
- IPV4_PTYPE = 0x2,
- IPV4_EXT_PTYPE = 0x4,
- IPV6_PTYPE = 0x8,
- IPV6_EXT_PTYPE = 0x10,
- UDP_PTYPE = 0x20,
- };
-
- static const struct {
- uint32_t mask;
- const char *name;
- rte_rx_callback_fn fn;
- } ptype2cb[] = {
- {
- .mask = ETHER_PTYPE | IPV4_PTYPE | IPV4_EXT_PTYPE |
- IPV6_PTYPE | IPV6_EXT_PTYPE | UDP_PTYPE,
- .name = "HW l2/l3x/l4 ptype",
- .fn = type0_rx_callback,
- },
- {
- .mask = ETHER_PTYPE | IPV4_PTYPE | IPV6_PTYPE |
- UDP_PTYPE,
- .name = "HW l2/l3/l4 ptype",
- .fn = type1_rx_callback,
- },
- {
- .mask = 0,
- .name = "no HW ptype",
- .fn = typen_rx_callback,
- },
- };
-
- rc = rte_eth_dev_get_supported_ptypes(uprt->id, pmask, NULL, 0);
- if (rc < 0) {
- RTE_LOG(ERR, USER1,
- "%s(port=%u) failed to get supported ptypes;\n",
- __func__, uprt->id);
- return rc;
- }
-
- uint32_t ptype[rc];
- rc = rte_eth_dev_get_supported_ptypes(uprt->id, pmask, ptype, rc);
-
- smask = 0;
- for (i = 0; i != rc; i++) {
- switch (ptype[i]) {
- case RTE_PTYPE_L2_ETHER:
- smask |= ETHER_PTYPE;
- break;
- case RTE_PTYPE_L3_IPV4:
- case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN:
- smask |= IPV4_PTYPE;
- break;
- case RTE_PTYPE_L3_IPV4_EXT:
- smask |= IPV4_EXT_PTYPE;
- break;
- case RTE_PTYPE_L3_IPV6:
- case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN:
- smask |= IPV6_PTYPE;
- break;
- case RTE_PTYPE_L3_IPV6_EXT:
- smask |= IPV6_EXT_PTYPE;
- break;
- case RTE_PTYPE_L4_UDP:
- smask |= UDP_PTYPE;
- break;
- }
- }
-
- for (i = 0; i != RTE_DIM(ptype2cb); i++) {
- if ((smask & ptype2cb[i].mask) == ptype2cb[i].mask) {
- cb = rte_eth_add_rx_callback(uprt->id, qid,
- ptype2cb[i].fn, lc);
- rc = -rte_errno;
- RTE_LOG(ERR, USER1,
- "%s(port=%u), setup RX callback \"%s\" "
- "returns %p;\n",
- __func__, uprt->id, ptype2cb[i].name, cb);
- return ((cb == NULL) ? rc : 0);
- }
- }
-
- /* no proper callback found. */
- RTE_LOG(ERR, USER1,
- "%s(port=%u) failed to find an appropriate callback;\n",
- __func__, uprt->id);
- return -ENOENT;
-}
+#include "pkt_dpdk_legacy.h"
diff --git a/examples/udpfwd/pkt_dpdk_legacy.h b/examples/udpfwd/pkt_dpdk_legacy.h
new file mode 100644
index 0000000..c32f044
--- /dev/null
+++ b/examples/udpfwd/pkt_dpdk_legacy.h
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2016 Intel Corporation.
+ * 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 PKT_DPDK_LEGACY_H_
+#define PKT_DPDK_LEGACY_H_
+
+#include "dpdk_version.h"
+
+#ifdef DPDK_VERSION_GE_1604
+
+int
+setup_rx_cb(const struct netbe_port *uprt, struct netbe_lcore *lc,
+ uint16_t qid)
+{
+ int32_t i, rc;
+ uint32_t smask;
+ void *cb;
+
+ const uint32_t pmask = RTE_PTYPE_L2_MASK | RTE_PTYPE_L3_MASK |
+ RTE_PTYPE_L4_MASK;
+
+ enum {
+ ETHER_PTYPE = 0x1,
+ IPV4_PTYPE = 0x2,
+ IPV4_EXT_PTYPE = 0x4,
+ IPV6_PTYPE = 0x8,
+ IPV6_EXT_PTYPE = 0x10,
+ UDP_PTYPE = 0x20,
+ };
+
+ static const struct {
+ uint32_t mask;
+ const char *name;
+ rte_rx_callback_fn fn;
+ } ptype2cb[] = {
+ {
+ .mask = ETHER_PTYPE | IPV4_PTYPE | IPV4_EXT_PTYPE |
+ IPV6_PTYPE | IPV6_EXT_PTYPE | UDP_PTYPE,
+ .name = "HW l2/l3x/l4 ptype",
+ .fn = type0_rx_callback,
+ },
+ {
+ .mask = ETHER_PTYPE | IPV4_PTYPE | IPV6_PTYPE |
+ UDP_PTYPE,
+ .name = "HW l2/l3/l4 ptype",
+ .fn = type1_rx_callback,
+ },
+ {
+ .mask = 0,
+ .name = "no HW ptype",
+ .fn = typen_rx_callback,
+ },
+ };
+
+ smask = 0;
+ rc = rte_eth_dev_get_supported_ptypes(uprt->id, pmask, NULL, 0);
+ if (rc < 0) {
+ RTE_LOG(ERR, USER1,
+ "%s(port=%u) failed to get supported ptypes;\n",
+ __func__, uprt->id);
+ return rc;
+ }
+
+ uint32_t ptype[rc];
+ rc = rte_eth_dev_get_supported_ptypes(uprt->id, pmask, ptype, rc);
+
+ for (i = 0; i != rc; i++) {
+ switch (ptype[i]) {
+ case RTE_PTYPE_L2_ETHER:
+ smask |= ETHER_PTYPE;
+ break;
+ case RTE_PTYPE_L3_IPV4:
+ case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN:
+ smask |= IPV4_PTYPE;
+ break;
+ case RTE_PTYPE_L3_IPV4_EXT:
+ smask |= IPV4_EXT_PTYPE;
+ break;
+ case RTE_PTYPE_L3_IPV6:
+ case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN:
+ smask |= IPV6_PTYPE;
+ break;
+ case RTE_PTYPE_L3_IPV6_EXT:
+ smask |= IPV6_EXT_PTYPE;
+ break;
+ case RTE_PTYPE_L4_UDP:
+ smask |= UDP_PTYPE;
+ break;
+ }
+ }
+
+ for (i = 0; i != RTE_DIM(ptype2cb); i++) {
+ if ((smask & ptype2cb[i].mask) == ptype2cb[i].mask) {
+ cb = rte_eth_add_rx_callback(uprt->id, qid,
+ ptype2cb[i].fn, lc);
+ rc = -rte_errno;
+ RTE_LOG(ERR, USER1,
+ "%s(port=%u), setup RX callback \"%s\" "
+ "returns %p;\n",
+ __func__, uprt->id, ptype2cb[i].name, cb);
+ return ((cb == NULL) ? rc : 0);
+ }
+ }
+
+ /* no proper callback found. */
+ RTE_LOG(ERR, USER1,
+ "%s(port=%u) failed to find an appropriate callback;\n",
+ __func__, uprt->id);
+ return -ENOENT;
+}
+
+#else
+
+int
+setup_rx_cb(const struct netbe_port *uprt, struct netbe_lcore *lc,
+ uint16_t qid)
+{
+ void *cb;
+ int32_t rc;
+
+ cb = rte_eth_add_rx_callback(uprt->id, qid, typen_rx_callback, lc);
+ rc = -rte_errno;
+ RTE_LOG(ERR, USER1,
+ "%s(port=%u), setup RX callback \"%s\" "
+ "returns %p;\n",
+ __func__, uprt->id, "no HW ptype", cb);
+
+ return ((cb == NULL) ? rc : 0);
+}
+
+#endif /* DPDK_VERSION_GE_1604 */
+
+#endif /* PKT_DPDK_LEGACY_H_ */