get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/1342/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1342,
    "url": "https://patches.dpdk.org/api/patches/1342/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1416335575-30717-1-git-send-email-bhavesh@vmware.com/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<1416335575-30717-1-git-send-email-bhavesh@vmware.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1416335575-30717-1-git-send-email-bhavesh@vmware.com",
    "date": "2014-11-18T18:32:55",
    "name": "[dpdk-dev] examples: new txburst application",
    "commit_ref": null,
    "pull_url": null,
    "state": "rejected",
    "archived": true,
    "hash": "379882625b2323783cbad3f5b746330ab2950a20",
    "submitter": {
        "id": 117,
        "url": "https://patches.dpdk.org/api/people/117/?format=api",
        "name": "Bhavesh Davda",
        "email": "bhavesh@vmware.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1416335575-30717-1-git-send-email-bhavesh@vmware.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/1342/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/1342/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 95BBA7E70;\n\tTue, 18 Nov 2014 19:23:21 +0100 (CET)",
            "from smtp-outbound-1.vmware.com (smtp-outbound-1.vmware.com\n\t[208.91.2.12]) by dpdk.org (Postfix) with ESMTP id D7CF4595B\n\tfor <dev@dpdk.org>; Tue, 18 Nov 2014 19:23:18 +0100 (CET)",
            "from sc9-mailhost2.vmware.com (sc9-mailhost2.vmware.com\n\t[10.113.161.72])\n\tby smtp-outbound-1.vmware.com (Postfix) with ESMTP id 6070B2882E;\n\tTue, 18 Nov 2014 10:33:26 -0800 (PST)",
            "from vmware.com (unknown [10.20.89.204])\n\tby sc9-mailhost2.vmware.com (Postfix) with ESMTP id 33BFDB14B4;\n\tTue, 18 Nov 2014 10:33:26 -0800 (PST)"
        ],
        "From": "Bhavesh Davda <bhavesh@vmware.com>",
        "To": "dev@dpdk.org",
        "Date": "Tue, 18 Nov 2014 10:32:55 -0800",
        "Message-Id": "<1416335575-30717-1-git-send-email-bhavesh@vmware.com>",
        "X-Mailer": "git-send-email 2.2.0.rc2.4.gea4f93e",
        "Subject": "[dpdk-dev] [PATCH] examples: new txburst application",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Test application to transmit 32-packet bursts of 220-byte UDP packets every\n50 us, approximating 240,000 pps. We found it useful for testing hypervisor\nperformance for a transmit-heavy but bursty workload in a VM with DPDK.\n\nSigned-off-by: Bhavesh Davda <bhavesh@vmware.com>\n---\n examples/Makefile          |    1 +\n examples/txburst/Makefile  |   53 +++++++++\n examples/txburst/burst.c   |  221 +++++++++++++++++++++++++++++++++++\n examples/txburst/burst.h   |   55 +++++++++\n examples/txburst/txburst.c |  278 ++++++++++++++++++++++++++++++++++++++++++++\n examples/txburst/txburst.h |   40 +++++++\n 6 files changed, 648 insertions(+), 0 deletions(-)\n create mode 100644 examples/txburst/Makefile\n create mode 100644 examples/txburst/burst.c\n create mode 100644 examples/txburst/burst.h\n create mode 100644 examples/txburst/txburst.c\n create mode 100644 examples/txburst/txburst.h",
    "diff": "diff --git a/examples/Makefile b/examples/Makefile\nindex 121dab4..12b10e1 100644\n--- a/examples/Makefile\n+++ b/examples/Makefile\n@@ -62,6 +62,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_METER) += qos_meter\n DIRS-$(CONFIG_RTE_LIBRTE_SCHED) += qos_sched\n DIRS-y += quota_watermark\n DIRS-y += timer\n+DIRS-y += txburst\n DIRS-$(CONFIG_RTE_LIBRTE_VHOST) += vhost\n DIRS-$(CONFIG_RTE_LIBRTE_XEN_DOM0) += vhost_xen\n DIRS-y += vmdq\ndiff --git a/examples/txburst/Makefile b/examples/txburst/Makefile\nnew file mode 100644\nindex 0000000..38334f7\n--- /dev/null\n+++ b/examples/txburst/Makefile\n@@ -0,0 +1,53 @@\n+##########################################################\n+# Copyright (C) 2014 VMware, Inc. All rights reserved.\n+#\n+# Redistribution and use in source and binary forms, with or without\n+# modification, are permitted provided that the following conditions\n+# are met:\n+#\n+# 1. Redistributions of source code must retain the above copyright\n+#    notice, this list of conditions and the following disclaimer.\n+# 2. Redistributions in binary form must reproduce the above copyright\n+#    notice, this list of conditions and the following disclaimer in the\n+#    documentation and/or other materials provided with the distribution.\n+#\n+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\n+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n+# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\n+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n+# SUCH DAMAGE.\n+#\n+##########################################################\n+\n+ifeq ($(RTE_SDK),)\n+$(error \"Please define RTE_SDK environment variable\")\n+endif\n+\n+# Default target, can be overriden by command line or environment\n+RTE_TARGET ?= x86_64-default-linuxapp-gcc\n+\n+include $(RTE_SDK)/mk/rte.vars.mk\n+\n+# binary name\n+APP = txburst\n+\n+# all source are stored in SRCS-y\n+SRCS-y := txburst.c burst.c\n+\n+CFLAGS += $(WERROR_FLAGS)\n+\n+# workaround for a gcc bug with noreturn attribute\n+# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603\n+ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)\n+CFLAGS_main.o += -Wno-return-type\n+endif\n+\n+EXTRA_CFLAGS += -O3 -g -Wfatal-errors\n+\n+include $(RTE_SDK)/mk/rte.extapp.mk\ndiff --git a/examples/txburst/burst.c b/examples/txburst/burst.c\nnew file mode 100644\nindex 0000000..dd682e8\n--- /dev/null\n+++ b/examples/txburst/burst.c\n@@ -0,0 +1,221 @@\n+/*********************************************************\n+ * Copyright (C) 2014 VMware, Inc. All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions\n+ * are met:\n+ *\n+ * 1. Redistributions of source code must retain the above copyright\n+ *    notice, this list of conditions and the following disclaimer.\n+ * 2. Redistributions in binary form must reproduce the above copyright\n+ *    notice, this list of conditions and the following disclaimer in the\n+ *    documentation and/or other materials provided with the distribution.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\n+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\n+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n+ * SUCH DAMAGE.\n+ *\n+ *********************************************************/\n+\n+#include <rte_byteorder.h>\n+#include <rte_mbuf.h>\n+#include <rte_memcpy.h>\n+\n+#include \"burst.h\"\n+\n+#define IP_DEFTTL  64   /* from RFC 1340. */\n+#define IP_VERSION 0x40\n+#define IP_HDRLEN  0x05 /* default IP header length == five 32-bits words. */\n+#define IP_VHL_DEF (IP_VERSION | IP_HDRLEN)\n+\n+static void\n+copy_buf_to_pkt_segs(void *buf, unsigned len, struct rte_mbuf *pkt,\n+\t\tunsigned offset)\n+{\n+\tstruct rte_mbuf *seg;\n+\tvoid *seg_buf;\n+\tunsigned copy_len;\n+\n+\tseg = pkt;\n+\twhile (offset >= seg->data_len) {\n+\t\toffset -= seg->data_len;\n+\t\tseg = seg->next;\n+\t}\n+\tcopy_len = seg->data_len - offset;\n+\tseg_buf = rte_pktmbuf_mtod(seg, char *) + offset;\n+\twhile (len > copy_len) {\n+\t\trte_memcpy(seg_buf, buf, (size_t) copy_len);\n+\t\tlen -= copy_len;\n+\t\tbuf = ((char *) buf + copy_len);\n+\t\tseg = seg->next;\n+\t\tseg_buf = rte_pktmbuf_mtod(seg, void *);\n+\t}\n+\trte_memcpy(seg_buf, buf, (size_t) len);\n+}\n+\n+static inline void\n+copy_buf_to_pkt(void *buf, unsigned len, struct rte_mbuf *pkt, unsigned offset)\n+{\n+\tif (offset + len <= pkt->data_len) {\n+\t\trte_memcpy(rte_pktmbuf_mtod(pkt, char *) + offset,\n+\t\t\t\tbuf, (size_t) len);\n+\t\treturn;\n+\t}\n+\tcopy_buf_to_pkt_segs(buf, len, pkt, offset);\n+}\n+\n+\n+uint16_t\n+initialize_udp_header(struct udp_hdr *udp_hdr, uint16_t src_port,\n+\t\tuint16_t dst_port, uint16_t pkt_data_len)\n+{\n+\tuint16_t pkt_len;\n+\n+\tpkt_len = (uint16_t) (pkt_data_len + sizeof(struct udp_hdr));\n+\n+\tudp_hdr->src_port = rte_cpu_to_be_16(src_port);\n+\tudp_hdr->dst_port = rte_cpu_to_be_16(dst_port);\n+\tudp_hdr->dgram_len = rte_cpu_to_be_16(pkt_len);\n+\tudp_hdr->dgram_cksum = 0; /* No UDP checksum. */\n+\n+\treturn pkt_len;\n+}\n+\n+\n+uint16_t\n+initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t src_addr,\n+\t\tuint32_t dst_addr, uint16_t pkt_data_len)\n+{\n+\tuint16_t pkt_len;\n+\tuint16_t *ptr16;\n+\tuint32_t ip_cksum;\n+\n+\t/*\n+\t * Initialize IP header.\n+\t */\n+\tpkt_len = (uint16_t) (pkt_data_len + sizeof(struct ipv4_hdr));\n+\n+\tip_hdr->version_ihl   = IP_VHL_DEF;\n+\tip_hdr->type_of_service   = 0;\n+\tip_hdr->fragment_offset = 0;\n+\tip_hdr->time_to_live   = IP_DEFTTL;\n+\tip_hdr->next_proto_id = IPPROTO_UDP;\n+\tip_hdr->packet_id = 0;\n+\tip_hdr->total_length   = rte_cpu_to_be_16(pkt_len);\n+\tip_hdr->src_addr = rte_cpu_to_be_32(src_addr);\n+\tip_hdr->dst_addr = rte_cpu_to_be_32(dst_addr);\n+\n+\t/*\n+\t * Compute IP header checksum.\n+\t */\n+\tptr16 = (uint16_t *)ip_hdr;\n+\tip_cksum = 0;\n+\tip_cksum += ptr16[0]; ip_cksum += ptr16[1];\n+\tip_cksum += ptr16[2]; ip_cksum += ptr16[3];\n+\tip_cksum += ptr16[4];\n+\tip_cksum += ptr16[6]; ip_cksum += ptr16[7];\n+\tip_cksum += ptr16[8]; ip_cksum += ptr16[9];\n+\n+\t/*\n+\t * Reduce 32 bit checksum to 16 bits and complement it.\n+\t */\n+\tip_cksum = ((ip_cksum & 0xFFFF0000) >> 16) +\n+\t\t(ip_cksum & 0x0000FFFF);\n+\tip_cksum %= 65536;\n+\tip_cksum = (~ip_cksum) & 0x0000FFFF;\n+\tif (ip_cksum == 0)\n+\t\tip_cksum = 0xFFFF;\n+\tip_hdr->hdr_checksum = (uint16_t) ip_cksum;\n+\n+\treturn pkt_len;\n+}\n+\n+\n+\n+/*\n+ * The maximum number of segments per packet is used when creating\n+ * scattered transmit packets composed of a list of mbufs.\n+ */\n+#define RTE_MAX_SEGS_PER_PKT 255 /**< pkt.nb_segs is a 8-bit unsigned char. */\n+\n+#define TXONLY_DEF_PACKET_LEN 64\n+#define TXONLY_DEF_PACKET_LEN_220 220\n+\n+uint16_t tx_pkt_length = TXONLY_DEF_PACKET_LEN;\n+uint16_t tx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT] = {\n+\t\tTXONLY_DEF_PACKET_LEN_220,\n+};\n+\n+uint8_t  tx_pkt_nb_segs = 1;\n+\n+int\n+generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,\n+\t\tstruct ether_hdr *eth_hdr, void *ip_hdr,\n+\t\tstruct udp_hdr *udp_hdr, int nb_pkt_per_burst)\n+{\n+\tint i, nb_pkt = 0;\n+\tsize_t eth_hdr_size;\n+\n+\tstruct rte_mbuf *pkt_seg;\n+\tstruct rte_mbuf *pkt;\n+\n+\tfor (nb_pkt = 0; nb_pkt < nb_pkt_per_burst; nb_pkt++) {\n+\t\tpkt = rte_pktmbuf_alloc(mp);\n+\t\tif (pkt == NULL) {\n+nomore_mbuf:\n+\t\t\tif (nb_pkt == 0)\n+\t\t\t\treturn -1;\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tpkt->data_len = tx_pkt_seg_lengths[0];\n+\t\tpkt_seg = pkt;\n+\t\tfor (i = 1; i < tx_pkt_nb_segs; i++) {\n+\t\t\tpkt_seg->next = rte_pktmbuf_alloc(mp);\n+\t\t\tif (pkt_seg->next == NULL) {\n+\t\t\t\tpkt->nb_segs = i;\n+\t\t\t\trte_pktmbuf_free(pkt);\n+\t\t\t\tgoto nomore_mbuf;\n+\t\t\t}\n+\t\t\tpkt_seg = pkt_seg->next;\n+\t\t\tpkt_seg->data_len = tx_pkt_seg_lengths[i];\n+\t\t}\n+\t\tpkt_seg->next = NULL; /* Last segment of packet. */\n+\n+\t\t/*\n+\t\t * Copy headers in first packet segment(s).\n+\t\t */\n+\t\teth_hdr_size = sizeof(struct ether_hdr);\n+\n+\t\tcopy_buf_to_pkt(eth_hdr, eth_hdr_size, pkt, 0);\n+\n+\t\tcopy_buf_to_pkt(ip_hdr, sizeof(struct ipv4_hdr), pkt,\n+\t\t\teth_hdr_size);\n+\t\tcopy_buf_to_pkt(udp_hdr, sizeof(*udp_hdr), pkt,\n+\t\t\teth_hdr_size + sizeof(struct ipv4_hdr));\n+\n+\t\t/*\n+\t\t * Complete first mbuf of packet and append it to the\n+\t\t * burst of packets to be transmitted.\n+\t\t */\n+\t\tpkt->nb_segs = tx_pkt_nb_segs;\n+\t\tpkt->pkt_len = tx_pkt_length;\n+\t\tpkt->l2_len = eth_hdr_size;\n+\n+\t\tpkt->vlan_tci  = ETHER_TYPE_IPv4;\n+\t\tpkt->l3_len = sizeof(struct ipv4_hdr);\n+\t\tpkt->ol_flags = PKT_RX_IPV4_HDR;\n+\n+\t\tpkts_burst[nb_pkt] = pkt;\n+\t}\n+\n+\treturn nb_pkt;\n+}\ndiff --git a/examples/txburst/burst.h b/examples/txburst/burst.h\nnew file mode 100644\nindex 0000000..760c30f\n--- /dev/null\n+++ b/examples/txburst/burst.h\n@@ -0,0 +1,55 @@\n+/*********************************************************\n+ * Copyright (C) 2014 VMware, Inc. All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions\n+ * are met:\n+ *\n+ * 1. Redistributions of source code must retain the above copyright\n+ *    notice, this list of conditions and the following disclaimer.\n+ * 2. Redistributions in binary form must reproduce the above copyright\n+ *    notice, this list of conditions and the following disclaimer in the\n+ *    documentation and/or other materials provided with the distribution.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\n+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\n+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n+ * SUCH DAMAGE.\n+ *\n+ *********************************************************/\n+\n+#ifndef PACKET_BURST_GENERATOR_H_\n+#define PACKET_BURST_GENERATOR_H_\n+\n+#include <rte_mbuf.h>\n+#include <rte_ether.h>\n+#include <rte_ip.h>\n+#include <rte_udp.h>\n+\n+\n+#define IPV4_ADDR(a, b, c, d)(((a & 0xff) << 24) | ((b & 0xff) << 16) | \\\n+\t\t((c & 0xff) << 8) | (d & 0xff))\n+\n+\n+uint16_t\n+initialize_udp_header(struct udp_hdr *udp_hdr, uint16_t src_port,\n+\t\tuint16_t dst_port, uint16_t pkt_data_len);\n+\n+\n+uint16_t\n+initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t src_addr,\n+\t\tuint32_t dst_addr, uint16_t pkt_data_len);\n+\n+int\n+generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,\n+\t\tstruct ether_hdr *eth_hdr, void *ip_hdr,\n+\t\tstruct udp_hdr *udp_hdr, int nb_pkt_per_burst);\n+\n+#endif /* PACKET_BURST_GENERATOR_H_ */\ndiff --git a/examples/txburst/txburst.c b/examples/txburst/txburst.c\nnew file mode 100644\nindex 0000000..dbcb831\n--- /dev/null\n+++ b/examples/txburst/txburst.c\n@@ -0,0 +1,278 @@\n+/*********************************************************\n+ * Copyright (C) 2014 VMware, Inc. All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions\n+ * are met:\n+ *\n+ * 1. Redistributions of source code must retain the above copyright\n+ *    notice, this list of conditions and the following disclaimer.\n+ * 2. Redistributions in binary form must reproduce the above copyright\n+ *    notice, this list of conditions and the following disclaimer in the\n+ *    documentation and/or other materials provided with the distribution.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\n+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\n+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n+ * SUCH DAMAGE.\n+ *\n+ *********************************************************/\n+\n+#include <stdint.h>\n+#include <inttypes.h>\n+#include <time.h>\n+#include <sys/time.h>\n+#include <rte_eal.h>\n+#include <rte_ethdev.h>\n+#include <rte_cycles.h>\n+#include <rte_lcore.h>\n+#include <rte_mbuf.h>\n+#include <rte_byteorder.h>\n+#include \"txburst.h\"\n+#include \"burst.h\"\n+\n+#define RX_RING_SIZE 128\n+#define RX_FREE_THRESH 32\n+#define RX_PTHRESH 8\n+#define RX_HTHRESH 8\n+#define RX_WTHRESH 0\n+\n+#define TX_RING_SIZE 512\n+#define TX_FREE_THRESH 32\n+#define TX_PTHRESH 32\n+#define TX_HTHRESH 0\n+#define TX_WTHRESH 0\n+#define TX_RSBIT_THRESH 32\n+#define TX_Q_FLAGS (ETH_TXQ_FLAGS_NOMULTSEGS | ETH_TXQ_FLAGS_NOVLANOFFL |\\\n+\tETH_TXQ_FLAGS_NOXSUMSCTP | ETH_TXQ_FLAGS_NOXSUMUDP | \\\n+\tETH_TXQ_FLAGS_NOXSUMTCP)\n+\n+#define NUM_MBUFS 8191\n+#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM)\n+#define MBUF_CACHE_SIZE 250\n+#define BURST_SIZE 32\n+\n+static struct rte_eth_conf port_conf_default = {\n+\t.rxmode = {\n+\t\t.mq_mode = ETH_MQ_RX_NONE,\n+\t\t.max_rx_pkt_len = ETHER_MAX_LEN,\n+\t\t.split_hdr_size = 0,\n+\t\t.header_split   = 0, /**< Header Split disabled */\n+\t\t.hw_ip_checksum = 0, /**< IP checksum offload enabled */\n+\t\t.hw_vlan_filter = 0, /**< VLAN filtering disabled */\n+\t\t.jumbo_frame    = 0, /**< Jumbo Frame Support disabled */\n+\t\t.hw_strip_crc   = 0, /**< CRC stripped by hardware */\n+\t},\n+\t.txmode = {\n+\t\t.mq_mode = ETH_MQ_TX_NONE,\n+\t},\n+\t.lpbk_mode = 0,\n+};\n+\n+static const struct rte_eth_rxconf rx_conf_default = {\n+\t.rx_thresh = {\n+\t\t.pthresh = RX_PTHRESH,\n+\t\t.hthresh = RX_HTHRESH,\n+\t\t.wthresh = RX_WTHRESH,\n+\t},\n+\t.rx_free_thresh = RX_FREE_THRESH,\n+\t.rx_drop_en = 0,\n+};\n+\n+static struct rte_eth_txconf tx_conf_default = {\n+\t.tx_thresh = {\n+\t\t.pthresh = TX_PTHRESH,\n+\t\t.hthresh = TX_HTHRESH,\n+\t\t.wthresh = TX_WTHRESH,\n+\t},\n+\t.tx_free_thresh = TX_FREE_THRESH,\n+\t.tx_rs_thresh = TX_RSBIT_THRESH,\n+\t.txq_flags = TX_Q_FLAGS\n+\n+};\n+\n+static struct rte_mbuf *mbufs[2][BURST_SIZE * 100];\n+static uint32_t src_addr = IPV4_ADDR(192, 168, 1, 98);\n+static uint32_t dst_addr = IPV4_ADDR(192, 168, 1, 99);\n+\n+static struct timespec tv = {\n+\t.tv_sec = 0,\n+\t.tv_nsec = 50000\t\t/* 50 us */\n+};\n+\n+/*\n+ * Initialises a given port using global settings and with the rx buffers\n+ * coming from the mbuf_pool passed as parameter\n+ */\n+static inline int\n+port_init(uint8_t port, struct rte_mempool *mbuf_pool)\n+{\n+\tstruct rte_eth_conf port_conf = port_conf_default;\n+\tconst uint16_t rxRings = 1, txRings = 1;\n+\tint retval;\n+\tuint16_t q;\n+\n+\tif (port >= rte_eth_dev_count())\n+\t\treturn -1;\n+\n+\tretval = rte_eth_dev_configure(port, rxRings, txRings, &port_conf);\n+\tif (retval != 0)\n+\t\treturn retval;\n+\n+\tfor (q = 0; q < rxRings; q++) {\n+\t\tretval = rte_eth_rx_queue_setup(port, q, RX_RING_SIZE,\n+\t\t\t\trte_eth_dev_socket_id(port), &rx_conf_default,\n+\t\t\t\tmbuf_pool);\n+\t\tif (retval < 0)\n+\t\t\treturn retval;\n+\t}\n+\n+\tfor (q = 0; q < txRings; q++) {\n+\t\tretval = rte_eth_tx_queue_setup(port, q, TX_RING_SIZE,\n+\t\t\t\trte_eth_dev_socket_id(port), &tx_conf_default);\n+\t\tif (retval < 0)\n+\t\t\treturn retval;\n+\t}\n+\n+\tretval  = rte_eth_dev_start(port);\n+\tif (retval < 0)\n+\t\treturn retval;\n+\n+\tstruct ether_addr addr;\n+\n+\trte_eth_macaddr_get(port, &addr);\n+\tprintf(\"Port %u MAC: %02\"PRIx8\" %02\"PRIx8\" %02\"PRIx8\n+\t\t\t\" %02\"PRIx8\" %02\"PRIx8\" %02\"PRIx8\"\\n\",\n+\t\t\t(unsigned)port,\n+\t\t\taddr.addr_bytes[0], addr.addr_bytes[1],\n+\t\t\taddr.addr_bytes[2], addr.addr_bytes[3],\n+\t\t\taddr.addr_bytes[4], addr.addr_bytes[5]);\n+\n+\tstruct ether_hdr eth_hdr;\n+\n+\teth_hdr.s_addr = addr;\n+\taddr.addr_bytes[5] ^= 1;\n+\teth_hdr.d_addr = addr;\n+\teth_hdr.ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4);\n+\n+\tint pkt_len;\n+\tstruct udp_hdr udp_hdr;\n+\tstruct ipv4_hdr ip_hdr;\n+\n+\tpkt_len = initialize_udp_header(&udp_hdr, 0x0246, 0x0357, 174);\n+\tpkt_len = initialize_ipv4_header(&ip_hdr, src_addr, dst_addr, pkt_len);\n+\n+\tint num_pkts;\n+\n+\tnum_pkts = generate_packet_burst(mbuf_pool, &mbufs[port][0],\n+\t\t\t&eth_hdr, &ip_hdr,\n+\t\t\t&udp_hdr, BURST_SIZE * 100);\n+\n+\tif (num_pkts < BURST_SIZE * 100)\n+\t\trte_exit(EXIT_FAILURE, \"Cannot allocate packet bursts\\n\");\n+\n+\treturn 0;\n+}\n+\n+/*\n+ * Main thread that does the work, reading from INPUT_PORT\n+ * and writing to OUTPUT_PORT\n+ */\n+static  __attribute__((noreturn)) void\n+lcore_main(void)\n+{\n+\tconst uint8_t nb_ports = rte_eth_dev_count();\n+\tuint8_t port;\n+\tint burst_cycle = 0;\n+\tunsigned long pktsTxed = 0;\n+\tstruct timeval tvStart, tvEnd, tvDiff, tvLastDrop, tvNow;\n+\tstruct timespec tvrem;\n+\n+\tprintf(\"\\nCore %u transmitting packets. [Ctrl+C to quit]\\n\",\n+\t\t\trte_lcore_id());\n+\tgettimeofday(&tvStart, NULL);\n+\ttvLastDrop = tvStart;\n+\tfor (;;) {\n+\t\tfor (port = 0; port < nb_ports; port++) {\n+\t\t\tconst uint16_t nb_tx = rte_eth_tx_burst(port, 0,\n+\t\t\t\t\t&mbufs[port]\n+\t\t\t\t\t[(burst_cycle % 100) * BURST_SIZE],\n+\t\t\t\t\tBURST_SIZE);\n+\t\t\tpktsTxed += nb_tx;\n+\t\t\tif (unlikely(nb_tx < BURST_SIZE)) {\n+\t\t\t\tgettimeofday(&tvNow, NULL);\n+\t\t\t\ttimersub(&tvNow, &tvLastDrop, &tvDiff);\n+\t\t\t\tprintf(\"Port %d dropped %d (Time since last \"\n+\t\t\t\t\t\"drop %g s)\\n\", port,\n+\t\t\t\t\tBURST_SIZE - nb_tx, tvDiff.tv_sec +\n+\t\t\t\t\ttvDiff.tv_usec/1000000.0);\n+\t\t\t\ttvLastDrop = tvNow;\n+\t\t\t}\n+\t\t}\n+\t\tburst_cycle++;\n+\t\tif (burst_cycle % 50000 == 0) {\n+\t\t\tgettimeofday(&tvEnd, NULL);\n+\t\t\ttimersub(&tvEnd, &tvStart, &tvDiff);\n+\t\t\tprintf(\"%g pps...\",\n+\t\t\t\tpktsTxed / (tvDiff.tv_sec + tvDiff.tv_usec/1000000.0));\n+\t\t\tif (burst_cycle % 500000 == 0)\n+\t\t\t\tprintf(\"\\n\");\n+\t\t\tfflush(stdout);\n+\t\t\tpktsTxed = 0;\n+\t\t\ttvStart = tvEnd;\n+\t\t}\n+\t\ttvrem = tv;\n+\t\twhile (nanosleep(&tvrem, &tvrem) != 0)\n+\t\t\t;\n+\t}\n+}\n+\n+/* Main function, does initialisation and calls the per-lcore functions */\n+int\n+MAIN(int argc, char *argv[])\n+{\n+\tstruct rte_mempool *mbuf_pool;\n+\tunsigned nb_ports;\n+\tuint8_t portid;\n+\n+\t/* init EAL */\n+\tint ret = rte_eal_init(argc, argv);\n+\n+\tif (ret < 0)\n+\t\trte_exit(EXIT_FAILURE, \"Error with EAL initialization\\n\");\n+\targc -= ret;\n+\targv += ret;\n+\n+\tnb_ports = rte_eth_dev_count();\n+\tif (nb_ports > 2)\n+\t\trte_exit(EXIT_FAILURE, \"Error: number of ports must be <=2\\n\");\n+\n+\tmbuf_pool = rte_mempool_create(\"MBUF_POOL\", NUM_MBUFS * nb_ports,\n+\t\t\t\t       MBUF_SIZE, MBUF_CACHE_SIZE,\n+\t\t\t\t       sizeof(struct rte_pktmbuf_pool_private),\n+\t\t\t\t       rte_pktmbuf_pool_init, NULL,\n+\t\t\t\t       rte_pktmbuf_init, NULL,\n+\t\t\t\t       rte_socket_id(), 0);\n+\tif (mbuf_pool == NULL)\n+\t\trte_exit(EXIT_FAILURE, \"Cannot create mbuf pool\\n\");\n+\n+\t/* initialize all ports */\n+\tfor (portid = 0; portid < nb_ports; portid++)\n+\t\tif (port_init(portid, mbuf_pool) != 0)\n+\t\t\trte_exit(EXIT_FAILURE, \"Cannot init port %\"PRIu8\"\\n\",\n+\t\t\t\t\tportid);\n+\n+\tif (rte_lcore_count() > 1)\n+\t\tprintf(\"\\nWARNING: Coremask too big - App uses only 1 lcore\\n\");\n+\n+\t/* call lcore_main on master core only */\n+\tlcore_main();\n+\treturn 0;\n+}\ndiff --git a/examples/txburst/txburst.h b/examples/txburst/txburst.h\nnew file mode 100644\nindex 0000000..909dd3b\n--- /dev/null\n+++ b/examples/txburst/txburst.h\n@@ -0,0 +1,40 @@\n+/*********************************************************\n+ * Copyright (C) 2014 VMware, Inc. All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions\n+ * are met:\n+ *\n+ * 1. Redistributions of source code must retain the above copyright\n+ *    notice, this list of conditions and the following disclaimer.\n+ * 2. Redistributions in binary form must reproduce the above copyright\n+ *    notice, this list of conditions and the following disclaimer in the\n+ *    documentation and/or other materials provided with the distribution.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\n+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\n+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n+ * SUCH DAMAGE.\n+ *\n+ *********************************************************/\n+\n+#ifndef _MAIN_H_\n+#define _MAIN_H_\n+\n+\n+#ifdef RTE_EXEC_ENV_BAREMETAL\n+#define MAIN _main\n+#else\n+#define MAIN main\n+#endif\n+\n+int MAIN(int argc, char *argv[]);\n+\n+#endif /* ifndef _MAIN_H_ */\n",
    "prefixes": [
        "dpdk-dev"
    ]
}