From 1b6242fc583a6b871304fb995af6dc211b58f69b Mon Sep 17 00:00:00 2001 From: Adrian Dudau Date: Thu, 26 Jun 2014 13:48:23 +0200 Subject: initial commit for Enea Linux 4.0 Migrated from the internal git server on the daisy-enea branch Signed-off-by: Adrian Dudau --- recipes-networking/dpdk/dpdk_git.bb | 139 +++ .../dpdk/files/igb_ethdev_loopback.patch | 96 +++ recipes-networking/dpdk/files/l2fwd-lpbk/Makefile | 51 ++ recipes-networking/dpdk/files/l2fwd-lpbk/main.c | 929 +++++++++++++++++++++ recipes-networking/dpdk/files/l2fwd-lpbk/main.h | 45 + recipes-networking/dpdk/files/machine-flags.patch | 12 + recipes-networking/dpdk/files/maketest.patch | 41 + .../dpdk/files/rte_kni_module_1_6.patch.x | 206 +++++ recipes-networking/dpdk/files/run-ptest | 195 +++++ recipes-networking/dpdk/files/runtest.patch | 20 + .../dpdk/files/unbreak-makefiles.patch | 87 ++ 11 files changed, 1821 insertions(+) create mode 100644 recipes-networking/dpdk/dpdk_git.bb create mode 100644 recipes-networking/dpdk/files/igb_ethdev_loopback.patch create mode 100644 recipes-networking/dpdk/files/l2fwd-lpbk/Makefile create mode 100644 recipes-networking/dpdk/files/l2fwd-lpbk/main.c create mode 100644 recipes-networking/dpdk/files/l2fwd-lpbk/main.h create mode 100644 recipes-networking/dpdk/files/machine-flags.patch create mode 100644 recipes-networking/dpdk/files/maketest.patch create mode 100644 recipes-networking/dpdk/files/rte_kni_module_1_6.patch.x create mode 100644 recipes-networking/dpdk/files/run-ptest create mode 100644 recipes-networking/dpdk/files/runtest.patch create mode 100644 recipes-networking/dpdk/files/unbreak-makefiles.patch (limited to 'recipes-networking/dpdk') 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 @@ +SUMMARY = "DPDK" +DESCRIPTION = "DPDK - a novel framework for fast packet I/O" +HOMEPAGE = "http://dpdk.org" +SECTION = "devel" +LICENSE = "GPLv2 | LGPLv2 | BSD" +LIC_FILES_CHKSUM = "file://LICENSE.GPL;md5=751419260aa954499f7abaabaa882bbe \ + file://LICENSE.LGPL;md5=4fbd65380cdd255951079008b364516c \ + file://lib/librte_eal/common/include/rte_version.h;beginline=1;endline=33;md5=ab6d502a4a25ded2bbabf031720bd1f4" + +PR = "r1" +PV = "1.6.0" +DEPENDS += "virtual/kernel" + +inherit module-base + +addtask make_scripts after do_patch before do_compile +do_make_scripts[lockfiles] = "${TMPDIR}/kernel-scripts.lock" +do_make_scripts[deptask] = "do_populate_sysroot" + +SRCREV = "v1.6.0r1" +SRC_URI = "git://dpdk.org/git/dpdk;protocol=http;branch=1.6.0 \ + file://unbreak-makefiles.patch \ + file://runtest.patch \ + file://run-ptest \ + file://igb_ethdev_loopback.patch \ + file://l2fwd-lpbk \ + file://machine-flags.patch \ + file://rte_kni_module_1_6.patch.x \ + " + +DPDK_TARGET_DEFAULT = "${TARGET_ARCH}-default-linuxapp-gcc" +DPDK_TARGET_IVSHMEM = "${TARGET_ARCH}-ivshmem-linuxapp-gcc" + +DPDK_BUILD_DIR = "build" +DPDK_VAR_O = "${S}/${DPDK_BUILD_DIR}" +DPDK_VAR_DESTDIR = "${WORKDIR}/install" + +DPDK_SRC_PATH = "/usr/src/dpdk" +DPDK_INSTALL_PATH = "/opt/dpdk" + +S = "${WORKDIR}/git" +B = "${S}" + +PACKAGES = "${PN}-dbg ${PN} ${PN}-mk ${PN}-scripts" +PACKAGES += "${PN}-default-dbg ${PN}-default-staticdev ${PN}-default" + +RDEPENDS_${PN} += "pciutils" +RDEPENDS_${PN}-default = "${PN}-mk ${PN}-scripts ${PN}-default-staticdev pciutils" +RRECOMMENDS_${PN} += "kernel-module-uio kernel-module-pci-stub" + +FILES_${PN} = "${DPDK_SRC_PATH}" +FILES_${PN}-dbg = "/usr/src/debug" +FILES_${PN}-mk = "${DPDK_INSTALL_PATH}/mk" +FILES_${PN}-scripts = "${DPDK_INSTALL_PATH}/scripts" + +FILES_${PN}-default = "${DPDK_INSTALL_PATH}/${TARGET_ARCH}-default-linuxapp-gcc" +FILES_${PN}-default-dbg = "${DPDK_INSTALL_PATH}/${TARGET_ARCH}-default-linuxapp-gcc/app/.debug" +FILES_${PN}-default-staticdev = "${DPDK_INSTALL_PATH}/${TARGET_ARCH}-default-linuxapp-gcc/lib" + +do_compile() { + cd ${S} && oe_runmake install \ + RTE_KERNELDIR=${STAGING_KERNEL_DIR} \ + RTE_MACHINE=default \ + prefix="" \ + V=1 KBUILD_VERBOSE=1 CROSS=${TARGET_SYS}- \ + O=${DPDK_VAR_O} \ + T=${DPDK_TARGET_DEFAULT} \ + DESTDIR=${DPDK_VAR_DESTDIR} \ + MACHINE_CFLAGS_ALT="${TARGET_CC_ARCH}" + + #patched version of IVSHMEM target for OVS-DPDK - installed to staging only + cd ${S} && git apply ${WORKDIR}/rte_kni_module_1_6.patch.x && \ + oe_runmake install \ + RTE_KERNELDIR=${STAGING_KERNEL_DIR} \ + RTE_MACHINE=default \ + prefix="" \ + V=1 KBUILD_VERBOSE=1 CROSS=${TARGET_SYS}- \ + O=${DPDK_VAR_O} \ + T=${DPDK_TARGET_IVSHMEM} \ + DESTDIR=${DPDK_VAR_DESTDIR} \ + MACHINE_CFLAGS_ALT="${TARGET_CC_ARCH}" \ + EXTRA_CFLAGS=-fPIC && \ + git apply --reverse ${WORKDIR}/rte_kni_module_1_6.patch.x \ +} + +do_install() { + # dpdk + install -d ${D}${DPDK_SRC_PATH} + cd ${S} && find . -depth -not -path "./${DPDK_BUILD_DIR}*" -not -path "./patches*" -not -path "./.*" -print0 |\ + cpio --null -pdlu ${D}${DPDK_SRC_PATH} + + # install sources to staging + cd ${S} && find . -depth -not -path "./${DPDK_BUILD_DIR}*" -not -path "./patches*" -not -path "./.*" -print0 |\ + cpio --null -pdlu ${STAGING_DIR_HOST}${DPDK_SRC_PATH} + + # install build to staging + cd ${DPDK_VAR_DESTDIR} && find . -print0 | cpio --null -pdlu ${STAGING_DIR_HOST}${DPDK_INSTALL_PATH} + + # install build output - skip OVS-DPDK IVSHMEM + install -d ${D}${DPDK_INSTALL_PATH} + cd ${DPDK_VAR_DESTDIR} && find . -depth -not -path "./${DPDK_TARGET_IVSHMEM}*" -print0 |\ + cpio --null -pdlu ${D}${DPDK_INSTALL_PATH} + + # add "scripts" directory to build output and staging, relpath.sh is needed by makefiles + cp -r ${S}/scripts ${D}${DPDK_INSTALL_PATH} + cp -r ${S}/scripts ${STAGING_DIR_HOST}${DPDK_INSTALL_PATH} + # relpath.sh use of $prefix breaks openvswitch + sed -i 's/prefix/path_prefix/g' ${STAGING_DIR_HOST}${DPDK_INSTALL_PATH}/scripts/relpath.sh +} + +COMPATIBLE_HOST = '(x86_64.*|i.86.*)-(linux.*)' + +#test default target + +inherit ptest + +RDEPENDS_${PN}-ptest += "\ + make \ + python-pexpect \ + ${PN}-default \ + ${PN} \ + " + +do_compile_ptest () { + cd ${WORKDIR}/l2fwd-lpbk && oe_runmake RTE_SDK="${DPDK_VAR_DESTDIR}" \ + RTE_TARGET="${DPDK_TARGET_DEFAULT}" RTE_ARCH="${TARGET_ARCH}" + sed -i 's|RTE_SDK=.*|RTE_SDK=${DPDK_INSTALL_PATH}|g' ${WORKDIR}/run-ptest + sed -i 's|RTE_TARGET=.*|RTE_TARGET=${DPDK_TARGET_DEFAULT}|g' ${WORKDIR}/run-ptest + sed -i 's|RTE_ARCH=.*|RTE_ARCH=${TARGET_ARCH}|g' ${WORKDIR}/run-ptest +} + +do_install_ptest () { + #install l2fwd loopback app + install ${WORKDIR}/l2fwd-lpbk/build/app/l2fwd-lpbk ${D}${PTEST_PATH} + + #install original test file to be used by autotest.py + install ${DPDK_VAR_O}/${DPDK_TARGET_DEFAULT}/app/test ${D}${PTEST_PATH} +} + 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 @@ +Index: dpdk/lib/librte_pmd_e1000/igb_ethdev.c +=================================================================== +--- dpdk.orig/lib/librte_pmd_e1000/igb_ethdev.c 2014-03-11 12:35:49.267083184 +0200 ++++ dpdk/lib/librte_pmd_e1000/igb_ethdev.c 2014-03-11 12:36:23.015082260 +0200 +@@ -701,50 +701,67 @@ + E1000_WRITE_REG(hw, E1000_EITR(0), 0xFFFF); + } + +- /* Setup link speed and duplex */ +- switch (dev->data->dev_conf.link_speed) { +- case ETH_LINK_SPEED_AUTONEG: ++ if (dev->data->dev_conf.lpbk_mode == 1) { ++ uint32_t reg; ++ ++ reg = E1000_READ_REG(hw, E1000_RCTL); ++ reg |= E1000_RCTL_LBM_MAC; ++ E1000_WRITE_REG(hw, E1000_RCTL, reg); ++ ++ reg = E1000_READ_REG(hw, E1000_CTRL); ++ reg |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX | E1000_CTRL_FD | ++ E1000_CTRL_SPD_1000); ++ E1000_WRITE_REG(hw, E1000_CTRL, reg); ++ ++ reg = E1000_READ_REG(hw, E1000_EEER); ++ reg |= (1 << 28); ++ E1000_WRITE_REG(hw, E1000_EEER, reg); ++ } else { ++ /* Setup link speed and duplex */ ++ switch (dev->data->dev_conf.link_speed) { ++ case ETH_LINK_SPEED_AUTONEG: + if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX) +- hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX; ++ hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX; + else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX) +- hw->phy.autoneg_advertised = E1000_ALL_HALF_DUPLEX; ++ hw->phy.autoneg_advertised = E1000_ALL_HALF_DUPLEX; + else if (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX) +- hw->phy.autoneg_advertised = E1000_ALL_FULL_DUPLEX; ++ hw->phy.autoneg_advertised = E1000_ALL_FULL_DUPLEX; + else +- goto error_invalid_config; ++ goto error_invalid_config; + break; +- case ETH_LINK_SPEED_10: ++ case ETH_LINK_SPEED_10: + if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX) +- hw->phy.autoneg_advertised = E1000_ALL_10_SPEED; ++ hw->phy.autoneg_advertised = E1000_ALL_10_SPEED; + else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX) +- hw->phy.autoneg_advertised = ADVERTISE_10_HALF; ++ hw->phy.autoneg_advertised = ADVERTISE_10_HALF; + else if (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX) +- hw->phy.autoneg_advertised = ADVERTISE_10_FULL; ++ hw->phy.autoneg_advertised = ADVERTISE_10_FULL; + else +- goto error_invalid_config; ++ goto error_invalid_config; + break; +- case ETH_LINK_SPEED_100: ++ case ETH_LINK_SPEED_100: + if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX) +- hw->phy.autoneg_advertised = E1000_ALL_100_SPEED; ++ hw->phy.autoneg_advertised = E1000_ALL_100_SPEED; + else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX) +- hw->phy.autoneg_advertised = ADVERTISE_100_HALF; ++ hw->phy.autoneg_advertised = ADVERTISE_100_HALF; + else if (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX) +- hw->phy.autoneg_advertised = ADVERTISE_100_FULL; ++ hw->phy.autoneg_advertised = ADVERTISE_100_FULL; + else +- goto error_invalid_config; ++ goto error_invalid_config; + break; +- case ETH_LINK_SPEED_1000: ++ case ETH_LINK_SPEED_1000: + if ((dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX) || +- (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX)) +- hw->phy.autoneg_advertised = ADVERTISE_1000_FULL; ++ (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX)) ++ hw->phy.autoneg_advertised = ADVERTISE_1000_FULL; + else +- goto error_invalid_config; ++ goto error_invalid_config; + break; +- case ETH_LINK_SPEED_10000: +- default: ++ case ETH_LINK_SPEED_10000: ++ default: + goto error_invalid_config; ++ } ++ e1000_setup_link(hw); + } +- e1000_setup_link(hw); + + /* check if lsc interrupt feature is enabled */ + 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 @@ +# BSD LICENSE +# +# Copyright(c) 2010-2013 Intel Corporation. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +ifeq ($(RTE_SDK),) +$(error "Please define RTE_SDK environment variable") +endif + +# Default target, can be overriden by command line or environment +RTE_TARGET ?= x86_64-default-linuxapp-gcc + +include $(RTE_SDK)/mk/rte.vars.mk + +# binary name +APP = l2fwd-lpbk + +# all source are stored in SRCS-y +SRCS-y := main.c + +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) + +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 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2010-2013 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "main.h" + +#define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 + +#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) +#define NB_MBUF 8192 + +/* + * RX and TX Prefetch, Host, and Write-back threshold values should be + * carefully set for optimal performance. Consult the network + * controller's datasheet and supporting DPDK documentation for guidance + * on how these parameters should be set. + */ +#define RX_PTHRESH 8 /**< Default values of RX prefetch threshold reg. */ +#define RX_HTHRESH 8 /**< Default values of RX host threshold reg. */ +#define RX_WTHRESH 4 /**< Default values of RX write-back threshold reg. */ + +/* + * These default values are optimized for use with the Intel(R) 82599 10 GbE + * Controller and the DPDK ixgbe PMD. Consider using other values for other + * network controllers and/or network drivers. + */ +#define TX_PTHRESH 36 /**< Default values of TX prefetch threshold reg. */ +#define TX_HTHRESH 0 /**< Default values of TX host threshold reg. */ +#define TX_WTHRESH 0 /**< Default values of TX write-back threshold reg. */ + +#define MAX_PKT_BURST 32 +#define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */ + +/* + * Configurable number of RX/TX ring descriptors + */ +#define RTE_TEST_RX_DESC_DEFAULT 128 +#define RTE_TEST_TX_DESC_DEFAULT 512 +static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT; +static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT; + +/* ethernet addresses of ports */ +static struct ether_addr l2fwd_ports_eth_addr[RTE_MAX_ETHPORTS]; + +/* mask of enabled ports */ +static uint32_t l2fwd_enabled_port_mask = 0; + +/* list of enabled ports */ +static uint32_t l2fwd_dst_ports[RTE_MAX_ETHPORTS]; + +static unsigned int l2fwd_rx_queue_per_lcore = 1; + +#define MIN_TX_SIZE 64 +#define MAX_TX_SIZE 2048 +static int l2fwd_tx_size = MIN_TX_SIZE; + +#define MAX_TX_COUNT 128 +static int l2fwd_tx_count = 0; + +static int l2fwd_loopback = 0; + +struct mbuf_table { + unsigned len; + struct rte_mbuf *m_table[MAX_PKT_BURST]; +}; + +#define MAX_RX_QUEUE_PER_LCORE 16 +#define MAX_TX_QUEUE_PER_PORT 16 +struct lcore_queue_conf { + unsigned n_rx_port; + unsigned rx_port_list[MAX_RX_QUEUE_PER_LCORE]; + struct mbuf_table tx_mbufs[RTE_MAX_ETHPORTS]; + +} __rte_cache_aligned; +struct lcore_queue_conf lcore_queue_conf[RTE_MAX_LCORE]; + +static struct rte_eth_conf port_conf = { + .rxmode = { + .split_hdr_size = 0, + .header_split = 0, /**< Header Split disabled */ + .hw_ip_checksum = 0, /**< IP checksum offload disabled */ + .hw_vlan_filter = 0, /**< VLAN filtering disabled */ + .jumbo_frame = 0, /**< Jumbo Frame Support disabled */ + .hw_strip_crc = 0, /**< CRC stripped by hardware */ + }, + .txmode = { + .mq_mode = ETH_MQ_TX_NONE, + }, +}; + +static const struct rte_eth_rxconf rx_conf = { + .rx_thresh = { + .pthresh = RX_PTHRESH, + .hthresh = RX_HTHRESH, + .wthresh = RX_WTHRESH, + }, +}; + +static const struct rte_eth_txconf tx_conf = { + .tx_thresh = { + .pthresh = TX_PTHRESH, + .hthresh = TX_HTHRESH, + .wthresh = TX_WTHRESH, + }, + .tx_free_thresh = 0, /* Use PMD default values */ + .tx_rs_thresh = 0, /* Use PMD default values */ +}; + +struct rte_mempool * l2fwd_pktmbuf_pool = NULL; + +/* Per-port statistics struct */ +struct l2fwd_port_statistics { + uint64_t tx; + uint64_t rx; + uint64_t dropped; + uint64_t loop; +} __rte_cache_aligned; +struct l2fwd_port_statistics port_statistics[RTE_MAX_ETHPORTS]; + +/* A tsc-based timer responsible for triggering statistics printout */ +#define MAX_TIMER_PERIOD 86400 /* 1 day max */ +static int64_t timer_period; +static uint64_t tsc_hz; + +static void l2fwd_init_time(void) +{ + tsc_hz = rte_get_tsc_hz(); + timer_period = 10 * rte_get_tsc_hz(); /* default period is 10 seconds */ +} + +/* Print out statistics on packets dropped */ +static void +print_stats(void) +{ + uint64_t total_packets_dropped, total_packets_tx, total_packets_rx; + unsigned portid; + static uint64_t count = 0; + const char clr[] = { 27, '[', '2', 'J', '\0' }; + const char topLeft[] = { 27, '[', '1', ';', '1', 'H','\0' }; + + total_packets_dropped = 0; + total_packets_tx = 0; + total_packets_rx = 0; + + /* Clear screen and move to top left */ + printf("%s%s", clr, topLeft); + + printf("\nPort statistics ===================================="); + + for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) { + /* skip disabled ports */ + if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) + continue; + printf("\nStatistics for port %u ------------------------------" + "\nPackets sent: %24"PRIu64 + "\nPackets received: %20"PRIu64 + "\nPackets dropped: %21"PRIu64 + "\nLoop count : %21"PRIu64, + portid, + port_statistics[portid].tx, + port_statistics[portid].rx, + port_statistics[portid].dropped, + port_statistics[portid].loop); + + total_packets_dropped += port_statistics[portid].dropped; + total_packets_tx += port_statistics[portid].tx; + total_packets_rx += port_statistics[portid].rx; + } + printf("\nAggregate statistics ===============================" + "\nTotal packets sent: %18"PRIu64 + "\nTotal packets received: %14"PRIu64 + "\nTotal packets dropped: %15"PRIu64 + "\nPeriod: %"PRIu64, + total_packets_tx, + total_packets_rx, + total_packets_dropped, + count + ); + printf("\n====================================================\n"); + + count++; +} + +/* Send the burst of packets on an output interface */ +static int +l2fwd_send_burst(struct lcore_queue_conf *qconf, unsigned n, uint8_t port) +{ + struct rte_mbuf **m_table; + unsigned ret; + unsigned queueid =0; + + m_table = (struct rte_mbuf **)qconf->tx_mbufs[port].m_table; + + ret = rte_eth_tx_burst(port, (uint16_t) queueid, m_table, (uint16_t) n); + port_statistics[port].tx += ret; + if (unlikely(ret < n)) { + port_statistics[port].dropped += (n - ret); + do { + rte_pktmbuf_free(m_table[ret]); + } while (++ret < n); + } + + return 0; +} + +/* Enqueue packets for TX and prepare them to be sent */ +static int +l2fwd_send_packet(struct rte_mbuf *m, uint8_t port) +{ + unsigned lcore_id, len; + struct lcore_queue_conf *qconf; + + lcore_id = rte_lcore_id(); + + qconf = &lcore_queue_conf[lcore_id]; + len = qconf->tx_mbufs[port].len; + qconf->tx_mbufs[port].m_table[len] = m; + len++; + + /* enough pkts to be sent */ + if (unlikely(len == MAX_PKT_BURST)) { + l2fwd_send_burst(qconf, MAX_PKT_BURST, port); + len = 0; + } + + qconf->tx_mbufs[port].len = len; + return 0; +} + +static void +l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid) +{ + struct ether_hdr *eth; + void *tmp; + unsigned dst_port; + + dst_port = l2fwd_dst_ports[portid]; + + eth = rte_pktmbuf_mtod(m, struct ether_hdr *); + /* 02:00:00:00:00:xx */ + tmp = ð->d_addr.addr_bytes[0]; + *((uint64_t *)tmp) = 0x000000000002 + ((uint64_t)dst_port << 40); + + /* src addr */ + ether_addr_copy(&l2fwd_ports_eth_addr[dst_port], ð->s_addr); + + l2fwd_send_packet(m, (uint8_t) dst_port); +} + +static inline void +copy_buf_to_pkt(void* buf, unsigned len, struct rte_mbuf *pkt, unsigned offset) +{ + rte_memcpy(((char *) pkt->pkt.data + offset), buf, (size_t) len); +} + +static int +l2fwd_tx(void) +{ + uint8_t portid; + + for (portid = 0; portid < RTE_MAX_ETHPORTS; ++portid) { + struct rte_mbuf *tx_mbuf[MAX_TX_COUNT]; + int pkt; + unsigned queueid = 0; + + if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) + continue; + + for (pkt = 0; pkt < l2fwd_tx_count; ++pkt) { + + tx_mbuf[pkt] = rte_pktmbuf_alloc(l2fwd_pktmbuf_pool); + if (!tx_mbuf[pkt]) + rte_exit(EXIT_FAILURE, + "rte_pktmbuf_alloc failed.\n"); + + /* minimum ethernet header + without this the 82599 will drop the packet if IXGBE_FCTRL_SBP is not set + */ + { + struct ether_hdr *eth_hdr; + /*struct ipv4_hdr *ipv4_hdr;*/ + struct ether_addr mac_addr; + + eth_hdr = rte_pktmbuf_mtod(tx_mbuf[pkt], struct ether_hdr*); + + rte_eth_macaddr_get(portid, &mac_addr); +#if 1 + mac_addr.addr_bytes[0] = 0; + mac_addr.addr_bytes[1] = 2; +#endif + ether_addr_copy(&mac_addr, ð_hdr->s_addr); + ether_addr_copy(&mac_addr, ð_hdr->d_addr); + eth_hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4); + + /*ipv4_hdr = (struct ipv4_hdr*)ð_hdr[1];*/ + + tx_mbuf[pkt]->pkt.data_len = l2fwd_tx_size; + tx_mbuf[pkt]->pkt.pkt_len = l2fwd_tx_size; +#if 0 + rte_hexdump(NULL, rte_pktmbuf_mtod(tx_mbuf[pkt], void*), l2fwd_tx_size); +#endif + } + } + + if(rte_eth_tx_burst(portid, queueid, tx_mbuf, l2fwd_tx_count) != l2fwd_tx_count) + rte_exit(EXIT_FAILURE, "Incomplete Tx for port %u\n", portid); + + RTE_LOG(INFO, L2FWD, "sent %u packets on port %u\n", l2fwd_tx_count, portid); + } + + return 0; +} + +/* main processing loop */ +static void +l2fwd_main_loop(void) +{ + struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; + struct rte_mbuf *m; + unsigned lcore_id; + uint64_t prev_tsc, diff_tsc, cur_tsc, timer_tsc; + unsigned i, j, portid, nb_rx; + struct lcore_queue_conf *qconf; + const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) / US_PER_S * BURST_TX_DRAIN_US; + + prev_tsc = 0; + timer_tsc = 0; + + lcore_id = rte_lcore_id(); + qconf = &lcore_queue_conf[lcore_id]; + + if (qconf->n_rx_port == 0) { + RTE_LOG(INFO, L2FWD, "lcore %u has nothing to do\n", lcore_id); + return; + } + + RTE_LOG(INFO, L2FWD, "entering main loop on lcore %u\n", lcore_id); + + for (i = 0; i < qconf->n_rx_port; i++) { + + portid = qconf->rx_port_list[i]; + RTE_LOG(INFO, L2FWD, " -- lcoreid=%u portid=%u\n", lcore_id, + portid); + } + + while (1) { + cur_tsc = rte_rdtsc(); + + /* + * TX burst queue drain + */ + diff_tsc = cur_tsc - prev_tsc; + if (unlikely(diff_tsc > drain_tsc)) { + for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) { + if (qconf->tx_mbufs[portid].len == 0) + continue; + l2fwd_send_burst(&lcore_queue_conf[lcore_id], + qconf->tx_mbufs[portid].len, + (uint8_t) portid); + qconf->tx_mbufs[portid].len = 0; + } + /* if timer is enabled */ + if (timer_period > 0) { + + /* advance the timer */ + timer_tsc += diff_tsc; + + /* if timer has reached its timeout */ + if (unlikely(timer_tsc >= (uint64_t) timer_period)) { + + /* do this only on master core */ + if (lcore_id == rte_get_master_lcore()) { + print_stats(); + /* reset the timer */ + timer_tsc = 0; + } + } + } + + prev_tsc = cur_tsc; + } + + /* + * Read packet from RX queues + */ + for (i = 0; i < qconf->n_rx_port; i++) { + portid = qconf->rx_port_list[i]; + nb_rx = rte_eth_rx_burst((uint8_t) portid, 0, + pkts_burst, MAX_PKT_BURST); + + port_statistics[portid].rx += nb_rx; + port_statistics[portid].loop++; + + for (j = 0; j < nb_rx; j++) { + m = pkts_burst[j]; + rte_prefetch0(rte_pktmbuf_mtod(m, void *)); + l2fwd_simple_forward(m, portid); + +#if 0 + rte_hexdump(NULL, rte_pktmbuf_mtod(pkts_burst[j], void*), pkts_burst[j]->pkt.data_len); +#endif + + } + } + } +} + +static int +l2fwd_launch_one_lcore(__attribute__((unused)) void *dummy) +{ + l2fwd_main_loop(); + return 0; +} + +/* display usage */ +static void +l2fwd_usage(const char *prgname) +{ + printf("%s [EAL options] -- -p PORTMASK [-q NQ]\n" + " -p PORTMASK: hexadecimal bitmask of ports to configure\n" + " -q NQ: number of queue (=ports) per lcore (default is 1)\n" + " -T PERIOD: statistics will be refreshed each PERIOD seconds (0 to disable, 10 default, 86400 maximum)\n" + " -t TX: number of packets to send before forwarding (0 to disable, 0 default, 128 maximum)\n" + " -l LOOPBACK: loopback mode \n" + " -s SIZE: size of packets to be sent (64 default/minimum, 2048 maximum)\n", + prgname); +} + +static int +l2fwd_parse_portmask(const char *portmask) +{ + char *end = NULL; + unsigned long pm; + + /* parse hexadecimal string */ + pm = strtoul(portmask, &end, 16); + if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0')) + return -1; + + if (pm == 0) + return -1; + + return pm; +} + +static int +l2fwd_parse_tx_packet_count(const char *q_arg) +{ + char *end = NULL; + int n; + + /* parse number string */ + n = strtol(q_arg, &end, 10); + if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0')) + return -1; + if (n > MAX_TX_COUNT) + return -1; + + return n; +} + +static int +l2fwd_parse_tx_packet_size(const char *q_arg) +{ + char *end = NULL; + int n; + + /* parse number string */ + n = strtol(q_arg, &end, 10); + if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0')) + return -1; + if (n < MIN_TX_SIZE) + return -1; + if (n > MAX_TX_SIZE) + return -1; + + return n; +} + +static unsigned int +l2fwd_parse_nqueue(const char *q_arg) +{ + char *end = NULL; + unsigned long n; + + /* parse hexadecimal string */ + n = strtoul(q_arg, &end, 10); + if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0')) + return 0; + if (n == 0) + return 0; + if (n >= MAX_RX_QUEUE_PER_LCORE) + return 0; + + return n; +} + +static int +l2fwd_parse_timer_period(const char *q_arg) +{ + char *end = NULL; + int n; + + /* parse number string */ + n = strtol(q_arg, &end, 10); + if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0')) + return -1; + if (n >= MAX_TIMER_PERIOD) + return -1; + + return n; +} + +/* Parse the argument given in the command line of the application */ +static int +l2fwd_parse_args(int argc, char **argv) +{ + int opt, ret; + char **argvopt; + int option_index; + char *prgname = argv[0]; + static struct option lgopts[] = { + {NULL, 0, 0, 0} + }; + + argvopt = argv; + + while ((opt = getopt_long(argc, argvopt, "p:q:T:t:s:l", + lgopts, &option_index)) != EOF) { + + switch (opt) { + /* portmask */ + case 'p': + l2fwd_enabled_port_mask = l2fwd_parse_portmask(optarg); + if (l2fwd_enabled_port_mask == 0) { + printf("invalid portmask\n"); + l2fwd_usage(prgname); + return -1; + } + break; + + /* nqueue */ + case 'q': + l2fwd_rx_queue_per_lcore = l2fwd_parse_nqueue(optarg); + if (l2fwd_rx_queue_per_lcore == 0) { + printf("invalid queue number\n"); + l2fwd_usage(prgname); + return -1; + } + break; + + /* timer period */ + case 'T': + timer_period = l2fwd_parse_timer_period(optarg) * tsc_hz; + if (timer_period < 0) { + printf("invalid timer period\n"); + l2fwd_usage(prgname); + return -1; + } + break; + + case 't': + l2fwd_tx_count = l2fwd_parse_tx_packet_count(optarg); + if (l2fwd_tx_count < 0) { + printf("invalid tx packet count\n"); + l2fwd_usage(prgname); + return -1; + } + break; + + case 's': + l2fwd_tx_size = l2fwd_parse_tx_packet_size(optarg); + if (l2fwd_tx_size < 0) { + printf("invalid tx packet size\n"); + l2fwd_usage(prgname); + return -1; + } + break; + + case 'l': + l2fwd_loopback = 1; + break; + + /* long options */ + case 0: + l2fwd_usage(prgname); + return -1; + + default: + l2fwd_usage(prgname); + return -1; + } + } + + if (optind >= 0) + argv[optind-1] = prgname; + + ret = optind-1; + optind = 0; /* reset getopt lib */ + return ret; +} + +/* Check the link status of all ports in up to 9s, and print them finally */ +static void +check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) +{ +#define CHECK_INTERVAL 100 /* 100ms */ +#define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */ + uint8_t portid, count, all_ports_up, print_flag = 0; + struct rte_eth_link link; + + printf("\nChecking link status"); + fflush(stdout); + for (count = 0; count <= MAX_CHECK_TIME; count++) { + all_ports_up = 1; + for (portid = 0; portid < port_num; portid++) { + if ((port_mask & (1 << portid)) == 0) + continue; + memset(&link, 0, sizeof(link)); + rte_eth_link_get_nowait(portid, &link); + /* print link status if flag set */ + if (print_flag == 1) { + if (link.link_status) + printf("Port %d Link Up - speed %u " + "Mbps - %s\n", (uint8_t)portid, + (unsigned)link.link_speed, + (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? + ("full-duplex") : ("half-duplex\n")); + else + printf("Port %d Link Down\n", + (uint8_t)portid); + continue; + } + /* clear all_ports_up flag if any link down */ + if (link.link_status == 0) { + all_ports_up = 0; + break; + } + } + /* after finally printing all link status, get out */ + if (print_flag == 1) + break; + + if (all_ports_up == 0) { + printf("."); + fflush(stdout); + rte_delay_ms(CHECK_INTERVAL); + } + + /* set the print_flag if all ports up or timeout */ + if (all_ports_up == 1 || count == (MAX_CHECK_TIME - 1)) { + print_flag = 1; + printf("done\n"); + } + } +} + +int +MAIN(int argc, char **argv) +{ + struct lcore_queue_conf *qconf; + struct rte_eth_dev_info dev_info; + int ret; + uint8_t nb_ports; + uint8_t nb_ports_available; + uint8_t portid, last_port; + unsigned lcore_id, rx_lcore_id; + unsigned nb_ports_in_mask = 0; + + setlinebuf(stdout); + setlinebuf(stderr); + + /* init EAL */ + ret = rte_eal_init(argc, argv); + if (ret < 0) + rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n"); + + l2fwd_init_time(); + + argc -= ret; + argv += ret; + + /* parse application arguments (after the EAL ones) */ + ret = l2fwd_parse_args(argc, argv); + if (ret < 0) + rte_exit(EXIT_FAILURE, "Invalid L2FWD arguments\n"); + + /* create the mbuf pool */ + l2fwd_pktmbuf_pool = + rte_mempool_create("mbuf_pool", NB_MBUF, + MBUF_SIZE, 32, + sizeof(struct rte_pktmbuf_pool_private), + rte_pktmbuf_pool_init, NULL, + rte_pktmbuf_init, NULL, + rte_socket_id(), 0); + if (l2fwd_pktmbuf_pool == NULL) + rte_exit(EXIT_FAILURE, "Cannot init mbuf pool\n"); + + /* init driver(s) */ + if (rte_pmd_init_all() < 0) + rte_exit(EXIT_FAILURE, "Cannot init pmd\n"); + + if (rte_eal_pci_probe() < 0) + rte_exit(EXIT_FAILURE, "Cannot probe PCI\n"); + + nb_ports = rte_eth_dev_count(); + if (nb_ports == 0) + rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n"); + + if (nb_ports > RTE_MAX_ETHPORTS) + nb_ports = RTE_MAX_ETHPORTS; + + /* reset l2fwd_dst_ports */ + for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) + l2fwd_dst_ports[portid] = 0; + last_port = 0; + + /* + * Each logical core is assigned a dedicated TX queue on each port. + */ + for (portid = 0; portid < nb_ports; portid++) { + /* skip ports that are not enabled */ + if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) + continue; + + if (l2fwd_loopback) { + l2fwd_dst_ports[portid] = portid; + continue; + } + + if (nb_ports_in_mask % 2) { + l2fwd_dst_ports[portid] = last_port; + l2fwd_dst_ports[last_port] = portid; + } + else + last_port = portid; + + nb_ports_in_mask++; + + rte_eth_dev_info_get(portid, &dev_info); + } + if (!l2fwd_loopback && (nb_ports_in_mask % 2)) { + printf("Notice: odd number of ports in portmask.\n"); + l2fwd_dst_ports[last_port] = last_port; + } + + rx_lcore_id = 0; + qconf = NULL; + + /* Initialize the port/queue configuration of each logical core */ + for (portid = 0; portid < nb_ports; portid++) { + /* skip ports that are not enabled */ + if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) + continue; + + /* get the lcore_id for this port */ + while (rte_lcore_is_enabled(rx_lcore_id) == 0 || + lcore_queue_conf[rx_lcore_id].n_rx_port == + l2fwd_rx_queue_per_lcore) { + rx_lcore_id++; + if (rx_lcore_id >= RTE_MAX_LCORE) + rte_exit(EXIT_FAILURE, "Not enough cores\n"); + } + + if (qconf != &lcore_queue_conf[rx_lcore_id]) + /* Assigned a new logical core in the loop above. */ + qconf = &lcore_queue_conf[rx_lcore_id]; + + qconf->rx_port_list[qconf->n_rx_port] = portid; + qconf->n_rx_port++; + printf("Lcore %u: RX port %u\n", rx_lcore_id, (unsigned) portid); + } + + nb_ports_available = nb_ports; + + if (l2fwd_loopback) + port_conf.lpbk_mode = 1; + + /* Initialise each port */ + for (portid = 0; portid < nb_ports; portid++) { + /* skip ports that are not enabled */ + if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) { + printf("Skipping disabled port %u\n", (unsigned) portid); + nb_ports_available--; + continue; + } + /* init port */ + printf("Initializing port %u... ", (unsigned) portid); + fflush(stdout); + + ret = rte_eth_dev_configure(portid, 1, 1, &port_conf); + if (ret < 0) + rte_exit(EXIT_FAILURE, "Cannot configure device: err=%d, port=%u\n", + ret, (unsigned) portid); + + rte_eth_macaddr_get(portid,&l2fwd_ports_eth_addr[portid]); + + /* init one RX queue */ + fflush(stdout); + ret = rte_eth_rx_queue_setup(portid, 0, nb_rxd, + rte_eth_dev_socket_id(portid), &rx_conf, + l2fwd_pktmbuf_pool); + if (ret < 0) + rte_exit(EXIT_FAILURE, "rte_eth_rx_queue_setup:err=%d, port=%u\n", + ret, (unsigned) portid); + + /* init one TX queue on each port */ + fflush(stdout); + ret = rte_eth_tx_queue_setup(portid, 0, nb_txd, + rte_eth_dev_socket_id(portid), &tx_conf); + if (ret < 0) + rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup:err=%d, port=%u\n", + ret, (unsigned) portid); + + /* Start device */ + ret = rte_eth_dev_start(portid); + if (ret < 0) + rte_exit(EXIT_FAILURE, "rte_eth_dev_start:err=%d, port=%u\n", + ret, (unsigned) portid); + + printf("done: \n"); + + rte_eth_promiscuous_enable(portid); + + printf("Port %u, MAC address: %02X:%02X:%02X:%02X:%02X:%02X\n\n", + (unsigned) portid, + l2fwd_ports_eth_addr[portid].addr_bytes[0], + l2fwd_ports_eth_addr[portid].addr_bytes[1], + l2fwd_ports_eth_addr[portid].addr_bytes[2], + l2fwd_ports_eth_addr[portid].addr_bytes[3], + l2fwd_ports_eth_addr[portid].addr_bytes[4], + l2fwd_ports_eth_addr[portid].addr_bytes[5]); + + /* initialize port stats */ + memset(&port_statistics, 0, sizeof(port_statistics)); + } + + if (!nb_ports_available) { + rte_exit(EXIT_FAILURE, + "All available ports are disabled. Please set portmask.\n"); + } + + if(!l2fwd_loopback) + check_all_ports_link_status(nb_ports, l2fwd_enabled_port_mask); + + if (l2fwd_tx_count) + l2fwd_tx(); + + /* launch per-lcore init on every lcore */ + rte_eal_mp_remote_launch(l2fwd_launch_one_lcore, NULL, CALL_MASTER); + + RTE_LCORE_FOREACH_SLAVE(lcore_id) { + if (rte_eal_wait_lcore(lcore_id) < 0) + return -1; + } + + return 0; +} + 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 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2010-2013 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _MAIN_H_ +#define _MAIN_H_ + +#ifdef RTE_EXEC_ENV_BAREMETAL +#define MAIN _main +#else +#define MAIN main +#endif + +int MAIN(int argc, char **argv); + +#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 @@ +Index: dpdk/mk/machine/native/rte.vars.mk +=================================================================== +--- dpdk.orig/mk/machine/native/rte.vars.mk 2014-04-25 18:53:11.422348174 +0300 ++++ dpdk/mk/machine/native/rte.vars.mk 2014-04-25 18:52:44.042348924 +0300 +@@ -55,4 +55,6 @@ + # CPU_LDFLAGS = + # CPU_ASFLAGS = + +-MACHINE_CFLAGS = -march=native ++MACHINE_CFLAGS_ALT ?= -march=native ++ ++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 @@ +Update test makefiles. + +Signed-off-by: Costin Popescu +Upstream-Status: Pending + +diff --git a/mk/rte.sdkroot.mk b/mk/rte.sdkroot.mk +index 29af6a5..59bf972 100644 +--- a/mk/rte.sdkroot.mk ++++ b/mk/rte.sdkroot.mk +@@ -101,6 +101,10 @@ testall: + install uninstall: + $(Q)$(MAKE) -f $(RTE_SDK)/mk/rte.sdkinstall.mk $@ + ++.PHONY: test-install ++test-install: ++ $(Q)$(MAKE) -f $(RTE_SDK)/mk/rte.sdktest.mk $@ ++ + .PHONY: doc help + doc: doc-all + help: doc-help +diff --git a/mk/rte.sdktest.mk b/mk/rte.sdktest.mk +index b2c043e..015aab5 100644 +--- a/mk/rte.sdktest.mk ++++ b/mk/rte.sdktest.mk +@@ -82,3 +82,16 @@ coverage: + else \ + echo "No test found, please do a 'make build' first, or specify O=" ;\ + fi ++ ++test-install: ++ install -d $(TEST_DESTDIR)/app/test ++ install -d $(TEST_DESTDIR)/mk ++ install -d $(TEST_DESTDIR)/$(TARGET_ARCH)-default-linuxapp-gcc ++ install -d $(TEST_DESTDIR)/$(TARGET_ARCH)-default-linuxapp-gcc/app ++ install $(DPDK_SRC_PATH)/$(TARGET_ARCH)-default-linuxapp-gcc/.config $(TEST_DESTDIR)/$(TARGET_ARCH)-default-linuxapp-gcc ++ install $(DPDK_SRC_PATH)/$(TARGET_ARCH)-default-linuxapp-gcc/Makefile $(TEST_DESTDIR)/$(TARGET_ARCH)-default-linuxapp-gcc ++ install $(DPDK_PATH)/$(TARGET_ARCH)-default-linuxapp-gcc/app/* $(TEST_DESTDIR)/$(TARGET_ARCH)-default-linuxapp-gcc/app/ ++ install $(DPDK_SRC_PATH)/app/test/*.py $(TEST_DESTDIR)/app/test ++ install $(DPDK_SRC_PATH)/Makefile $(TEST_DESTDIR) ++ cp -r $(DPDK_SRC_PATH)/mk/* $(TEST_DESTDIR)/mk ++ 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 @@ +--- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h ++++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h +@@ -101,6 +101,7 @@ struct rte_kni_device_info { + + /* mbuf size */ + unsigned mbuf_size; ++ uint64_t mempool_size; + }; + + #define KNI_DEVICE "kni" +--- a/lib/librte_eal/linuxapp/kni/kni_misc.c ++++ b/lib/librte_eal/linuxapp/kni/kni_misc.c +@@ -21,6 +21,19 @@ MODULE_DESCRIPTION("Kernel Module for managing kni devices"); + + #define KNI_MAX_DEVICES 32 + ++#define PCI_VENDOR_ID_IVSHMEM 0x1AF4 ++#define PCI_DEVICE_ID_IVSHMEM 0x1110 ++#define BAR2 2 ++#define IVSHMEM_MAGIC 0x0BADC0DE ++#define IVSHMEM_METADATA_SIZE 0x4000 ++#define KNI_FIFO_COUNT_MAX 1024 ++#define KNI_FIFO_SIZE ((KNI_FIFO_COUNT_MAX) * sizeof(void *) + \ ++ sizeof(struct rte_kni_fifo)) ++ ++#define get_virt_addr(x) get_virt_addr_by_size(x,KNI_FIFO_SIZE) ++#define get_virt_addr_by_size(x,s) (has_ivshmem_metadata ? \ ++ ioremap(x, s) : phys_to_virt(x)) ++ + extern void kni_net_rx(struct kni_dev *kni); + extern void kni_net_init(struct net_device *dev); + extern void kni_net_config_lo_mode(char *lo_str); +@@ -47,6 +60,8 @@ static int kni_thread_single(void *unused); + /* KNI processing for multiple kernel thread mode */ + static int kni_thread_multiple(void *param); + ++static int kni_has_ivshmem_metadata(void); ++ + static struct file_operations kni_fops = { + .owner = THIS_MODULE, + .open = kni_open, +@@ -72,6 +87,7 @@ static unsigned multiple_kthread_on = 0; + + static volatile unsigned long device_in_use; /* device in use flag */ + static struct task_struct *kni_kthread; ++static int has_ivshmem_metadata = 0; + + /* kni list lock */ + static DECLARE_RWSEM(kni_list_lock); +@@ -100,6 +116,10 @@ kni_init(void) + /* Configure the lo mode according to the input parameter */ + kni_net_config_lo_mode(lo_mode); + ++ has_ivshmem_metadata = kni_has_ivshmem_metadata(); ++ KNI_PRINT("IVSHMEM metadata %s \n", ++ has_ivshmem_metadata ? "found" : "NOT found"); ++ + KNI_PRINT("######## DPDK kni module loaded ########\n"); + + return 0; +@@ -178,6 +198,19 @@ kni_release(struct inode *inode, struct file *file) + #endif + kni_dev_remove(dev); + list_del(&dev->list); ++ ++ if (has_ivshmem_metadata) { ++ KNI_PRINT("iounmapping KNI FIFOs for device '%s'\n", dev->name); ++ iounmap(dev->tx_q); ++ iounmap(dev->rx_q); ++ iounmap(dev->alloc_q); ++ iounmap(dev->free_q); ++ iounmap(dev->req_q); ++ iounmap(dev->resp_q); ++ iounmap(dev->sync_kva); ++ iounmap(dev->mbuf_kva); ++ } ++ + } + up_write(&kni_list_lock); + +@@ -339,17 +372,17 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned long ioctl_param) + strncpy(kni->name, dev_info.name, RTE_KNI_NAMESIZE); + + /* Translate user space info into kernel space info */ +- kni->tx_q = phys_to_virt(dev_info.tx_phys); +- kni->rx_q = phys_to_virt(dev_info.rx_phys); +- kni->alloc_q = phys_to_virt(dev_info.alloc_phys); +- kni->free_q = phys_to_virt(dev_info.free_phys); ++ kni->tx_q = get_virt_addr(dev_info.tx_phys); ++ kni->rx_q = get_virt_addr(dev_info.rx_phys); ++ kni->alloc_q = get_virt_addr(dev_info.alloc_phys); ++ kni->free_q = get_virt_addr(dev_info.free_phys); + +- kni->req_q = phys_to_virt(dev_info.req_phys); +- kni->resp_q = phys_to_virt(dev_info.resp_phys); ++ kni->req_q = get_virt_addr(dev_info.req_phys); ++ kni->resp_q = get_virt_addr(dev_info.resp_phys); + kni->sync_va = dev_info.sync_va; +- kni->sync_kva = phys_to_virt(dev_info.sync_phys); ++ kni->sync_kva = get_virt_addr(dev_info.sync_phys); + +- kni->mbuf_kva = phys_to_virt(dev_info.mbuf_phys); ++ kni->mbuf_kva = get_virt_addr_by_size(dev_info.mbuf_phys, dev_info.mempool_size); + kni->mbuf_va = dev_info.mbuf_va; + + #ifdef RTE_KNI_VHOST +@@ -552,6 +585,40 @@ kni_compat_ioctl(struct inode *inode, + return -EINVAL; + } + ++static int ++kni_has_ivshmem_metadata(void) ++{ ++ struct pci_dev *ivshm_dev = NULL; ++ phys_addr_t ivshmem_metadata_addr = 0; ++ void *ivshmem_metadata = NULL; ++ int ivshmem_magic_number; ++ ++ ivshm_dev = pci_get_device(PCI_VENDOR_ID_IVSHMEM, PCI_DEVICE_ID_IVSHMEM, ++ NULL); ++ ++ if (ivshm_dev == NULL) { ++ printk("No IVSHMEM device found!\n"); ++ return 0; ++ } ++ ++ /* IVSHMEM metadata will be received at the very last 4K of the BAR2 */ ++ ivshmem_metadata_addr = (pci_resource_end(ivshm_dev, BAR2) ++ - IVSHMEM_METADATA_SIZE) + 1; ++ ++ ivshmem_metadata = ioremap(ivshmem_metadata_addr, IVSHMEM_METADATA_SIZE); ++ if (ivshmem_metadata == NULL) { ++ printk("Could not ioremap IVSHMEM metadata\n"); ++ return 0; ++ } ++ ++ /* The first sizeof(int) bytes contain the magic number that tells us ++ * ivshmem_metadata is coming from the host */ ++ ivshmem_magic_number = ((int*) ivshmem_metadata)[0]; ++ iounmap(ivshmem_metadata); ++ return !!(ivshmem_magic_number == IVSHMEM_MAGIC); ++} ++ ++ + module_init(kni_init); + module_exit(kni_exit); + +--- a/lib/librte_eal/linuxapp/kni/kni_net.c ++++ b/lib/librte_eal/linuxapp/kni/kni_net.c +@@ -50,15 +50,16 @@ kni_net_open(struct net_device *dev) + struct rte_kni_request req; + struct kni_dev *kni = netdev_priv(dev); + +- if (kni->lad_dev) +- memcpy(dev->dev_addr, kni->lad_dev->dev_addr, ETH_ALEN); +- else +- /* +- * Generate random mac address. eth_random_addr() is the newer +- * version of generating mac address in linux kernel. +- */ +- random_ether_addr(dev->dev_addr); +- ++ if (!is_valid_ether_addr(dev->dev_addr)) { ++ if (kni->lad_dev) ++ memcpy(dev->dev_addr, kni->lad_dev->dev_addr, ETH_ALEN); ++ else ++ /* ++ * Generate random mac address. eth_random_addr() is the newer ++ * version of generating mac address in linux kernel. ++ */ ++ random_ether_addr(dev->dev_addr); ++ } + netif_start_queue(dev); + + memset(&req, 0, sizeof(req)); +@@ -459,6 +460,22 @@ kni_net_tx_timeout (struct net_device *dev) + return; + } + ++static int ++kni_set_mac_address(struct net_device *dev, void *addr_ptr) ++{ ++ struct sockaddr *addr = addr_ptr; ++ ++ if (netif_running(dev)) ++ return -EBUSY; ++ ++ if (!is_valid_ether_addr(addr->sa_data)) ++ return -EADDRNOTAVAIL; ++ ++ memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); ++ ++ return 0; ++} ++ + /* + * Ioctl commands + */ +@@ -608,6 +625,7 @@ static const struct net_device_ops kni_net_netdev_ops = { + .ndo_do_ioctl = kni_net_ioctl, + .ndo_get_stats = kni_net_stats, + .ndo_tx_timeout = kni_net_tx_timeout, ++ .ndo_set_mac_address = kni_set_mac_address, + }; + + 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 @@ +#!/bin/sh + +export RTE_SDK=/opt/dpdk +export RTE_TARGET=x86_64-default-linuxapp-gcc +export RTE_ARCH=x86_64 +RTE_SRC=/usr/src/dpdk +HUGE_PAGES_MEM=2097152 #[1024 * 2048kB] + +#check hugetlbfs mount +echo -n "Mounting hugepages..." +mount | grep "nodev on /mnt/huge type hugetlbfs" +if [ $? -ne 0 ]; then + mkdir -p /mnt/huge + mount -t hugetlbfs nodev /mnt/huge +fi +echo "OK!" + +#increase hugepages for all nodes +echo -n "Allocating hugepages..." +#get hugepages sizes +hp_sz=`cat /proc/meminfo | grep Hugepagesize | sed -r "s/Hugepagesize:[^0-9]*([0-9]+) kB/\1/"` +#calculate huge pages number to get the equivalent of 1024 pages of 2MB +huge_pages_no=`expr ${HUGE_PAGES_MEM} / ${hp_sz}` +#get hugepages no +hp=0 +#Find out if this is a NUMA machine +ls /sys/devices/system/node/node* > /dev/null 2>&1 +if [ $? -ne 0 ]; then + hp=`cat /proc/sys/vm/nr_hugepages` + hptest=`expr $hp + $huge_pages_no` + echo $hptest > /proc/sys/vm/nr_hugepages +else + hparray=() + nodes=`ls /sys/devices/system/node | grep node | wc -l` + for (( i=0; $i<$nodes; i++ )) + do + hp=`cat /sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages` + hptest=`expr $hp + $huge_pages_no` + echo $hptest > /sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages + hparray+=("$hp") + done +fi +echo "OK!" +echo "Allocated ${huge_pages_no} x ${hp_sz}kB" + +#run l2fwd loopback test +DEVS=("I350" "82599") +PCI_UTIL=${RTE_SRC}/tools/pci_unbind.py +IGB_UIO=${RTE_SDK}/${RTE_TARGET}/kmod/igb_uio.ko +RTE_KNI=${RTE_SDK}/${RTE_TARGET}/kmod/rte_kni.ko + +rmmod rte_kni > /dev/null 2>&1 +rmmod igb_uio > /dev/null 2>&1 +modprobe uio && insmod ${IGB_UIO} + +#insert igb_uio, needed by some dpdk tests +if [ $? -ne 0 ]; then + echo "FAIL: uio/igb_uio load" + DEVS=() +else + echo "PASS: uio/igb_uio load" +fi + +#insert rte_kni driver in loopback mode, needed by KNI tests +insmod ${RTE_KNI} lo_mode=lo_mode_fifo + +if [ $? -ne 0 ]; then + echo "FAIL: rte_kni load" + DEVS=() +else + echo "PASS: rte_kni load" +fi + +#bind devices to igb_uio, needed by some dpdk tests +drvarray=() +pciarray=() +for dev in ${DEVS[@]} +do + DEV_INFO=`${PCI_UTIL} --status|grep ${dev}|grep -v -i 'active'|head -n 1` + if [ -z "$DEV_INFO" ] || [ "$DEV_INFO" == " " ] ; then + continue + fi + + DEV_PCI_ADDR=`echo ${DEV_INFO}|sed -r "s/([^ ]*) .*/\1/"` + DEV_NAME=`echo ${DEV_INFO}|sed -r "s/.*'(.*)'.*/\1/"` + DEV_ETH=`echo ${DEV_INFO}|grep eth=|sed -r "s/.*if=([^ ]*).*/\1/"` + DEV_DRV=`echo ${DEV_INFO}|sed -r "s/.*drv=([^ ]*).*/\1/"` + + echo "Testing device: $DEV_NAME(pci $DEV_PCI_ADDR, eth $DEV_ETH, drv $DEV_DRV)" + + if [ ! -z ${DEV_ETH} ]; then + ifconfig ${DEV_ETH} down + fi + + ${PCI_UTIL} --bind=igb_uio ${DEV_PCI_ADDR} + drvarray+=("${DEV_DRV}") + pciarray+=("${DEV_PCI_ADDR}") +done + +#run dpdk tests +python ${RTE_SRC}/app/test/autotest.py ./test ${RTE_TARGET} + +#bind devices to initial drivers +for ((i=0;i<${#pciarray[@]};i++)); +do + echo "${PCI_UTIL} --bind=${drvarray[$i]} ${pciarray[$i]}" + ${PCI_UTIL} --bind=${drvarray[$i]} ${pciarray[$i]} +done + +for dev in ${DEVS[@]} +do + DEV_INFO=`${PCI_UTIL} --status|grep ${dev}|grep -v -i 'active'|head -n 1` + if [ -z "$DEV_INFO" ] || [ "$DEV_INFO" == " " ] ; then + echo "SKIP: l2fwd-lpbk ($dev)" + continue + fi + + DEV_PCI_ADDR=`echo ${DEV_INFO}|sed -r "s/([^ ]*) .*/\1/"` + DEV_NAME=`echo ${DEV_INFO}|sed -r "s/.*'(.*)'.*/\1/"` + DEV_ETH=`echo ${DEV_INFO}|grep eth=|sed -r "s/.*if=([^ ]*).*/\1/"` + DEV_DRV=`echo ${DEV_INFO}|sed -r "s/.*drv=([^ ]*).*/\1/"` + + echo "Testing device: $DEV_NAME(pci $DEV_PCI_ADDR, eth $DEV_ETH, drv $DEV_DRV)" + + if [ ! -z ${DEV_ETH} ]; then + ifconfig ${DEV_ETH} down + fi + + ${PCI_UTIL} --bind=igb_uio ${DEV_PCI_ADDR} + + ./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 & + APP_PID=$! + sleep 20 + kill $APP_PID + + DEV_SENT=`cat ${DEV_PCI_ADDR}.log|grep "Packets sent:"|tail -n 1|sed -r "s/.* ([0-9]*)/\1/"` + DEV_RECV=`cat ${DEV_PCI_ADDR}.log|grep "Packets received:"|tail -n 1|sed -r "s/.* ([0-9]*)/\1/"` + DEV_DROP=`cat ${DEV_PCI_ADDR}.log|grep "Packets dropped:"|tail -n 1|sed -r "s/.* ([0-9]*)/\1/"` + + + echo "Results: sent $DEV_SENT, received $DEV_RECV, dropped $DEV_DROP" + + STATUS=0 + + case "$dev" in + "I350") + if [ ${DEV_SENT} -lt 13000000 ]; then + STATUS=1 + fi + ;; + "82599") + if [ ${DEV_SENT} -lt 110000000 ]; then + STATUS=1 + fi + ;; + esac + + if [ ${STATUS} -ne 0 ]; then + echo "FAIL: l2fwd-lpbk (low throughput)" + fi + + if [ ${STATUS} -eq 0 ] && { [ ${DEV_DROP} -ne 0 ] || [ ${DEV_SENT} -ne ${DEV_RECV} ]; } then + echo "FAIL: l2fwd-lpbk (dropped packets)" + STATUS=1 + fi + + if [ ${STATUS} -eq 0 ]; then + echo "PASS: l2fwd-lpbk ($dev)" + fi + + ${PCI_UTIL} --bind=${DEV_DRV} ${DEV_PCI_ADDR} +done + +if [ ! -z ${DEVS} ]; then + rmmod rte_kni > /dev/null 2>&1 + rmmod igb_uio > /dev/null 2>&1 + rmmod uio > /dev/null 2>&1 +fi + +echo -n "Freeing hugepages..." +#Find out if this is a NUMA machine +ls /sys/devices/system/node/node* > /dev/null 2>&1 +if [ $? -ne 0 ]; then + echo $hp > /proc/sys/vm/nr_hugepages +else + i=0 + for hp in ${hparray[@]} + do + echo $hp > "/sys/devices/system/node/node${i}/hugepages/hugepages-${hp_sz}kB/nr_hugepages" + ((i++)) + done +fi +echo "OK!" +rm -rf /mnt/huge/* + 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 @@ +Adapt test output. + +Signed-off-by: Costin Popescu +Upstream-Status: Pending + +diff --git a/app/test/autotest_runner.py b/app/test/autotest_runner.py +index af225ff..33b776a 100644 +--- a/app/test/autotest_runner.py ++++ b/app/test/autotest_runner.py +@@ -267,6 +267,10 @@ class AutotestRunner: + # if test failed and it wasn't a "start" test + if test_result < 0 and not i == 0: + self.fails += 1 ++ if test_result < 0: ++ print "FAIL: %s" % test_name ++ else: ++ print "PASS: %s" % test_name + + # collect logs + 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 @@ +Fix makefiles. + +Signed-off-by: Costin Popescu +Upstream-Status: Pending + +diff --git a/mk/rte.app.mk b/mk/rte.app.mk +index d90a0b0..93f1dd9 100644 +--- a/mk/rte.app.mk ++++ b/mk/rte.app.mk +@@ -203,6 +203,7 @@ endif + + ifeq ($(LINK_USING_CC),1) + comma := , ++LDFLAGS := $(patsubst -Wl$(comma)%,%,$(LDFLAGS)) + LDLIBS := $(addprefix -Wl$(comma),$(LDLIBS)) + LDFLAGS := $(addprefix -Wl$(comma),$(LDFLAGS)) + override EXTRA_LDFLAGS := $(addprefix -Wl$(comma),$(EXTRA_LDFLAGS)) +diff --git a/mk/target/generic/rte.vars.mk b/mk/target/generic/rte.vars.mk +index a163272..9fb07d8 100644 +--- a/mk/target/generic/rte.vars.mk ++++ b/mk/target/generic/rte.vars.mk +@@ -107,7 +107,7 @@ ifeq ($(KERNELRELEASE),) + include $(RTE_SDK)/mk/rte.cpuflags.mk + + # merge all CFLAGS +-CFLAGS := $(CPU_CFLAGS) $(EXECENV_CFLAGS) $(TOOLCHAIN_CFLAGS) $(MACHINE_CFLAGS) ++CFLAGS += $(CPU_CFLAGS) $(EXECENV_CFLAGS) $(TOOLCHAIN_CFLAGS) $(MACHINE_CFLAGS) + CFLAGS += $(TARGET_CFLAGS) $(EXTERNAL_LIB_CFLAGS) + + # merge all LDFLAGS +@@ -115,7 +115,7 @@ LDFLAGS := $(CPU_LDFLAGS) $(EXECENV_LDFLAGS) $(TOOLCHAIN_LDFLAGS) $(MACHINE_LDFL + LDFLAGS += $(TARGET_LDFLAGS) + + # merge all ASFLAGS +-ASFLAGS := $(CPU_ASFLAGS) $(EXECENV_ASFLAGS) $(TOOLCHAIN_ASFLAGS) $(MACHINE_ASFLAGS) ++ASFLAGS += $(CPU_ASFLAGS) $(EXECENV_ASFLAGS) $(TOOLCHAIN_ASFLAGS) $(MACHINE_ASFLAGS) + ASFLAGS += $(TARGET_ASFLAGS) + + # add default include and lib paths +diff --git a/mk/toolchain/gcc/rte.vars.mk b/mk/toolchain/gcc/rte.vars.mk +index 0edb93f..adba7d4 100644 +--- a/mk/toolchain/gcc/rte.vars.mk ++++ b/mk/toolchain/gcc/rte.vars.mk +@@ -40,21 +40,20 @@ + # examples for RTE_TOOLCHAIN: gcc, icc + # + +-CC = $(CROSS)gcc +-CPP = $(CROSS)cpp +-# for now, we don't use as but nasm. +-# AS = $(CROSS)as +-AS = nasm +-AR = $(CROSS)ar +-LD = $(CROSS)ld +-OBJCOPY = $(CROSS)objcopy +-OBJDUMP = $(CROSS)objdump +-STRIP = $(CROSS)strip +-READELF = $(CROSS)readelf +-GCOV = $(CROSS)gcov ++CC ?= $(CROSS)gcc ++CPP ?= $(CROSS)cpp ++AS ?= $(CROSS)as ++#AS ?= nasm ++AR ?= $(CROSS)ar ++LD ?= $(CROSS)ld ++OBJCOPY ?= $(CROSS)objcopy ++OBJDUMP ?= $(CROSS)objdump ++STRIP ?= $(CROSS)strip ++READELF ?= $(CROSS)readelf ++GCOV ?= $(CROSS)gcov + +-HOSTCC = gcc +-HOSTAS = as ++HOSTCC ?= gcc ++HOSTAS ?= as + + TOOLCHAIN_ASFLAGS = + TOOLCHAIN_CFLAGS = +@@ -68,7 +67,7 @@ ifeq (,$(findstring -O0,$(EXTRA_CFLAGS))) + endif + endif + +-WERROR_FLAGS := -W -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes ++WERROR_FLAGS := -W -Wall -Wstrict-prototypes -Wmissing-prototypes + WERROR_FLAGS += -Wmissing-declarations -Wold-style-definition -Wpointer-arith + WERROR_FLAGS += -Wcast-align -Wnested-externs -Wcast-qual + WERROR_FLAGS += -Wformat-nonliteral -Wformat-security -- cgit v1.2.3-54-g00ecf