diff options
author | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 13:48:23 +0200 |
---|---|---|
committer | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 13:48:23 +0200 |
commit | 1b6242fc583a6b871304fb995af6dc211b58f69b (patch) | |
tree | b5d434d90dedae24792906aa304897c23a134386 /recipes-networking/dpdk | |
download | meta-ip-1b6242fc583a6b871304fb995af6dc211b58f69b.tar.gz |
initial commit for Enea Linux 4.0daisy-enea
Migrated from the internal git server on the daisy-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'recipes-networking/dpdk')
-rw-r--r-- | recipes-networking/dpdk/dpdk_git.bb | 139 | ||||
-rw-r--r-- | recipes-networking/dpdk/files/igb_ethdev_loopback.patch | 96 | ||||
-rw-r--r-- | recipes-networking/dpdk/files/l2fwd-lpbk/Makefile | 51 | ||||
-rw-r--r-- | recipes-networking/dpdk/files/l2fwd-lpbk/main.c | 929 | ||||
-rw-r--r-- | recipes-networking/dpdk/files/l2fwd-lpbk/main.h | 45 | ||||
-rw-r--r-- | recipes-networking/dpdk/files/machine-flags.patch | 12 | ||||
-rw-r--r-- | recipes-networking/dpdk/files/maketest.patch | 41 | ||||
-rw-r--r-- | recipes-networking/dpdk/files/rte_kni_module_1_6.patch.x | 206 | ||||
-rw-r--r-- | recipes-networking/dpdk/files/run-ptest | 195 | ||||
-rw-r--r-- | recipes-networking/dpdk/files/runtest.patch | 20 | ||||
-rw-r--r-- | recipes-networking/dpdk/files/unbreak-makefiles.patch | 87 |
11 files changed, 1821 insertions, 0 deletions
diff --git a/recipes-networking/dpdk/dpdk_git.bb b/recipes-networking/dpdk/dpdk_git.bb new file mode 100644 index 0000000..ed4c2b3 --- /dev/null +++ b/recipes-networking/dpdk/dpdk_git.bb | |||
@@ -0,0 +1,139 @@ | |||
1 | SUMMARY = "DPDK" | ||
2 | DESCRIPTION = "DPDK - a novel framework for fast packet I/O" | ||
3 | HOMEPAGE = "http://dpdk.org" | ||
4 | SECTION = "devel" | ||
5 | LICENSE = "GPLv2 | LGPLv2 | BSD" | ||
6 | LIC_FILES_CHKSUM = "file://LICENSE.GPL;md5=751419260aa954499f7abaabaa882bbe \ | ||
7 | file://LICENSE.LGPL;md5=4fbd65380cdd255951079008b364516c \ | ||
8 | file://lib/librte_eal/common/include/rte_version.h;beginline=1;endline=33;md5=ab6d502a4a25ded2bbabf031720bd1f4" | ||
9 | |||
10 | PR = "r1" | ||
11 | PV = "1.6.0" | ||
12 | DEPENDS += "virtual/kernel" | ||
13 | |||
14 | inherit module-base | ||
15 | |||
16 | addtask make_scripts after do_patch before do_compile | ||
17 | do_make_scripts[lockfiles] = "${TMPDIR}/kernel-scripts.lock" | ||
18 | do_make_scripts[deptask] = "do_populate_sysroot" | ||
19 | |||
20 | SRCREV = "v1.6.0r1" | ||
21 | SRC_URI = "git://dpdk.org/git/dpdk;protocol=http;branch=1.6.0 \ | ||
22 | file://unbreak-makefiles.patch \ | ||
23 | file://runtest.patch \ | ||
24 | file://run-ptest \ | ||
25 | file://igb_ethdev_loopback.patch \ | ||
26 | file://l2fwd-lpbk \ | ||
27 | file://machine-flags.patch \ | ||
28 | file://rte_kni_module_1_6.patch.x \ | ||
29 | " | ||
30 | |||
31 | DPDK_TARGET_DEFAULT = "${TARGET_ARCH}-default-linuxapp-gcc" | ||
32 | DPDK_TARGET_IVSHMEM = "${TARGET_ARCH}-ivshmem-linuxapp-gcc" | ||
33 | |||
34 | DPDK_BUILD_DIR = "build" | ||
35 | DPDK_VAR_O = "${S}/${DPDK_BUILD_DIR}" | ||
36 | DPDK_VAR_DESTDIR = "${WORKDIR}/install" | ||
37 | |||
38 | DPDK_SRC_PATH = "/usr/src/dpdk" | ||
39 | DPDK_INSTALL_PATH = "/opt/dpdk" | ||
40 | |||
41 | S = "${WORKDIR}/git" | ||
42 | B = "${S}" | ||
43 | |||
44 | PACKAGES = "${PN}-dbg ${PN} ${PN}-mk ${PN}-scripts" | ||
45 | PACKAGES += "${PN}-default-dbg ${PN}-default-staticdev ${PN}-default" | ||
46 | |||
47 | RDEPENDS_${PN} += "pciutils" | ||
48 | RDEPENDS_${PN}-default = "${PN}-mk ${PN}-scripts ${PN}-default-staticdev pciutils" | ||
49 | RRECOMMENDS_${PN} += "kernel-module-uio kernel-module-pci-stub" | ||
50 | |||
51 | FILES_${PN} = "${DPDK_SRC_PATH}" | ||
52 | FILES_${PN}-dbg = "/usr/src/debug" | ||
53 | FILES_${PN}-mk = "${DPDK_INSTALL_PATH}/mk" | ||
54 | FILES_${PN}-scripts = "${DPDK_INSTALL_PATH}/scripts" | ||
55 | |||
56 | FILES_${PN}-default = "${DPDK_INSTALL_PATH}/${TARGET_ARCH}-default-linuxapp-gcc" | ||
57 | FILES_${PN}-default-dbg = "${DPDK_INSTALL_PATH}/${TARGET_ARCH}-default-linuxapp-gcc/app/.debug" | ||
58 | FILES_${PN}-default-staticdev = "${DPDK_INSTALL_PATH}/${TARGET_ARCH}-default-linuxapp-gcc/lib" | ||
59 | |||
60 | do_compile() { | ||
61 | cd ${S} && oe_runmake install \ | ||
62 | RTE_KERNELDIR=${STAGING_KERNEL_DIR} \ | ||
63 | RTE_MACHINE=default \ | ||
64 | prefix="" \ | ||
65 | V=1 KBUILD_VERBOSE=1 CROSS=${TARGET_SYS}- \ | ||
66 | O=${DPDK_VAR_O} \ | ||
67 | T=${DPDK_TARGET_DEFAULT} \ | ||
68 | DESTDIR=${DPDK_VAR_DESTDIR} \ | ||
69 | MACHINE_CFLAGS_ALT="${TARGET_CC_ARCH}" | ||
70 | |||
71 | #patched version of IVSHMEM target for OVS-DPDK - installed to staging only | ||
72 | cd ${S} && git apply ${WORKDIR}/rte_kni_module_1_6.patch.x && \ | ||
73 | oe_runmake install \ | ||
74 | RTE_KERNELDIR=${STAGING_KERNEL_DIR} \ | ||
75 | RTE_MACHINE=default \ | ||
76 | prefix="" \ | ||
77 | V=1 KBUILD_VERBOSE=1 CROSS=${TARGET_SYS}- \ | ||
78 | O=${DPDK_VAR_O} \ | ||
79 | T=${DPDK_TARGET_IVSHMEM} \ | ||
80 | DESTDIR=${DPDK_VAR_DESTDIR} \ | ||
81 | MACHINE_CFLAGS_ALT="${TARGET_CC_ARCH}" \ | ||
82 | EXTRA_CFLAGS=-fPIC && \ | ||
83 | git apply --reverse ${WORKDIR}/rte_kni_module_1_6.patch.x \ | ||
84 | } | ||
85 | |||
86 | do_install() { | ||
87 | # dpdk | ||
88 | install -d ${D}${DPDK_SRC_PATH} | ||
89 | cd ${S} && find . -depth -not -path "./${DPDK_BUILD_DIR}*" -not -path "./patches*" -not -path "./.*" -print0 |\ | ||
90 | cpio --null -pdlu ${D}${DPDK_SRC_PATH} | ||
91 | |||
92 | # install sources to staging | ||
93 | cd ${S} && find . -depth -not -path "./${DPDK_BUILD_DIR}*" -not -path "./patches*" -not -path "./.*" -print0 |\ | ||
94 | cpio --null -pdlu ${STAGING_DIR_HOST}${DPDK_SRC_PATH} | ||
95 | |||
96 | # install build to staging | ||
97 | cd ${DPDK_VAR_DESTDIR} && find . -print0 | cpio --null -pdlu ${STAGING_DIR_HOST}${DPDK_INSTALL_PATH} | ||
98 | |||
99 | # install build output - skip OVS-DPDK IVSHMEM | ||
100 | install -d ${D}${DPDK_INSTALL_PATH} | ||
101 | cd ${DPDK_VAR_DESTDIR} && find . -depth -not -path "./${DPDK_TARGET_IVSHMEM}*" -print0 |\ | ||
102 | cpio --null -pdlu ${D}${DPDK_INSTALL_PATH} | ||
103 | |||
104 | # add "scripts" directory to build output and staging, relpath.sh is needed by makefiles | ||
105 | cp -r ${S}/scripts ${D}${DPDK_INSTALL_PATH} | ||
106 | cp -r ${S}/scripts ${STAGING_DIR_HOST}${DPDK_INSTALL_PATH} | ||
107 | # relpath.sh use of $prefix breaks openvswitch | ||
108 | sed -i 's/prefix/path_prefix/g' ${STAGING_DIR_HOST}${DPDK_INSTALL_PATH}/scripts/relpath.sh | ||
109 | } | ||
110 | |||
111 | COMPATIBLE_HOST = '(x86_64.*|i.86.*)-(linux.*)' | ||
112 | |||
113 | #test default target | ||
114 | |||
115 | inherit ptest | ||
116 | |||
117 | RDEPENDS_${PN}-ptest += "\ | ||
118 | make \ | ||
119 | python-pexpect \ | ||
120 | ${PN}-default \ | ||
121 | ${PN} \ | ||
122 | " | ||
123 | |||
124 | do_compile_ptest () { | ||
125 | cd ${WORKDIR}/l2fwd-lpbk && oe_runmake RTE_SDK="${DPDK_VAR_DESTDIR}" \ | ||
126 | RTE_TARGET="${DPDK_TARGET_DEFAULT}" RTE_ARCH="${TARGET_ARCH}" | ||
127 | sed -i 's|RTE_SDK=.*|RTE_SDK=${DPDK_INSTALL_PATH}|g' ${WORKDIR}/run-ptest | ||
128 | sed -i 's|RTE_TARGET=.*|RTE_TARGET=${DPDK_TARGET_DEFAULT}|g' ${WORKDIR}/run-ptest | ||
129 | sed -i 's|RTE_ARCH=.*|RTE_ARCH=${TARGET_ARCH}|g' ${WORKDIR}/run-ptest | ||
130 | } | ||
131 | |||
132 | do_install_ptest () { | ||
133 | #install l2fwd loopback app | ||
134 | install ${WORKDIR}/l2fwd-lpbk/build/app/l2fwd-lpbk ${D}${PTEST_PATH} | ||
135 | |||
136 | #install original test file to be used by autotest.py | ||
137 | install ${DPDK_VAR_O}/${DPDK_TARGET_DEFAULT}/app/test ${D}${PTEST_PATH} | ||
138 | } | ||
139 | |||
diff --git a/recipes-networking/dpdk/files/igb_ethdev_loopback.patch b/recipes-networking/dpdk/files/igb_ethdev_loopback.patch new file mode 100644 index 0000000..6b979ca --- /dev/null +++ b/recipes-networking/dpdk/files/igb_ethdev_loopback.patch | |||
@@ -0,0 +1,96 @@ | |||
1 | Index: dpdk/lib/librte_pmd_e1000/igb_ethdev.c | ||
2 | =================================================================== | ||
3 | --- dpdk.orig/lib/librte_pmd_e1000/igb_ethdev.c 2014-03-11 12:35:49.267083184 +0200 | ||
4 | +++ dpdk/lib/librte_pmd_e1000/igb_ethdev.c 2014-03-11 12:36:23.015082260 +0200 | ||
5 | @@ -701,50 +701,67 @@ | ||
6 | E1000_WRITE_REG(hw, E1000_EITR(0), 0xFFFF); | ||
7 | } | ||
8 | |||
9 | - /* Setup link speed and duplex */ | ||
10 | - switch (dev->data->dev_conf.link_speed) { | ||
11 | - case ETH_LINK_SPEED_AUTONEG: | ||
12 | + if (dev->data->dev_conf.lpbk_mode == 1) { | ||
13 | + uint32_t reg; | ||
14 | + | ||
15 | + reg = E1000_READ_REG(hw, E1000_RCTL); | ||
16 | + reg |= E1000_RCTL_LBM_MAC; | ||
17 | + E1000_WRITE_REG(hw, E1000_RCTL, reg); | ||
18 | + | ||
19 | + reg = E1000_READ_REG(hw, E1000_CTRL); | ||
20 | + reg |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX | E1000_CTRL_FD | | ||
21 | + E1000_CTRL_SPD_1000); | ||
22 | + E1000_WRITE_REG(hw, E1000_CTRL, reg); | ||
23 | + | ||
24 | + reg = E1000_READ_REG(hw, E1000_EEER); | ||
25 | + reg |= (1 << 28); | ||
26 | + E1000_WRITE_REG(hw, E1000_EEER, reg); | ||
27 | + } else { | ||
28 | + /* Setup link speed and duplex */ | ||
29 | + switch (dev->data->dev_conf.link_speed) { | ||
30 | + case ETH_LINK_SPEED_AUTONEG: | ||
31 | if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX) | ||
32 | - hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX; | ||
33 | + hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX; | ||
34 | else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX) | ||
35 | - hw->phy.autoneg_advertised = E1000_ALL_HALF_DUPLEX; | ||
36 | + hw->phy.autoneg_advertised = E1000_ALL_HALF_DUPLEX; | ||
37 | else if (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX) | ||
38 | - hw->phy.autoneg_advertised = E1000_ALL_FULL_DUPLEX; | ||
39 | + hw->phy.autoneg_advertised = E1000_ALL_FULL_DUPLEX; | ||
40 | else | ||
41 | - goto error_invalid_config; | ||
42 | + goto error_invalid_config; | ||
43 | break; | ||
44 | - case ETH_LINK_SPEED_10: | ||
45 | + case ETH_LINK_SPEED_10: | ||
46 | if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX) | ||
47 | - hw->phy.autoneg_advertised = E1000_ALL_10_SPEED; | ||
48 | + hw->phy.autoneg_advertised = E1000_ALL_10_SPEED; | ||
49 | else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX) | ||
50 | - hw->phy.autoneg_advertised = ADVERTISE_10_HALF; | ||
51 | + hw->phy.autoneg_advertised = ADVERTISE_10_HALF; | ||
52 | else if (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX) | ||
53 | - hw->phy.autoneg_advertised = ADVERTISE_10_FULL; | ||
54 | + hw->phy.autoneg_advertised = ADVERTISE_10_FULL; | ||
55 | else | ||
56 | - goto error_invalid_config; | ||
57 | + goto error_invalid_config; | ||
58 | break; | ||
59 | - case ETH_LINK_SPEED_100: | ||
60 | + case ETH_LINK_SPEED_100: | ||
61 | if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX) | ||
62 | - hw->phy.autoneg_advertised = E1000_ALL_100_SPEED; | ||
63 | + hw->phy.autoneg_advertised = E1000_ALL_100_SPEED; | ||
64 | else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX) | ||
65 | - hw->phy.autoneg_advertised = ADVERTISE_100_HALF; | ||
66 | + hw->phy.autoneg_advertised = ADVERTISE_100_HALF; | ||
67 | else if (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX) | ||
68 | - hw->phy.autoneg_advertised = ADVERTISE_100_FULL; | ||
69 | + hw->phy.autoneg_advertised = ADVERTISE_100_FULL; | ||
70 | else | ||
71 | - goto error_invalid_config; | ||
72 | + goto error_invalid_config; | ||
73 | break; | ||
74 | - case ETH_LINK_SPEED_1000: | ||
75 | + case ETH_LINK_SPEED_1000: | ||
76 | if ((dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX) || | ||
77 | - (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX)) | ||
78 | - hw->phy.autoneg_advertised = ADVERTISE_1000_FULL; | ||
79 | + (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX)) | ||
80 | + hw->phy.autoneg_advertised = ADVERTISE_1000_FULL; | ||
81 | else | ||
82 | - goto error_invalid_config; | ||
83 | + goto error_invalid_config; | ||
84 | break; | ||
85 | - case ETH_LINK_SPEED_10000: | ||
86 | - default: | ||
87 | + case ETH_LINK_SPEED_10000: | ||
88 | + default: | ||
89 | goto error_invalid_config; | ||
90 | + } | ||
91 | + e1000_setup_link(hw); | ||
92 | } | ||
93 | - e1000_setup_link(hw); | ||
94 | |||
95 | /* check if lsc interrupt feature is enabled */ | ||
96 | if (dev->data->dev_conf.intr_conf.lsc != 0) | ||
diff --git a/recipes-networking/dpdk/files/l2fwd-lpbk/Makefile b/recipes-networking/dpdk/files/l2fwd-lpbk/Makefile new file mode 100644 index 0000000..72d56b7 --- /dev/null +++ b/recipes-networking/dpdk/files/l2fwd-lpbk/Makefile | |||
@@ -0,0 +1,51 @@ | |||
1 | # BSD LICENSE | ||
2 | # | ||
3 | # Copyright(c) 2010-2013 Intel Corporation. All rights reserved. | ||
4 | # All rights reserved. | ||
5 | # | ||
6 | # Redistribution and use in source and binary forms, with or without | ||
7 | # modification, are permitted provided that the following conditions | ||
8 | # are met: | ||
9 | # | ||
10 | # * Redistributions of source code must retain the above copyright | ||
11 | # notice, this list of conditions and the following disclaimer. | ||
12 | # * Redistributions in binary form must reproduce the above copyright | ||
13 | # notice, this list of conditions and the following disclaimer in | ||
14 | # the documentation and/or other materials provided with the | ||
15 | # distribution. | ||
16 | # * Neither the name of Intel Corporation nor the names of its | ||
17 | # contributors may be used to endorse or promote products derived | ||
18 | # from this software without specific prior written permission. | ||
19 | # | ||
20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
31 | # | ||
32 | |||
33 | ifeq ($(RTE_SDK),) | ||
34 | $(error "Please define RTE_SDK environment variable") | ||
35 | endif | ||
36 | |||
37 | # Default target, can be overriden by command line or environment | ||
38 | RTE_TARGET ?= x86_64-default-linuxapp-gcc | ||
39 | |||
40 | include $(RTE_SDK)/mk/rte.vars.mk | ||
41 | |||
42 | # binary name | ||
43 | APP = l2fwd-lpbk | ||
44 | |||
45 | # all source are stored in SRCS-y | ||
46 | SRCS-y := main.c | ||
47 | |||
48 | CFLAGS += -O3 | ||
49 | CFLAGS += $(WERROR_FLAGS) | ||
50 | |||
51 | include $(RTE_SDK)/mk/rte.extapp.mk | ||
diff --git a/recipes-networking/dpdk/files/l2fwd-lpbk/main.c b/recipes-networking/dpdk/files/l2fwd-lpbk/main.c new file mode 100644 index 0000000..ff22b66 --- /dev/null +++ b/recipes-networking/dpdk/files/l2fwd-lpbk/main.c | |||
@@ -0,0 +1,929 @@ | |||
1 | /*- | ||
2 | * BSD LICENSE | ||
3 | * | ||
4 | * Copyright(c) 2010-2013 Intel Corporation. All rights reserved. | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * | ||
11 | * * Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * * Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in | ||
15 | * the documentation and/or other materials provided with the | ||
16 | * distribution. | ||
17 | * * Neither the name of Intel Corporation nor the names of its | ||
18 | * contributors may be used to endorse or promote products derived | ||
19 | * from this software without specific prior written permission. | ||
20 | * | ||
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
32 | */ | ||
33 | |||
34 | #include <stdio.h> | ||
35 | #include <stdlib.h> | ||
36 | #include <string.h> | ||
37 | #include <stdint.h> | ||
38 | #include <inttypes.h> | ||
39 | #include <sys/types.h> | ||
40 | #include <sys/queue.h> | ||
41 | #include <netinet/in.h> | ||
42 | #include <setjmp.h> | ||
43 | #include <stdarg.h> | ||
44 | #include <ctype.h> | ||
45 | #include <errno.h> | ||
46 | #include <getopt.h> | ||
47 | |||
48 | #include <rte_common.h> | ||
49 | #include <rte_log.h> | ||
50 | #include <rte_memory.h> | ||
51 | #include <rte_memcpy.h> | ||
52 | #include <rte_memzone.h> | ||
53 | #include <rte_tailq.h> | ||
54 | #include <rte_eal.h> | ||
55 | #include <rte_per_lcore.h> | ||
56 | #include <rte_launch.h> | ||
57 | #include <rte_atomic.h> | ||
58 | #include <rte_cycles.h> | ||
59 | #include <rte_prefetch.h> | ||
60 | #include <rte_lcore.h> | ||
61 | #include <rte_per_lcore.h> | ||
62 | #include <rte_branch_prediction.h> | ||
63 | #include <rte_interrupts.h> | ||
64 | #include <rte_pci.h> | ||
65 | #include <rte_random.h> | ||
66 | #include <rte_debug.h> | ||
67 | #include <rte_ether.h> | ||
68 | #include <rte_ethdev.h> | ||
69 | #include <rte_ring.h> | ||
70 | #include <rte_mempool.h> | ||
71 | #include <rte_mbuf.h> | ||
72 | #include <rte_byteorder.h> | ||
73 | #include <rte_hexdump.h> | ||
74 | |||
75 | #include "main.h" | ||
76 | |||
77 | #define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 | ||
78 | |||
79 | #define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) | ||
80 | #define NB_MBUF 8192 | ||
81 | |||
82 | /* | ||
83 | * RX and TX Prefetch, Host, and Write-back threshold values should be | ||
84 | * carefully set for optimal performance. Consult the network | ||
85 | * controller's datasheet and supporting DPDK documentation for guidance | ||
86 | * on how these parameters should be set. | ||
87 | */ | ||
88 | #define RX_PTHRESH 8 /**< Default values of RX prefetch threshold reg. */ | ||
89 | #define RX_HTHRESH 8 /**< Default values of RX host threshold reg. */ | ||
90 | #define RX_WTHRESH 4 /**< Default values of RX write-back threshold reg. */ | ||
91 | |||
92 | /* | ||
93 | * These default values are optimized for use with the Intel(R) 82599 10 GbE | ||
94 | * Controller and the DPDK ixgbe PMD. Consider using other values for other | ||
95 | * network controllers and/or network drivers. | ||
96 | */ | ||
97 | #define TX_PTHRESH 36 /**< Default values of TX prefetch threshold reg. */ | ||
98 | #define TX_HTHRESH 0 /**< Default values of TX host threshold reg. */ | ||
99 | #define TX_WTHRESH 0 /**< Default values of TX write-back threshold reg. */ | ||
100 | |||
101 | #define MAX_PKT_BURST 32 | ||
102 | #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */ | ||
103 | |||
104 | /* | ||
105 | * Configurable number of RX/TX ring descriptors | ||
106 | */ | ||
107 | #define RTE_TEST_RX_DESC_DEFAULT 128 | ||
108 | #define RTE_TEST_TX_DESC_DEFAULT 512 | ||
109 | static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT; | ||
110 | static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT; | ||
111 | |||
112 | /* ethernet addresses of ports */ | ||
113 | static struct ether_addr l2fwd_ports_eth_addr[RTE_MAX_ETHPORTS]; | ||
114 | |||
115 | /* mask of enabled ports */ | ||
116 | static uint32_t l2fwd_enabled_port_mask = 0; | ||
117 | |||
118 | /* list of enabled ports */ | ||
119 | static uint32_t l2fwd_dst_ports[RTE_MAX_ETHPORTS]; | ||
120 | |||
121 | static unsigned int l2fwd_rx_queue_per_lcore = 1; | ||
122 | |||
123 | #define MIN_TX_SIZE 64 | ||
124 | #define MAX_TX_SIZE 2048 | ||
125 | static int l2fwd_tx_size = MIN_TX_SIZE; | ||
126 | |||
127 | #define MAX_TX_COUNT 128 | ||
128 | static int l2fwd_tx_count = 0; | ||
129 | |||
130 | static int l2fwd_loopback = 0; | ||
131 | |||
132 | struct mbuf_table { | ||
133 | unsigned len; | ||
134 | struct rte_mbuf *m_table[MAX_PKT_BURST]; | ||
135 | }; | ||
136 | |||
137 | #define MAX_RX_QUEUE_PER_LCORE 16 | ||
138 | #define MAX_TX_QUEUE_PER_PORT 16 | ||
139 | struct lcore_queue_conf { | ||
140 | unsigned n_rx_port; | ||
141 | unsigned rx_port_list[MAX_RX_QUEUE_PER_LCORE]; | ||
142 | struct mbuf_table tx_mbufs[RTE_MAX_ETHPORTS]; | ||
143 | |||
144 | } __rte_cache_aligned; | ||
145 | struct lcore_queue_conf lcore_queue_conf[RTE_MAX_LCORE]; | ||
146 | |||
147 | static struct rte_eth_conf port_conf = { | ||
148 | .rxmode = { | ||
149 | .split_hdr_size = 0, | ||
150 | .header_split = 0, /**< Header Split disabled */ | ||
151 | .hw_ip_checksum = 0, /**< IP checksum offload disabled */ | ||
152 | .hw_vlan_filter = 0, /**< VLAN filtering disabled */ | ||
153 | .jumbo_frame = 0, /**< Jumbo Frame Support disabled */ | ||
154 | .hw_strip_crc = 0, /**< CRC stripped by hardware */ | ||
155 | }, | ||
156 | .txmode = { | ||
157 | .mq_mode = ETH_MQ_TX_NONE, | ||
158 | }, | ||
159 | }; | ||
160 | |||
161 | static const struct rte_eth_rxconf rx_conf = { | ||
162 | .rx_thresh = { | ||
163 | .pthresh = RX_PTHRESH, | ||
164 | .hthresh = RX_HTHRESH, | ||
165 | .wthresh = RX_WTHRESH, | ||
166 | }, | ||
167 | }; | ||
168 | |||
169 | static const struct rte_eth_txconf tx_conf = { | ||
170 | .tx_thresh = { | ||
171 | .pthresh = TX_PTHRESH, | ||
172 | .hthresh = TX_HTHRESH, | ||
173 | .wthresh = TX_WTHRESH, | ||
174 | }, | ||
175 | .tx_free_thresh = 0, /* Use PMD default values */ | ||
176 | .tx_rs_thresh = 0, /* Use PMD default values */ | ||
177 | }; | ||
178 | |||
179 | struct rte_mempool * l2fwd_pktmbuf_pool = NULL; | ||
180 | |||
181 | /* Per-port statistics struct */ | ||
182 | struct l2fwd_port_statistics { | ||
183 | uint64_t tx; | ||
184 | uint64_t rx; | ||
185 | uint64_t dropped; | ||
186 | uint64_t loop; | ||
187 | } __rte_cache_aligned; | ||
188 | struct l2fwd_port_statistics port_statistics[RTE_MAX_ETHPORTS]; | ||
189 | |||
190 | /* A tsc-based timer responsible for triggering statistics printout */ | ||
191 | #define MAX_TIMER_PERIOD 86400 /* 1 day max */ | ||
192 | static int64_t timer_period; | ||
193 | static uint64_t tsc_hz; | ||
194 | |||
195 | static void l2fwd_init_time(void) | ||
196 | { | ||
197 | tsc_hz = rte_get_tsc_hz(); | ||
198 | timer_period = 10 * rte_get_tsc_hz(); /* default period is 10 seconds */ | ||
199 | } | ||
200 | |||
201 | /* Print out statistics on packets dropped */ | ||
202 | static void | ||
203 | print_stats(void) | ||
204 | { | ||
205 | uint64_t total_packets_dropped, total_packets_tx, total_packets_rx; | ||
206 | unsigned portid; | ||
207 | static uint64_t count = 0; | ||
208 | const char clr[] = { 27, '[', '2', 'J', '\0' }; | ||
209 | const char topLeft[] = { 27, '[', '1', ';', '1', 'H','\0' }; | ||
210 | |||
211 | total_packets_dropped = 0; | ||
212 | total_packets_tx = 0; | ||
213 | total_packets_rx = 0; | ||
214 | |||
215 | /* Clear screen and move to top left */ | ||
216 | printf("%s%s", clr, topLeft); | ||
217 | |||
218 | printf("\nPort statistics ===================================="); | ||
219 | |||
220 | for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) { | ||
221 | /* skip disabled ports */ | ||
222 | if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) | ||
223 | continue; | ||
224 | printf("\nStatistics for port %u ------------------------------" | ||
225 | "\nPackets sent: %24"PRIu64 | ||
226 | "\nPackets received: %20"PRIu64 | ||
227 | "\nPackets dropped: %21"PRIu64 | ||
228 | "\nLoop count : %21"PRIu64, | ||
229 | portid, | ||
230 | port_statistics[portid].tx, | ||
231 | port_statistics[portid].rx, | ||
232 | port_statistics[portid].dropped, | ||
233 | port_statistics[portid].loop); | ||
234 | |||
235 | total_packets_dropped += port_statistics[portid].dropped; | ||
236 | total_packets_tx += port_statistics[portid].tx; | ||
237 | total_packets_rx += port_statistics[portid].rx; | ||
238 | } | ||
239 | printf("\nAggregate statistics ===============================" | ||
240 | "\nTotal packets sent: %18"PRIu64 | ||
241 | "\nTotal packets received: %14"PRIu64 | ||
242 | "\nTotal packets dropped: %15"PRIu64 | ||
243 | "\nPeriod: %"PRIu64, | ||
244 | total_packets_tx, | ||
245 | total_packets_rx, | ||
246 | total_packets_dropped, | ||
247 | count | ||
248 | ); | ||
249 | printf("\n====================================================\n"); | ||
250 | |||
251 | count++; | ||
252 | } | ||
253 | |||
254 | /* Send the burst of packets on an output interface */ | ||
255 | static int | ||
256 | l2fwd_send_burst(struct lcore_queue_conf *qconf, unsigned n, uint8_t port) | ||
257 | { | ||
258 | struct rte_mbuf **m_table; | ||
259 | unsigned ret; | ||
260 | unsigned queueid =0; | ||
261 | |||
262 | m_table = (struct rte_mbuf **)qconf->tx_mbufs[port].m_table; | ||
263 | |||
264 | ret = rte_eth_tx_burst(port, (uint16_t) queueid, m_table, (uint16_t) n); | ||
265 | port_statistics[port].tx += ret; | ||
266 | if (unlikely(ret < n)) { | ||
267 | port_statistics[port].dropped += (n - ret); | ||
268 | do { | ||
269 | rte_pktmbuf_free(m_table[ret]); | ||
270 | } while (++ret < n); | ||
271 | } | ||
272 | |||
273 | return 0; | ||
274 | } | ||
275 | |||
276 | /* Enqueue packets for TX and prepare them to be sent */ | ||
277 | static int | ||
278 | l2fwd_send_packet(struct rte_mbuf *m, uint8_t port) | ||
279 | { | ||
280 | unsigned lcore_id, len; | ||
281 | struct lcore_queue_conf *qconf; | ||
282 | |||
283 | lcore_id = rte_lcore_id(); | ||
284 | |||
285 | qconf = &lcore_queue_conf[lcore_id]; | ||
286 | len = qconf->tx_mbufs[port].len; | ||
287 | qconf->tx_mbufs[port].m_table[len] = m; | ||
288 | len++; | ||
289 | |||
290 | /* enough pkts to be sent */ | ||
291 | if (unlikely(len == MAX_PKT_BURST)) { | ||
292 | l2fwd_send_burst(qconf, MAX_PKT_BURST, port); | ||
293 | len = 0; | ||
294 | } | ||
295 | |||
296 | qconf->tx_mbufs[port].len = len; | ||
297 | return 0; | ||
298 | } | ||
299 | |||
300 | static void | ||
301 | l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid) | ||
302 | { | ||
303 | struct ether_hdr *eth; | ||
304 | void *tmp; | ||
305 | unsigned dst_port; | ||
306 | |||
307 | dst_port = l2fwd_dst_ports[portid]; | ||
308 | |||
309 | eth = rte_pktmbuf_mtod(m, struct ether_hdr *); | ||
310 | /* 02:00:00:00:00:xx */ | ||
311 | tmp = ð->d_addr.addr_bytes[0]; | ||
312 | *((uint64_t *)tmp) = 0x000000000002 + ((uint64_t)dst_port << 40); | ||
313 | |||
314 | /* src addr */ | ||
315 | ether_addr_copy(&l2fwd_ports_eth_addr[dst_port], ð->s_addr); | ||
316 | |||
317 | l2fwd_send_packet(m, (uint8_t) dst_port); | ||
318 | } | ||
319 | |||
320 | static inline void | ||
321 | copy_buf_to_pkt(void* buf, unsigned len, struct rte_mbuf *pkt, unsigned offset) | ||
322 | { | ||
323 | rte_memcpy(((char *) pkt->pkt.data + offset), buf, (size_t) len); | ||
324 | } | ||
325 | |||
326 | static int | ||
327 | l2fwd_tx(void) | ||
328 | { | ||
329 | uint8_t portid; | ||
330 | |||
331 | for (portid = 0; portid < RTE_MAX_ETHPORTS; ++portid) { | ||
332 | struct rte_mbuf *tx_mbuf[MAX_TX_COUNT]; | ||
333 | int pkt; | ||
334 | unsigned queueid = 0; | ||
335 | |||
336 | if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) | ||
337 | continue; | ||
338 | |||
339 | for (pkt = 0; pkt < l2fwd_tx_count; ++pkt) { | ||
340 | |||
341 | tx_mbuf[pkt] = rte_pktmbuf_alloc(l2fwd_pktmbuf_pool); | ||
342 | if (!tx_mbuf[pkt]) | ||
343 | rte_exit(EXIT_FAILURE, | ||
344 | "rte_pktmbuf_alloc failed.\n"); | ||
345 | |||
346 | /* minimum ethernet header | ||
347 | without this the 82599 will drop the packet if IXGBE_FCTRL_SBP is not set | ||
348 | */ | ||
349 | { | ||
350 | struct ether_hdr *eth_hdr; | ||
351 | /*struct ipv4_hdr *ipv4_hdr;*/ | ||
352 | struct ether_addr mac_addr; | ||
353 | |||
354 | eth_hdr = rte_pktmbuf_mtod(tx_mbuf[pkt], struct ether_hdr*); | ||
355 | |||
356 | rte_eth_macaddr_get(portid, &mac_addr); | ||
357 | #if 1 | ||
358 | mac_addr.addr_bytes[0] = 0; | ||
359 | mac_addr.addr_bytes[1] = 2; | ||
360 | #endif | ||
361 | ether_addr_copy(&mac_addr, ð_hdr->s_addr); | ||
362 | ether_addr_copy(&mac_addr, ð_hdr->d_addr); | ||
363 | eth_hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4); | ||
364 | |||
365 | /*ipv4_hdr = (struct ipv4_hdr*)ð_hdr[1];*/ | ||
366 | |||
367 | tx_mbuf[pkt]->pkt.data_len = l2fwd_tx_size; | ||
368 | tx_mbuf[pkt]->pkt.pkt_len = l2fwd_tx_size; | ||
369 | #if 0 | ||
370 | rte_hexdump(NULL, rte_pktmbuf_mtod(tx_mbuf[pkt], void*), l2fwd_tx_size); | ||
371 | #endif | ||
372 | } | ||
373 | } | ||
374 | |||
375 | if(rte_eth_tx_burst(portid, queueid, tx_mbuf, l2fwd_tx_count) != l2fwd_tx_count) | ||
376 | rte_exit(EXIT_FAILURE, "Incomplete Tx for port %u\n", portid); | ||
377 | |||
378 | RTE_LOG(INFO, L2FWD, "sent %u packets on port %u\n", l2fwd_tx_count, portid); | ||
379 | } | ||
380 | |||
381 | return 0; | ||
382 | } | ||
383 | |||
384 | /* main processing loop */ | ||
385 | static void | ||
386 | l2fwd_main_loop(void) | ||
387 | { | ||
388 | struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; | ||
389 | struct rte_mbuf *m; | ||
390 | unsigned lcore_id; | ||
391 | uint64_t prev_tsc, diff_tsc, cur_tsc, timer_tsc; | ||
392 | unsigned i, j, portid, nb_rx; | ||
393 | struct lcore_queue_conf *qconf; | ||
394 | const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) / US_PER_S * BURST_TX_DRAIN_US; | ||
395 | |||
396 | prev_tsc = 0; | ||
397 | timer_tsc = 0; | ||
398 | |||
399 | lcore_id = rte_lcore_id(); | ||
400 | qconf = &lcore_queue_conf[lcore_id]; | ||
401 | |||
402 | if (qconf->n_rx_port == 0) { | ||
403 | RTE_LOG(INFO, L2FWD, "lcore %u has nothing to do\n", lcore_id); | ||
404 | return; | ||
405 | } | ||
406 | |||
407 | RTE_LOG(INFO, L2FWD, "entering main loop on lcore %u\n", lcore_id); | ||
408 | |||
409 | for (i = 0; i < qconf->n_rx_port; i++) { | ||
410 | |||
411 | portid = qconf->rx_port_list[i]; | ||
412 | RTE_LOG(INFO, L2FWD, " -- lcoreid=%u portid=%u\n", lcore_id, | ||
413 | portid); | ||
414 | } | ||
415 | |||
416 | while (1) { | ||
417 | cur_tsc = rte_rdtsc(); | ||
418 | |||
419 | /* | ||
420 | * TX burst queue drain | ||
421 | */ | ||
422 | diff_tsc = cur_tsc - prev_tsc; | ||
423 | if (unlikely(diff_tsc > drain_tsc)) { | ||
424 | for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) { | ||
425 | if (qconf->tx_mbufs[portid].len == 0) | ||
426 | continue; | ||
427 | l2fwd_send_burst(&lcore_queue_conf[lcore_id], | ||
428 | qconf->tx_mbufs[portid].len, | ||
429 | (uint8_t) portid); | ||
430 | qconf->tx_mbufs[portid].len = 0; | ||
431 | } | ||
432 | /* if timer is enabled */ | ||
433 | if (timer_period > 0) { | ||
434 | |||
435 | /* advance the timer */ | ||
436 | timer_tsc += diff_tsc; | ||
437 | |||
438 | /* if timer has reached its timeout */ | ||
439 | if (unlikely(timer_tsc >= (uint64_t) timer_period)) { | ||
440 | |||
441 | /* do this only on master core */ | ||
442 | if (lcore_id == rte_get_master_lcore()) { | ||
443 | print_stats(); | ||
444 | /* reset the timer */ | ||
445 | timer_tsc = 0; | ||
446 | } | ||
447 | } | ||
448 | } | ||
449 | |||
450 | prev_tsc = cur_tsc; | ||
451 | } | ||
452 | |||
453 | /* | ||
454 | * Read packet from RX queues | ||
455 | */ | ||
456 | for (i = 0; i < qconf->n_rx_port; i++) { | ||
457 | portid = qconf->rx_port_list[i]; | ||
458 | nb_rx = rte_eth_rx_burst((uint8_t) portid, 0, | ||
459 | pkts_burst, MAX_PKT_BURST); | ||
460 | |||
461 | port_statistics[portid].rx += nb_rx; | ||
462 | port_statistics[portid].loop++; | ||
463 | |||
464 | for (j = 0; j < nb_rx; j++) { | ||
465 | m = pkts_burst[j]; | ||
466 | rte_prefetch0(rte_pktmbuf_mtod(m, void *)); | ||
467 | l2fwd_simple_forward(m, portid); | ||
468 | |||
469 | #if 0 | ||
470 | rte_hexdump(NULL, rte_pktmbuf_mtod(pkts_burst[j], void*), pkts_burst[j]->pkt.data_len); | ||
471 | #endif | ||
472 | |||
473 | } | ||
474 | } | ||
475 | } | ||
476 | } | ||
477 | |||
478 | static int | ||
479 | l2fwd_launch_one_lcore(__attribute__((unused)) void *dummy) | ||
480 | { | ||
481 | l2fwd_main_loop(); | ||
482 | return 0; | ||
483 | } | ||
484 | |||
485 | /* display usage */ | ||
486 | static void | ||
487 | l2fwd_usage(const char *prgname) | ||
488 | { | ||
489 | printf("%s [EAL options] -- -p PORTMASK [-q NQ]\n" | ||
490 | " -p PORTMASK: hexadecimal bitmask of ports to configure\n" | ||
491 | " -q NQ: number of queue (=ports) per lcore (default is 1)\n" | ||
492 | " -T PERIOD: statistics will be refreshed each PERIOD seconds (0 to disable, 10 default, 86400 maximum)\n" | ||
493 | " -t TX: number of packets to send before forwarding (0 to disable, 0 default, 128 maximum)\n" | ||
494 | " -l LOOPBACK: loopback mode \n" | ||
495 | " -s SIZE: size of packets to be sent (64 default/minimum, 2048 maximum)\n", | ||
496 | prgname); | ||
497 | } | ||
498 | |||
499 | static int | ||
500 | l2fwd_parse_portmask(const char *portmask) | ||
501 | { | ||
502 | char *end = NULL; | ||
503 | unsigned long pm; | ||
504 | |||
505 | /* parse hexadecimal string */ | ||
506 | pm = strtoul(portmask, &end, 16); | ||
507 | if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0')) | ||
508 | return -1; | ||
509 | |||
510 | if (pm == 0) | ||
511 | return -1; | ||
512 | |||
513 | return pm; | ||
514 | } | ||
515 | |||
516 | static int | ||
517 | l2fwd_parse_tx_packet_count(const char *q_arg) | ||
518 | { | ||
519 | char *end = NULL; | ||
520 | int n; | ||
521 | |||
522 | /* parse number string */ | ||
523 | n = strtol(q_arg, &end, 10); | ||
524 | if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0')) | ||
525 | return -1; | ||
526 | if (n > MAX_TX_COUNT) | ||
527 | return -1; | ||
528 | |||
529 | return n; | ||
530 | } | ||
531 | |||
532 | static int | ||
533 | l2fwd_parse_tx_packet_size(const char *q_arg) | ||
534 | { | ||
535 | char *end = NULL; | ||
536 | int n; | ||
537 | |||
538 | /* parse number string */ | ||
539 | n = strtol(q_arg, &end, 10); | ||
540 | if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0')) | ||
541 | return -1; | ||
542 | if (n < MIN_TX_SIZE) | ||
543 | return -1; | ||
544 | if (n > MAX_TX_SIZE) | ||
545 | return -1; | ||
546 | |||
547 | return n; | ||
548 | } | ||
549 | |||
550 | static unsigned int | ||
551 | l2fwd_parse_nqueue(const char *q_arg) | ||
552 | { | ||
553 | char *end = NULL; | ||
554 | unsigned long n; | ||
555 | |||
556 | /* parse hexadecimal string */ | ||
557 | n = strtoul(q_arg, &end, 10); | ||
558 | if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0')) | ||
559 | return 0; | ||
560 | if (n == 0) | ||
561 | return 0; | ||
562 | if (n >= MAX_RX_QUEUE_PER_LCORE) | ||
563 | return 0; | ||
564 | |||
565 | return n; | ||
566 | } | ||
567 | |||
568 | static int | ||
569 | l2fwd_parse_timer_period(const char *q_arg) | ||
570 | { | ||
571 | char *end = NULL; | ||
572 | int n; | ||
573 | |||
574 | /* parse number string */ | ||
575 | n = strtol(q_arg, &end, 10); | ||
576 | if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0')) | ||
577 | return -1; | ||
578 | if (n >= MAX_TIMER_PERIOD) | ||
579 | return -1; | ||
580 | |||
581 | return n; | ||
582 | } | ||
583 | |||
584 | /* Parse the argument given in the command line of the application */ | ||
585 | static int | ||
586 | l2fwd_parse_args(int argc, char **argv) | ||
587 | { | ||
588 | int opt, ret; | ||
589 | char **argvopt; | ||
590 | int option_index; | ||
591 | char *prgname = argv[0]; | ||
592 | static struct option lgopts[] = { | ||
593 | {NULL, 0, 0, 0} | ||
594 | }; | ||
595 | |||
596 | argvopt = argv; | ||
597 | |||
598 | while ((opt = getopt_long(argc, argvopt, "p:q:T:t:s:l", | ||
599 | lgopts, &option_index)) != EOF) { | ||
600 | |||
601 | switch (opt) { | ||
602 | /* portmask */ | ||
603 | case 'p': | ||
604 | l2fwd_enabled_port_mask = l2fwd_parse_portmask(optarg); | ||
605 | if (l2fwd_enabled_port_mask == 0) { | ||
606 | printf("invalid portmask\n"); | ||
607 | l2fwd_usage(prgname); | ||
608 | return -1; | ||
609 | } | ||
610 | break; | ||
611 | |||
612 | /* nqueue */ | ||
613 | case 'q': | ||
614 | l2fwd_rx_queue_per_lcore = l2fwd_parse_nqueue(optarg); | ||
615 | if (l2fwd_rx_queue_per_lcore == 0) { | ||
616 | printf("invalid queue number\n"); | ||
617 | l2fwd_usage(prgname); | ||
618 | return -1; | ||
619 | } | ||
620 | break; | ||
621 | |||
622 | /* timer period */ | ||
623 | case 'T': | ||
624 | timer_period = l2fwd_parse_timer_period(optarg) * tsc_hz; | ||
625 | if (timer_period < 0) { | ||
626 | printf("invalid timer period\n"); | ||
627 | l2fwd_usage(prgname); | ||
628 | return -1; | ||
629 | } | ||
630 | break; | ||
631 | |||
632 | case 't': | ||
633 | l2fwd_tx_count = l2fwd_parse_tx_packet_count(optarg); | ||
634 | if (l2fwd_tx_count < 0) { | ||
635 | printf("invalid tx packet count\n"); | ||
636 | l2fwd_usage(prgname); | ||
637 | return -1; | ||
638 | } | ||
639 | break; | ||
640 | |||
641 | case 's': | ||
642 | l2fwd_tx_size = l2fwd_parse_tx_packet_size(optarg); | ||
643 | if (l2fwd_tx_size < 0) { | ||
644 | printf("invalid tx packet size\n"); | ||
645 | l2fwd_usage(prgname); | ||
646 | return -1; | ||
647 | } | ||
648 | break; | ||
649 | |||
650 | case 'l': | ||
651 | l2fwd_loopback = 1; | ||
652 | break; | ||
653 | |||
654 | /* long options */ | ||
655 | case 0: | ||
656 | l2fwd_usage(prgname); | ||
657 | return -1; | ||
658 | |||
659 | default: | ||
660 | l2fwd_usage(prgname); | ||
661 | return -1; | ||
662 | } | ||
663 | } | ||
664 | |||
665 | if (optind >= 0) | ||
666 | argv[optind-1] = prgname; | ||
667 | |||
668 | ret = optind-1; | ||
669 | optind = 0; /* reset getopt lib */ | ||
670 | return ret; | ||
671 | } | ||
672 | |||
673 | /* Check the link status of all ports in up to 9s, and print them finally */ | ||
674 | static void | ||
675 | check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) | ||
676 | { | ||
677 | #define CHECK_INTERVAL 100 /* 100ms */ | ||
678 | #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */ | ||
679 | uint8_t portid, count, all_ports_up, print_flag = 0; | ||
680 | struct rte_eth_link link; | ||
681 | |||
682 | printf("\nChecking link status"); | ||
683 | fflush(stdout); | ||
684 | for (count = 0; count <= MAX_CHECK_TIME; count++) { | ||
685 | all_ports_up = 1; | ||
686 | for (portid = 0; portid < port_num; portid++) { | ||
687 | if ((port_mask & (1 << portid)) == 0) | ||
688 | continue; | ||
689 | memset(&link, 0, sizeof(link)); | ||
690 | rte_eth_link_get_nowait(portid, &link); | ||
691 | /* print link status if flag set */ | ||
692 | if (print_flag == 1) { | ||
693 | if (link.link_status) | ||
694 | printf("Port %d Link Up - speed %u " | ||
695 | "Mbps - %s\n", (uint8_t)portid, | ||
696 | (unsigned)link.link_speed, | ||
697 | (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? | ||
698 | ("full-duplex") : ("half-duplex\n")); | ||
699 | else | ||
700 | printf("Port %d Link Down\n", | ||
701 | (uint8_t)portid); | ||
702 | continue; | ||
703 | } | ||
704 | /* clear all_ports_up flag if any link down */ | ||
705 | if (link.link_status == 0) { | ||
706 | all_ports_up = 0; | ||
707 | break; | ||
708 | } | ||
709 | } | ||
710 | /* after finally printing all link status, get out */ | ||
711 | if (print_flag == 1) | ||
712 | break; | ||
713 | |||
714 | if (all_ports_up == 0) { | ||
715 | printf("."); | ||
716 | fflush(stdout); | ||
717 | rte_delay_ms(CHECK_INTERVAL); | ||
718 | } | ||
719 | |||
720 | /* set the print_flag if all ports up or timeout */ | ||
721 | if (all_ports_up == 1 || count == (MAX_CHECK_TIME - 1)) { | ||
722 | print_flag = 1; | ||
723 | printf("done\n"); | ||
724 | } | ||
725 | } | ||
726 | } | ||
727 | |||
728 | int | ||
729 | MAIN(int argc, char **argv) | ||
730 | { | ||
731 | struct lcore_queue_conf *qconf; | ||
732 | struct rte_eth_dev_info dev_info; | ||
733 | int ret; | ||
734 | uint8_t nb_ports; | ||
735 | uint8_t nb_ports_available; | ||
736 | uint8_t portid, last_port; | ||
737 | unsigned lcore_id, rx_lcore_id; | ||
738 | unsigned nb_ports_in_mask = 0; | ||
739 | |||
740 | setlinebuf(stdout); | ||
741 | setlinebuf(stderr); | ||
742 | |||
743 | /* init EAL */ | ||
744 | ret = rte_eal_init(argc, argv); | ||
745 | if (ret < 0) | ||
746 | rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n"); | ||
747 | |||
748 | l2fwd_init_time(); | ||
749 | |||
750 | argc -= ret; | ||
751 | argv += ret; | ||
752 | |||
753 | /* parse application arguments (after the EAL ones) */ | ||
754 | ret = l2fwd_parse_args(argc, argv); | ||
755 | if (ret < 0) | ||
756 | rte_exit(EXIT_FAILURE, "Invalid L2FWD arguments\n"); | ||
757 | |||
758 | /* create the mbuf pool */ | ||
759 | l2fwd_pktmbuf_pool = | ||
760 | rte_mempool_create("mbuf_pool", NB_MBUF, | ||
761 | MBUF_SIZE, 32, | ||
762 | sizeof(struct rte_pktmbuf_pool_private), | ||
763 | rte_pktmbuf_pool_init, NULL, | ||
764 | rte_pktmbuf_init, NULL, | ||
765 | rte_socket_id(), 0); | ||
766 | if (l2fwd_pktmbuf_pool == NULL) | ||
767 | rte_exit(EXIT_FAILURE, "Cannot init mbuf pool\n"); | ||
768 | |||
769 | /* init driver(s) */ | ||
770 | if (rte_pmd_init_all() < 0) | ||
771 | rte_exit(EXIT_FAILURE, "Cannot init pmd\n"); | ||
772 | |||
773 | if (rte_eal_pci_probe() < 0) | ||
774 | rte_exit(EXIT_FAILURE, "Cannot probe PCI\n"); | ||
775 | |||
776 | nb_ports = rte_eth_dev_count(); | ||
777 | if (nb_ports == 0) | ||
778 | rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n"); | ||
779 | |||
780 | if (nb_ports > RTE_MAX_ETHPORTS) | ||
781 | nb_ports = RTE_MAX_ETHPORTS; | ||
782 | |||
783 | /* reset l2fwd_dst_ports */ | ||
784 | for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) | ||
785 | l2fwd_dst_ports[portid] = 0; | ||
786 | last_port = 0; | ||
787 | |||
788 | /* | ||
789 | * Each logical core is assigned a dedicated TX queue on each port. | ||
790 | */ | ||
791 | for (portid = 0; portid < nb_ports; portid++) { | ||
792 | /* skip ports that are not enabled */ | ||
793 | if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) | ||
794 | continue; | ||
795 | |||
796 | if (l2fwd_loopback) { | ||
797 | l2fwd_dst_ports[portid] = portid; | ||
798 | continue; | ||
799 | } | ||
800 | |||
801 | if (nb_ports_in_mask % 2) { | ||
802 | l2fwd_dst_ports[portid] = last_port; | ||
803 | l2fwd_dst_ports[last_port] = portid; | ||
804 | } | ||
805 | else | ||
806 | last_port = portid; | ||
807 | |||
808 | nb_ports_in_mask++; | ||
809 | |||
810 | rte_eth_dev_info_get(portid, &dev_info); | ||
811 | } | ||
812 | if (!l2fwd_loopback && (nb_ports_in_mask % 2)) { | ||
813 | printf("Notice: odd number of ports in portmask.\n"); | ||
814 | l2fwd_dst_ports[last_port] = last_port; | ||
815 | } | ||
816 | |||
817 | rx_lcore_id = 0; | ||
818 | qconf = NULL; | ||
819 | |||
820 | /* Initialize the port/queue configuration of each logical core */ | ||
821 | for (portid = 0; portid < nb_ports; portid++) { | ||
822 | /* skip ports that are not enabled */ | ||
823 | if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) | ||
824 | continue; | ||
825 | |||
826 | /* get the lcore_id for this port */ | ||
827 | while (rte_lcore_is_enabled(rx_lcore_id) == 0 || | ||
828 | lcore_queue_conf[rx_lcore_id].n_rx_port == | ||
829 | l2fwd_rx_queue_per_lcore) { | ||
830 | rx_lcore_id++; | ||
831 | if (rx_lcore_id >= RTE_MAX_LCORE) | ||
832 | rte_exit(EXIT_FAILURE, "Not enough cores\n"); | ||
833 | } | ||
834 | |||
835 | if (qconf != &lcore_queue_conf[rx_lcore_id]) | ||
836 | /* Assigned a new logical core in the loop above. */ | ||
837 | qconf = &lcore_queue_conf[rx_lcore_id]; | ||
838 | |||
839 | qconf->rx_port_list[qconf->n_rx_port] = portid; | ||
840 | qconf->n_rx_port++; | ||
841 | printf("Lcore %u: RX port %u\n", rx_lcore_id, (unsigned) portid); | ||
842 | } | ||
843 | |||
844 | nb_ports_available = nb_ports; | ||
845 | |||
846 | if (l2fwd_loopback) | ||
847 | port_conf.lpbk_mode = 1; | ||
848 | |||
849 | /* Initialise each port */ | ||
850 | for (portid = 0; portid < nb_ports; portid++) { | ||
851 | /* skip ports that are not enabled */ | ||
852 | if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) { | ||
853 | printf("Skipping disabled port %u\n", (unsigned) portid); | ||
854 | nb_ports_available--; | ||
855 | continue; | ||
856 | } | ||
857 | /* init port */ | ||
858 | printf("Initializing port %u... ", (unsigned) portid); | ||
859 | fflush(stdout); | ||
860 | |||
861 | ret = rte_eth_dev_configure(portid, 1, 1, &port_conf); | ||
862 | if (ret < 0) | ||
863 | rte_exit(EXIT_FAILURE, "Cannot configure device: err=%d, port=%u\n", | ||
864 | ret, (unsigned) portid); | ||
865 | |||
866 | rte_eth_macaddr_get(portid,&l2fwd_ports_eth_addr[portid]); | ||
867 | |||
868 | /* init one RX queue */ | ||
869 | fflush(stdout); | ||
870 | ret = rte_eth_rx_queue_setup(portid, 0, nb_rxd, | ||
871 | rte_eth_dev_socket_id(portid), &rx_conf, | ||
872 | l2fwd_pktmbuf_pool); | ||
873 | if (ret < 0) | ||
874 | rte_exit(EXIT_FAILURE, "rte_eth_rx_queue_setup:err=%d, port=%u\n", | ||
875 | ret, (unsigned) portid); | ||
876 | |||
877 | /* init one TX queue on each port */ | ||
878 | fflush(stdout); | ||
879 | ret = rte_eth_tx_queue_setup(portid, 0, nb_txd, | ||
880 | rte_eth_dev_socket_id(portid), &tx_conf); | ||
881 | if (ret < 0) | ||
882 | rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup:err=%d, port=%u\n", | ||
883 | ret, (unsigned) portid); | ||
884 | |||
885 | /* Start device */ | ||
886 | ret = rte_eth_dev_start(portid); | ||
887 | if (ret < 0) | ||
888 | rte_exit(EXIT_FAILURE, "rte_eth_dev_start:err=%d, port=%u\n", | ||
889 | ret, (unsigned) portid); | ||
890 | |||
891 | printf("done: \n"); | ||
892 | |||
893 | rte_eth_promiscuous_enable(portid); | ||
894 | |||
895 | printf("Port %u, MAC address: %02X:%02X:%02X:%02X:%02X:%02X\n\n", | ||
896 | (unsigned) portid, | ||
897 | l2fwd_ports_eth_addr[portid].addr_bytes[0], | ||
898 | l2fwd_ports_eth_addr[portid].addr_bytes[1], | ||
899 | l2fwd_ports_eth_addr[portid].addr_bytes[2], | ||
900 | l2fwd_ports_eth_addr[portid].addr_bytes[3], | ||
901 | l2fwd_ports_eth_addr[portid].addr_bytes[4], | ||
902 | l2fwd_ports_eth_addr[portid].addr_bytes[5]); | ||
903 | |||
904 | /* initialize port stats */ | ||
905 | memset(&port_statistics, 0, sizeof(port_statistics)); | ||
906 | } | ||
907 | |||
908 | if (!nb_ports_available) { | ||
909 | rte_exit(EXIT_FAILURE, | ||
910 | "All available ports are disabled. Please set portmask.\n"); | ||
911 | } | ||
912 | |||
913 | if(!l2fwd_loopback) | ||
914 | check_all_ports_link_status(nb_ports, l2fwd_enabled_port_mask); | ||
915 | |||
916 | if (l2fwd_tx_count) | ||
917 | l2fwd_tx(); | ||
918 | |||
919 | /* launch per-lcore init on every lcore */ | ||
920 | rte_eal_mp_remote_launch(l2fwd_launch_one_lcore, NULL, CALL_MASTER); | ||
921 | |||
922 | RTE_LCORE_FOREACH_SLAVE(lcore_id) { | ||
923 | if (rte_eal_wait_lcore(lcore_id) < 0) | ||
924 | return -1; | ||
925 | } | ||
926 | |||
927 | return 0; | ||
928 | } | ||
929 | |||
diff --git a/recipes-networking/dpdk/files/l2fwd-lpbk/main.h b/recipes-networking/dpdk/files/l2fwd-lpbk/main.h new file mode 100644 index 0000000..93dca37 --- /dev/null +++ b/recipes-networking/dpdk/files/l2fwd-lpbk/main.h | |||
@@ -0,0 +1,45 @@ | |||
1 | /*- | ||
2 | * BSD LICENSE | ||
3 | * | ||
4 | * Copyright(c) 2010-2013 Intel Corporation. All rights reserved. | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * | ||
11 | * * Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * * Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in | ||
15 | * the documentation and/or other materials provided with the | ||
16 | * distribution. | ||
17 | * * Neither the name of Intel Corporation nor the names of its | ||
18 | * contributors may be used to endorse or promote products derived | ||
19 | * from this software without specific prior written permission. | ||
20 | * | ||
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
32 | */ | ||
33 | |||
34 | #ifndef _MAIN_H_ | ||
35 | #define _MAIN_H_ | ||
36 | |||
37 | #ifdef RTE_EXEC_ENV_BAREMETAL | ||
38 | #define MAIN _main | ||
39 | #else | ||
40 | #define MAIN main | ||
41 | #endif | ||
42 | |||
43 | int MAIN(int argc, char **argv); | ||
44 | |||
45 | #endif /* _MAIN_H_ */ | ||
diff --git a/recipes-networking/dpdk/files/machine-flags.patch b/recipes-networking/dpdk/files/machine-flags.patch new file mode 100644 index 0000000..a6998fd --- /dev/null +++ b/recipes-networking/dpdk/files/machine-flags.patch | |||
@@ -0,0 +1,12 @@ | |||
1 | Index: dpdk/mk/machine/native/rte.vars.mk | ||
2 | =================================================================== | ||
3 | --- dpdk.orig/mk/machine/native/rte.vars.mk 2014-04-25 18:53:11.422348174 +0300 | ||
4 | +++ dpdk/mk/machine/native/rte.vars.mk 2014-04-25 18:52:44.042348924 +0300 | ||
5 | @@ -55,4 +55,6 @@ | ||
6 | # CPU_LDFLAGS = | ||
7 | # CPU_ASFLAGS = | ||
8 | |||
9 | -MACHINE_CFLAGS = -march=native | ||
10 | +MACHINE_CFLAGS_ALT ?= -march=native | ||
11 | + | ||
12 | +MACHINE_CFLAGS = $(MACHINE_CFLAGS_ALT) | ||
diff --git a/recipes-networking/dpdk/files/maketest.patch b/recipes-networking/dpdk/files/maketest.patch new file mode 100644 index 0000000..cae679a --- /dev/null +++ b/recipes-networking/dpdk/files/maketest.patch | |||
@@ -0,0 +1,41 @@ | |||
1 | Update test makefiles. | ||
2 | |||
3 | Signed-off-by: Costin Popescu <costin.popescu@enea.com> | ||
4 | Upstream-Status: Pending | ||
5 | |||
6 | diff --git a/mk/rte.sdkroot.mk b/mk/rte.sdkroot.mk | ||
7 | index 29af6a5..59bf972 100644 | ||
8 | --- a/mk/rte.sdkroot.mk | ||
9 | +++ b/mk/rte.sdkroot.mk | ||
10 | @@ -101,6 +101,10 @@ testall: | ||
11 | install uninstall: | ||
12 | $(Q)$(MAKE) -f $(RTE_SDK)/mk/rte.sdkinstall.mk $@ | ||
13 | |||
14 | +.PHONY: test-install | ||
15 | +test-install: | ||
16 | + $(Q)$(MAKE) -f $(RTE_SDK)/mk/rte.sdktest.mk $@ | ||
17 | + | ||
18 | .PHONY: doc help | ||
19 | doc: doc-all | ||
20 | help: doc-help | ||
21 | diff --git a/mk/rte.sdktest.mk b/mk/rte.sdktest.mk | ||
22 | index b2c043e..015aab5 100644 | ||
23 | --- a/mk/rte.sdktest.mk | ||
24 | +++ b/mk/rte.sdktest.mk | ||
25 | @@ -82,3 +82,16 @@ coverage: | ||
26 | else \ | ||
27 | echo "No test found, please do a 'make build' first, or specify O=" ;\ | ||
28 | fi | ||
29 | + | ||
30 | +test-install: | ||
31 | + install -d $(TEST_DESTDIR)/app/test | ||
32 | + install -d $(TEST_DESTDIR)/mk | ||
33 | + install -d $(TEST_DESTDIR)/$(TARGET_ARCH)-default-linuxapp-gcc | ||
34 | + install -d $(TEST_DESTDIR)/$(TARGET_ARCH)-default-linuxapp-gcc/app | ||
35 | + install $(DPDK_SRC_PATH)/$(TARGET_ARCH)-default-linuxapp-gcc/.config $(TEST_DESTDIR)/$(TARGET_ARCH)-default-linuxapp-gcc | ||
36 | + install $(DPDK_SRC_PATH)/$(TARGET_ARCH)-default-linuxapp-gcc/Makefile $(TEST_DESTDIR)/$(TARGET_ARCH)-default-linuxapp-gcc | ||
37 | + install $(DPDK_PATH)/$(TARGET_ARCH)-default-linuxapp-gcc/app/* $(TEST_DESTDIR)/$(TARGET_ARCH)-default-linuxapp-gcc/app/ | ||
38 | + install $(DPDK_SRC_PATH)/app/test/*.py $(TEST_DESTDIR)/app/test | ||
39 | + install $(DPDK_SRC_PATH)/Makefile $(TEST_DESTDIR) | ||
40 | + cp -r $(DPDK_SRC_PATH)/mk/* $(TEST_DESTDIR)/mk | ||
41 | + echo "make test O=$(TARGET_ARCH)-default-linuxapp-gcc" >> $(TEST_DESTDIR)/maketest | ||
diff --git a/recipes-networking/dpdk/files/rte_kni_module_1_6.patch.x b/recipes-networking/dpdk/files/rte_kni_module_1_6.patch.x new file mode 100644 index 0000000..48b1849 --- /dev/null +++ b/recipes-networking/dpdk/files/rte_kni_module_1_6.patch.x | |||
@@ -0,0 +1,206 @@ | |||
1 | --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | ||
2 | +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h | ||
3 | @@ -101,6 +101,7 @@ struct rte_kni_device_info { | ||
4 | |||
5 | /* mbuf size */ | ||
6 | unsigned mbuf_size; | ||
7 | + uint64_t mempool_size; | ||
8 | }; | ||
9 | |||
10 | #define KNI_DEVICE "kni" | ||
11 | --- a/lib/librte_eal/linuxapp/kni/kni_misc.c | ||
12 | +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c | ||
13 | @@ -21,6 +21,19 @@ MODULE_DESCRIPTION("Kernel Module for managing kni devices"); | ||
14 | |||
15 | #define KNI_MAX_DEVICES 32 | ||
16 | |||
17 | +#define PCI_VENDOR_ID_IVSHMEM 0x1AF4 | ||
18 | +#define PCI_DEVICE_ID_IVSHMEM 0x1110 | ||
19 | +#define BAR2 2 | ||
20 | +#define IVSHMEM_MAGIC 0x0BADC0DE | ||
21 | +#define IVSHMEM_METADATA_SIZE 0x4000 | ||
22 | +#define KNI_FIFO_COUNT_MAX 1024 | ||
23 | +#define KNI_FIFO_SIZE ((KNI_FIFO_COUNT_MAX) * sizeof(void *) + \ | ||
24 | + sizeof(struct rte_kni_fifo)) | ||
25 | + | ||
26 | +#define get_virt_addr(x) get_virt_addr_by_size(x,KNI_FIFO_SIZE) | ||
27 | +#define get_virt_addr_by_size(x,s) (has_ivshmem_metadata ? \ | ||
28 | + ioremap(x, s) : phys_to_virt(x)) | ||
29 | + | ||
30 | extern void kni_net_rx(struct kni_dev *kni); | ||
31 | extern void kni_net_init(struct net_device *dev); | ||
32 | extern void kni_net_config_lo_mode(char *lo_str); | ||
33 | @@ -47,6 +60,8 @@ static int kni_thread_single(void *unused); | ||
34 | /* KNI processing for multiple kernel thread mode */ | ||
35 | static int kni_thread_multiple(void *param); | ||
36 | |||
37 | +static int kni_has_ivshmem_metadata(void); | ||
38 | + | ||
39 | static struct file_operations kni_fops = { | ||
40 | .owner = THIS_MODULE, | ||
41 | .open = kni_open, | ||
42 | @@ -72,6 +87,7 @@ static unsigned multiple_kthread_on = 0; | ||
43 | |||
44 | static volatile unsigned long device_in_use; /* device in use flag */ | ||
45 | static struct task_struct *kni_kthread; | ||
46 | +static int has_ivshmem_metadata = 0; | ||
47 | |||
48 | /* kni list lock */ | ||
49 | static DECLARE_RWSEM(kni_list_lock); | ||
50 | @@ -100,6 +116,10 @@ kni_init(void) | ||
51 | /* Configure the lo mode according to the input parameter */ | ||
52 | kni_net_config_lo_mode(lo_mode); | ||
53 | |||
54 | + has_ivshmem_metadata = kni_has_ivshmem_metadata(); | ||
55 | + KNI_PRINT("IVSHMEM metadata %s \n", | ||
56 | + has_ivshmem_metadata ? "found" : "NOT found"); | ||
57 | + | ||
58 | KNI_PRINT("######## DPDK kni module loaded ########\n"); | ||
59 | |||
60 | return 0; | ||
61 | @@ -178,6 +198,19 @@ kni_release(struct inode *inode, struct file *file) | ||
62 | #endif | ||
63 | kni_dev_remove(dev); | ||
64 | list_del(&dev->list); | ||
65 | + | ||
66 | + if (has_ivshmem_metadata) { | ||
67 | + KNI_PRINT("iounmapping KNI FIFOs for device '%s'\n", dev->name); | ||
68 | + iounmap(dev->tx_q); | ||
69 | + iounmap(dev->rx_q); | ||
70 | + iounmap(dev->alloc_q); | ||
71 | + iounmap(dev->free_q); | ||
72 | + iounmap(dev->req_q); | ||
73 | + iounmap(dev->resp_q); | ||
74 | + iounmap(dev->sync_kva); | ||
75 | + iounmap(dev->mbuf_kva); | ||
76 | + } | ||
77 | + | ||
78 | } | ||
79 | up_write(&kni_list_lock); | ||
80 | |||
81 | @@ -339,17 +372,17 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned long ioctl_param) | ||
82 | strncpy(kni->name, dev_info.name, RTE_KNI_NAMESIZE); | ||
83 | |||
84 | /* Translate user space info into kernel space info */ | ||
85 | - kni->tx_q = phys_to_virt(dev_info.tx_phys); | ||
86 | - kni->rx_q = phys_to_virt(dev_info.rx_phys); | ||
87 | - kni->alloc_q = phys_to_virt(dev_info.alloc_phys); | ||
88 | - kni->free_q = phys_to_virt(dev_info.free_phys); | ||
89 | + kni->tx_q = get_virt_addr(dev_info.tx_phys); | ||
90 | + kni->rx_q = get_virt_addr(dev_info.rx_phys); | ||
91 | + kni->alloc_q = get_virt_addr(dev_info.alloc_phys); | ||
92 | + kni->free_q = get_virt_addr(dev_info.free_phys); | ||
93 | |||
94 | - kni->req_q = phys_to_virt(dev_info.req_phys); | ||
95 | - kni->resp_q = phys_to_virt(dev_info.resp_phys); | ||
96 | + kni->req_q = get_virt_addr(dev_info.req_phys); | ||
97 | + kni->resp_q = get_virt_addr(dev_info.resp_phys); | ||
98 | kni->sync_va = dev_info.sync_va; | ||
99 | - kni->sync_kva = phys_to_virt(dev_info.sync_phys); | ||
100 | + kni->sync_kva = get_virt_addr(dev_info.sync_phys); | ||
101 | |||
102 | - kni->mbuf_kva = phys_to_virt(dev_info.mbuf_phys); | ||
103 | + kni->mbuf_kva = get_virt_addr_by_size(dev_info.mbuf_phys, dev_info.mempool_size); | ||
104 | kni->mbuf_va = dev_info.mbuf_va; | ||
105 | |||
106 | #ifdef RTE_KNI_VHOST | ||
107 | @@ -552,6 +585,40 @@ kni_compat_ioctl(struct inode *inode, | ||
108 | return -EINVAL; | ||
109 | } | ||
110 | |||
111 | +static int | ||
112 | +kni_has_ivshmem_metadata(void) | ||
113 | +{ | ||
114 | + struct pci_dev *ivshm_dev = NULL; | ||
115 | + phys_addr_t ivshmem_metadata_addr = 0; | ||
116 | + void *ivshmem_metadata = NULL; | ||
117 | + int ivshmem_magic_number; | ||
118 | + | ||
119 | + ivshm_dev = pci_get_device(PCI_VENDOR_ID_IVSHMEM, PCI_DEVICE_ID_IVSHMEM, | ||
120 | + NULL); | ||
121 | + | ||
122 | + if (ivshm_dev == NULL) { | ||
123 | + printk("No IVSHMEM device found!\n"); | ||
124 | + return 0; | ||
125 | + } | ||
126 | + | ||
127 | + /* IVSHMEM metadata will be received at the very last 4K of the BAR2 */ | ||
128 | + ivshmem_metadata_addr = (pci_resource_end(ivshm_dev, BAR2) | ||
129 | + - IVSHMEM_METADATA_SIZE) + 1; | ||
130 | + | ||
131 | + ivshmem_metadata = ioremap(ivshmem_metadata_addr, IVSHMEM_METADATA_SIZE); | ||
132 | + if (ivshmem_metadata == NULL) { | ||
133 | + printk("Could not ioremap IVSHMEM metadata\n"); | ||
134 | + return 0; | ||
135 | + } | ||
136 | + | ||
137 | + /* The first sizeof(int) bytes contain the magic number that tells us | ||
138 | + * ivshmem_metadata is coming from the host */ | ||
139 | + ivshmem_magic_number = ((int*) ivshmem_metadata)[0]; | ||
140 | + iounmap(ivshmem_metadata); | ||
141 | + return !!(ivshmem_magic_number == IVSHMEM_MAGIC); | ||
142 | +} | ||
143 | + | ||
144 | + | ||
145 | module_init(kni_init); | ||
146 | module_exit(kni_exit); | ||
147 | |||
148 | --- a/lib/librte_eal/linuxapp/kni/kni_net.c | ||
149 | +++ b/lib/librte_eal/linuxapp/kni/kni_net.c | ||
150 | @@ -50,15 +50,16 @@ kni_net_open(struct net_device *dev) | ||
151 | struct rte_kni_request req; | ||
152 | struct kni_dev *kni = netdev_priv(dev); | ||
153 | |||
154 | - if (kni->lad_dev) | ||
155 | - memcpy(dev->dev_addr, kni->lad_dev->dev_addr, ETH_ALEN); | ||
156 | - else | ||
157 | - /* | ||
158 | - * Generate random mac address. eth_random_addr() is the newer | ||
159 | - * version of generating mac address in linux kernel. | ||
160 | - */ | ||
161 | - random_ether_addr(dev->dev_addr); | ||
162 | - | ||
163 | + if (!is_valid_ether_addr(dev->dev_addr)) { | ||
164 | + if (kni->lad_dev) | ||
165 | + memcpy(dev->dev_addr, kni->lad_dev->dev_addr, ETH_ALEN); | ||
166 | + else | ||
167 | + /* | ||
168 | + * Generate random mac address. eth_random_addr() is the newer | ||
169 | + * version of generating mac address in linux kernel. | ||
170 | + */ | ||
171 | + random_ether_addr(dev->dev_addr); | ||
172 | + } | ||
173 | netif_start_queue(dev); | ||
174 | |||
175 | memset(&req, 0, sizeof(req)); | ||
176 | @@ -459,6 +460,22 @@ kni_net_tx_timeout (struct net_device *dev) | ||
177 | return; | ||
178 | } | ||
179 | |||
180 | +static int | ||
181 | +kni_set_mac_address(struct net_device *dev, void *addr_ptr) | ||
182 | +{ | ||
183 | + struct sockaddr *addr = addr_ptr; | ||
184 | + | ||
185 | + if (netif_running(dev)) | ||
186 | + return -EBUSY; | ||
187 | + | ||
188 | + if (!is_valid_ether_addr(addr->sa_data)) | ||
189 | + return -EADDRNOTAVAIL; | ||
190 | + | ||
191 | + memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); | ||
192 | + | ||
193 | + return 0; | ||
194 | +} | ||
195 | + | ||
196 | /* | ||
197 | * Ioctl commands | ||
198 | */ | ||
199 | @@ -608,6 +625,7 @@ static const struct net_device_ops kni_net_netdev_ops = { | ||
200 | .ndo_do_ioctl = kni_net_ioctl, | ||
201 | .ndo_get_stats = kni_net_stats, | ||
202 | .ndo_tx_timeout = kni_net_tx_timeout, | ||
203 | + .ndo_set_mac_address = kni_set_mac_address, | ||
204 | }; | ||
205 | |||
206 | void | ||
diff --git a/recipes-networking/dpdk/files/run-ptest b/recipes-networking/dpdk/files/run-ptest new file mode 100644 index 0000000..76fd407 --- /dev/null +++ b/recipes-networking/dpdk/files/run-ptest | |||
@@ -0,0 +1,195 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | export RTE_SDK=/opt/dpdk | ||
4 | export RTE_TARGET=x86_64-default-linuxapp-gcc | ||
5 | export RTE_ARCH=x86_64 | ||
6 | RTE_SRC=/usr/src/dpdk | ||
7 | HUGE_PAGES_MEM=2097152 #[1024 * 2048kB] | ||
8 | |||
9 | #check hugetlbfs mount | ||
10 | echo -n "Mounting hugepages..." | ||
11 | mount | grep "nodev on /mnt/huge type hugetlbfs" | ||
12 | if [ $? -ne 0 ]; then | ||
13 | mkdir -p /mnt/huge | ||
14 | mount -t hugetlbfs nodev /mnt/huge | ||
15 | fi | ||
16 | echo "OK!" | ||
17 | |||
18 | #increase hugepages for all nodes | ||
19 | echo -n "Allocating hugepages..." | ||
20 | #get hugepages sizes | ||
21 | hp_sz=`cat /proc/meminfo | grep Hugepagesize | sed -r "s/Hugepagesize:[^0-9]*([0-9]+) kB/\1/"` | ||
22 | #calculate huge pages number to get the equivalent of 1024 pages of 2MB | ||
23 | huge_pages_no=`expr ${HUGE_PAGES_MEM} / ${hp_sz}` | ||
24 | #get hugepages no | ||
25 | hp=0 | ||
26 | #Find out if this is a NUMA machine | ||
27 | ls /sys/devices/system/node/node* > /dev/null 2>&1 | ||
28 | if [ $? -ne 0 ]; then | ||
29 | hp=`cat /proc/sys/vm/nr_hugepages` | ||
30 | hptest=`expr $hp + $huge_pages_no` | ||
31 | echo $hptest > /proc/sys/vm/nr_hugepages | ||
32 | else | ||
33 | hparray=() | ||
34 | nodes=`ls /sys/devices/system/node | grep node | wc -l` | ||
35 | for (( i=0; $i<$nodes; i++ )) | ||
36 | do | ||
37 | hp=`cat /sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages` | ||
38 | hptest=`expr $hp + $huge_pages_no` | ||
39 | echo $hptest > /sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages | ||
40 | hparray+=("$hp") | ||
41 | done | ||
42 | fi | ||
43 | echo "OK!" | ||
44 | echo "Allocated ${huge_pages_no} x ${hp_sz}kB" | ||
45 | |||
46 | #run l2fwd loopback test | ||
47 | DEVS=("I350" "82599") | ||
48 | PCI_UTIL=${RTE_SRC}/tools/pci_unbind.py | ||
49 | IGB_UIO=${RTE_SDK}/${RTE_TARGET}/kmod/igb_uio.ko | ||
50 | RTE_KNI=${RTE_SDK}/${RTE_TARGET}/kmod/rte_kni.ko | ||
51 | |||
52 | rmmod rte_kni > /dev/null 2>&1 | ||
53 | rmmod igb_uio > /dev/null 2>&1 | ||
54 | modprobe uio && insmod ${IGB_UIO} | ||
55 | |||
56 | #insert igb_uio, needed by some dpdk tests | ||
57 | if [ $? -ne 0 ]; then | ||
58 | echo "FAIL: uio/igb_uio load" | ||
59 | DEVS=() | ||
60 | else | ||
61 | echo "PASS: uio/igb_uio load" | ||
62 | fi | ||
63 | |||
64 | #insert rte_kni driver in loopback mode, needed by KNI tests | ||
65 | insmod ${RTE_KNI} lo_mode=lo_mode_fifo | ||
66 | |||
67 | if [ $? -ne 0 ]; then | ||
68 | echo "FAIL: rte_kni load" | ||
69 | DEVS=() | ||
70 | else | ||
71 | echo "PASS: rte_kni load" | ||
72 | fi | ||
73 | |||
74 | #bind devices to igb_uio, needed by some dpdk tests | ||
75 | drvarray=() | ||
76 | pciarray=() | ||
77 | for dev in ${DEVS[@]} | ||
78 | do | ||
79 | DEV_INFO=`${PCI_UTIL} --status|grep ${dev}|grep -v -i 'active'|head -n 1` | ||
80 | if [ -z "$DEV_INFO" ] || [ "$DEV_INFO" == " " ] ; then | ||
81 | continue | ||
82 | fi | ||
83 | |||
84 | DEV_PCI_ADDR=`echo ${DEV_INFO}|sed -r "s/([^ ]*) .*/\1/"` | ||
85 | DEV_NAME=`echo ${DEV_INFO}|sed -r "s/.*'(.*)'.*/\1/"` | ||
86 | DEV_ETH=`echo ${DEV_INFO}|grep eth=|sed -r "s/.*if=([^ ]*).*/\1/"` | ||
87 | DEV_DRV=`echo ${DEV_INFO}|sed -r "s/.*drv=([^ ]*).*/\1/"` | ||
88 | |||
89 | echo "Testing device: $DEV_NAME(pci $DEV_PCI_ADDR, eth $DEV_ETH, drv $DEV_DRV)" | ||
90 | |||
91 | if [ ! -z ${DEV_ETH} ]; then | ||
92 | ifconfig ${DEV_ETH} down | ||
93 | fi | ||
94 | |||
95 | ${PCI_UTIL} --bind=igb_uio ${DEV_PCI_ADDR} | ||
96 | drvarray+=("${DEV_DRV}") | ||
97 | pciarray+=("${DEV_PCI_ADDR}") | ||
98 | done | ||
99 | |||
100 | #run dpdk tests | ||
101 | python ${RTE_SRC}/app/test/autotest.py ./test ${RTE_TARGET} | ||
102 | |||
103 | #bind devices to initial drivers | ||
104 | for ((i=0;i<${#pciarray[@]};i++)); | ||
105 | do | ||
106 | echo "${PCI_UTIL} --bind=${drvarray[$i]} ${pciarray[$i]}" | ||
107 | ${PCI_UTIL} --bind=${drvarray[$i]} ${pciarray[$i]} | ||
108 | done | ||
109 | |||
110 | for dev in ${DEVS[@]} | ||
111 | do | ||
112 | DEV_INFO=`${PCI_UTIL} --status|grep ${dev}|grep -v -i 'active'|head -n 1` | ||
113 | if [ -z "$DEV_INFO" ] || [ "$DEV_INFO" == " " ] ; then | ||
114 | echo "SKIP: l2fwd-lpbk ($dev)" | ||
115 | continue | ||
116 | fi | ||
117 | |||
118 | DEV_PCI_ADDR=`echo ${DEV_INFO}|sed -r "s/([^ ]*) .*/\1/"` | ||
119 | DEV_NAME=`echo ${DEV_INFO}|sed -r "s/.*'(.*)'.*/\1/"` | ||
120 | DEV_ETH=`echo ${DEV_INFO}|grep eth=|sed -r "s/.*if=([^ ]*).*/\1/"` | ||
121 | DEV_DRV=`echo ${DEV_INFO}|sed -r "s/.*drv=([^ ]*).*/\1/"` | ||
122 | |||
123 | echo "Testing device: $DEV_NAME(pci $DEV_PCI_ADDR, eth $DEV_ETH, drv $DEV_DRV)" | ||
124 | |||
125 | if [ ! -z ${DEV_ETH} ]; then | ||
126 | ifconfig ${DEV_ETH} down | ||
127 | fi | ||
128 | |||
129 | ${PCI_UTIL} --bind=igb_uio ${DEV_PCI_ADDR} | ||
130 | |||
131 | ./l2fwd-lpbk -c 0xff -n 2 --use-device=${DEV_PCI_ADDR} -- -p 0x1 -t 128 -s 64 -T 10 -l > ${DEV_PCI_ADDR}.log 2>&1 & | ||
132 | APP_PID=$! | ||
133 | sleep 20 | ||
134 | kill $APP_PID | ||
135 | |||
136 | DEV_SENT=`cat ${DEV_PCI_ADDR}.log|grep "Packets sent:"|tail -n 1|sed -r "s/.* ([0-9]*)/\1/"` | ||
137 | DEV_RECV=`cat ${DEV_PCI_ADDR}.log|grep "Packets received:"|tail -n 1|sed -r "s/.* ([0-9]*)/\1/"` | ||
138 | DEV_DROP=`cat ${DEV_PCI_ADDR}.log|grep "Packets dropped:"|tail -n 1|sed -r "s/.* ([0-9]*)/\1/"` | ||
139 | |||
140 | |||
141 | echo "Results: sent $DEV_SENT, received $DEV_RECV, dropped $DEV_DROP" | ||
142 | |||
143 | STATUS=0 | ||
144 | |||
145 | case "$dev" in | ||
146 | "I350") | ||
147 | if [ ${DEV_SENT} -lt 13000000 ]; then | ||
148 | STATUS=1 | ||
149 | fi | ||
150 | ;; | ||
151 | "82599") | ||
152 | if [ ${DEV_SENT} -lt 110000000 ]; then | ||
153 | STATUS=1 | ||
154 | fi | ||
155 | ;; | ||
156 | esac | ||
157 | |||
158 | if [ ${STATUS} -ne 0 ]; then | ||
159 | echo "FAIL: l2fwd-lpbk (low throughput)" | ||
160 | fi | ||
161 | |||
162 | if [ ${STATUS} -eq 0 ] && { [ ${DEV_DROP} -ne 0 ] || [ ${DEV_SENT} -ne ${DEV_RECV} ]; } then | ||
163 | echo "FAIL: l2fwd-lpbk (dropped packets)" | ||
164 | STATUS=1 | ||
165 | fi | ||
166 | |||
167 | if [ ${STATUS} -eq 0 ]; then | ||
168 | echo "PASS: l2fwd-lpbk ($dev)" | ||
169 | fi | ||
170 | |||
171 | ${PCI_UTIL} --bind=${DEV_DRV} ${DEV_PCI_ADDR} | ||
172 | done | ||
173 | |||
174 | if [ ! -z ${DEVS} ]; then | ||
175 | rmmod rte_kni > /dev/null 2>&1 | ||
176 | rmmod igb_uio > /dev/null 2>&1 | ||
177 | rmmod uio > /dev/null 2>&1 | ||
178 | fi | ||
179 | |||
180 | echo -n "Freeing hugepages..." | ||
181 | #Find out if this is a NUMA machine | ||
182 | ls /sys/devices/system/node/node* > /dev/null 2>&1 | ||
183 | if [ $? -ne 0 ]; then | ||
184 | echo $hp > /proc/sys/vm/nr_hugepages | ||
185 | else | ||
186 | i=0 | ||
187 | for hp in ${hparray[@]} | ||
188 | do | ||
189 | echo $hp > "/sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages" | ||
190 | ((i++)) | ||
191 | done | ||
192 | fi | ||
193 | echo "OK!" | ||
194 | rm -rf /mnt/huge/* | ||
195 | |||
diff --git a/recipes-networking/dpdk/files/runtest.patch b/recipes-networking/dpdk/files/runtest.patch new file mode 100644 index 0000000..0432fb7 --- /dev/null +++ b/recipes-networking/dpdk/files/runtest.patch | |||
@@ -0,0 +1,20 @@ | |||
1 | Adapt test output. | ||
2 | |||
3 | Signed-off-by: Costin Popescu <costin.popescu@enea.com> | ||
4 | Upstream-Status: Pending | ||
5 | |||
6 | diff --git a/app/test/autotest_runner.py b/app/test/autotest_runner.py | ||
7 | index af225ff..33b776a 100644 | ||
8 | --- a/app/test/autotest_runner.py | ||
9 | +++ b/app/test/autotest_runner.py | ||
10 | @@ -267,6 +267,10 @@ class AutotestRunner: | ||
11 | # if test failed and it wasn't a "start" test | ||
12 | if test_result < 0 and not i == 0: | ||
13 | self.fails += 1 | ||
14 | + if test_result < 0: | ||
15 | + print "FAIL: %s" % test_name | ||
16 | + else: | ||
17 | + print "PASS: %s" % test_name | ||
18 | |||
19 | # collect logs | ||
20 | self.log_buffers.append(log) | ||
diff --git a/recipes-networking/dpdk/files/unbreak-makefiles.patch b/recipes-networking/dpdk/files/unbreak-makefiles.patch new file mode 100644 index 0000000..f96dd68 --- /dev/null +++ b/recipes-networking/dpdk/files/unbreak-makefiles.patch | |||
@@ -0,0 +1,87 @@ | |||
1 | Fix makefiles. | ||
2 | |||
3 | Signed-off-by: Costin Popescu <costin.popescu@enea.com> | ||
4 | Upstream-Status: Pending | ||
5 | |||
6 | diff --git a/mk/rte.app.mk b/mk/rte.app.mk | ||
7 | index d90a0b0..93f1dd9 100644 | ||
8 | --- a/mk/rte.app.mk | ||
9 | +++ b/mk/rte.app.mk | ||
10 | @@ -203,6 +203,7 @@ endif | ||
11 | |||
12 | ifeq ($(LINK_USING_CC),1) | ||
13 | comma := , | ||
14 | +LDFLAGS := $(patsubst -Wl$(comma)%,%,$(LDFLAGS)) | ||
15 | LDLIBS := $(addprefix -Wl$(comma),$(LDLIBS)) | ||
16 | LDFLAGS := $(addprefix -Wl$(comma),$(LDFLAGS)) | ||
17 | override EXTRA_LDFLAGS := $(addprefix -Wl$(comma),$(EXTRA_LDFLAGS)) | ||
18 | diff --git a/mk/target/generic/rte.vars.mk b/mk/target/generic/rte.vars.mk | ||
19 | index a163272..9fb07d8 100644 | ||
20 | --- a/mk/target/generic/rte.vars.mk | ||
21 | +++ b/mk/target/generic/rte.vars.mk | ||
22 | @@ -107,7 +107,7 @@ ifeq ($(KERNELRELEASE),) | ||
23 | include $(RTE_SDK)/mk/rte.cpuflags.mk | ||
24 | |||
25 | # merge all CFLAGS | ||
26 | -CFLAGS := $(CPU_CFLAGS) $(EXECENV_CFLAGS) $(TOOLCHAIN_CFLAGS) $(MACHINE_CFLAGS) | ||
27 | +CFLAGS += $(CPU_CFLAGS) $(EXECENV_CFLAGS) $(TOOLCHAIN_CFLAGS) $(MACHINE_CFLAGS) | ||
28 | CFLAGS += $(TARGET_CFLAGS) $(EXTERNAL_LIB_CFLAGS) | ||
29 | |||
30 | # merge all LDFLAGS | ||
31 | @@ -115,7 +115,7 @@ LDFLAGS := $(CPU_LDFLAGS) $(EXECENV_LDFLAGS) $(TOOLCHAIN_LDFLAGS) $(MACHINE_LDFL | ||
32 | LDFLAGS += $(TARGET_LDFLAGS) | ||
33 | |||
34 | # merge all ASFLAGS | ||
35 | -ASFLAGS := $(CPU_ASFLAGS) $(EXECENV_ASFLAGS) $(TOOLCHAIN_ASFLAGS) $(MACHINE_ASFLAGS) | ||
36 | +ASFLAGS += $(CPU_ASFLAGS) $(EXECENV_ASFLAGS) $(TOOLCHAIN_ASFLAGS) $(MACHINE_ASFLAGS) | ||
37 | ASFLAGS += $(TARGET_ASFLAGS) | ||
38 | |||
39 | # add default include and lib paths | ||
40 | diff --git a/mk/toolchain/gcc/rte.vars.mk b/mk/toolchain/gcc/rte.vars.mk | ||
41 | index 0edb93f..adba7d4 100644 | ||
42 | --- a/mk/toolchain/gcc/rte.vars.mk | ||
43 | +++ b/mk/toolchain/gcc/rte.vars.mk | ||
44 | @@ -40,21 +40,20 @@ | ||
45 | # examples for RTE_TOOLCHAIN: gcc, icc | ||
46 | # | ||
47 | |||
48 | -CC = $(CROSS)gcc | ||
49 | -CPP = $(CROSS)cpp | ||
50 | -# for now, we don't use as but nasm. | ||
51 | -# AS = $(CROSS)as | ||
52 | -AS = nasm | ||
53 | -AR = $(CROSS)ar | ||
54 | -LD = $(CROSS)ld | ||
55 | -OBJCOPY = $(CROSS)objcopy | ||
56 | -OBJDUMP = $(CROSS)objdump | ||
57 | -STRIP = $(CROSS)strip | ||
58 | -READELF = $(CROSS)readelf | ||
59 | -GCOV = $(CROSS)gcov | ||
60 | +CC ?= $(CROSS)gcc | ||
61 | +CPP ?= $(CROSS)cpp | ||
62 | +AS ?= $(CROSS)as | ||
63 | +#AS ?= nasm | ||
64 | +AR ?= $(CROSS)ar | ||
65 | +LD ?= $(CROSS)ld | ||
66 | +OBJCOPY ?= $(CROSS)objcopy | ||
67 | +OBJDUMP ?= $(CROSS)objdump | ||
68 | +STRIP ?= $(CROSS)strip | ||
69 | +READELF ?= $(CROSS)readelf | ||
70 | +GCOV ?= $(CROSS)gcov | ||
71 | |||
72 | -HOSTCC = gcc | ||
73 | -HOSTAS = as | ||
74 | +HOSTCC ?= gcc | ||
75 | +HOSTAS ?= as | ||
76 | |||
77 | TOOLCHAIN_ASFLAGS = | ||
78 | TOOLCHAIN_CFLAGS = | ||
79 | @@ -68,7 +67,7 @@ ifeq (,$(findstring -O0,$(EXTRA_CFLAGS))) | ||
80 | endif | ||
81 | endif | ||
82 | |||
83 | -WERROR_FLAGS := -W -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes | ||
84 | +WERROR_FLAGS := -W -Wall -Wstrict-prototypes -Wmissing-prototypes | ||
85 | WERROR_FLAGS += -Wmissing-declarations -Wold-style-definition -Wpointer-arith | ||
86 | WERROR_FLAGS += -Wcast-align -Wnested-externs -Wcast-qual | ||
87 | WERROR_FLAGS += -Wformat-nonliteral -Wformat-security | ||