get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 46,
    "url": "http://patches.dpdk.org/api/patches/46/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1405362290-6753-1-git-send-email-linville@tuxdriver.com/",
    "project": {
        "id": 1,
        "url": "http://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": "<1405362290-6753-1-git-send-email-linville@tuxdriver.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1405362290-6753-1-git-send-email-linville@tuxdriver.com",
    "date": "2014-07-14T18:24:50",
    "name": "[dpdk-dev,v2] librte_pmd_packet: add PMD for AF_PACKET-based virtual devices",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "aa8134b7e8abffb551f1b7434d3f8ee9b78c55f9",
    "submitter": {
        "id": 26,
        "url": "http://patches.dpdk.org/api/people/26/?format=api",
        "name": "John W. Linville",
        "email": "linville@tuxdriver.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1405362290-6753-1-git-send-email-linville@tuxdriver.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/46/comments/",
    "check": "pending",
    "checks": "http://patches.dpdk.org/api/patches/46/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<linville@tuxdriver.com>",
        "Received": [
            "from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58])\n\tby dpdk.org (Postfix) with ESMTP id 0FA5F68CB\n\tfor <dev@dpdk.org>; Mon, 14 Jul 2014 20:29:31 +0200 (CEST)",
            "from uucp by smtp.tuxdriver.com with local-rmail (Exim 4.63)\n\t(envelope-from <linville@tuxdriver.com>)\n\tid 1X6l0q-0004DT-6P; Mon, 14 Jul 2014 14:30:08 -0400",
            "from linville-x1.hq.tuxdriver.com (localhost.localdomain\n\t[127.0.0.1])\n\tby linville-x1.hq.tuxdriver.com (8.14.8/8.14.6) with ESMTP id\n\ts6EIP12H006791; Mon, 14 Jul 2014 14:25:01 -0400",
            "(from linville@localhost)\n\tby linville-x1.hq.tuxdriver.com (8.14.8/8.14.8/Submit) id\n\ts6EIP0es006790; Mon, 14 Jul 2014 14:25:00 -0400"
        ],
        "X-Authentication-Warning": "linville-x1.hq.tuxdriver.com: linville set sender\n\tto linville@tuxdriver.com using -f",
        "From": "\"John W. Linville\" <linville@tuxdriver.com>",
        "To": "dev@dpdk.org",
        "Date": "Mon, 14 Jul 2014 14:24:50 -0400",
        "Message-Id": "<1405362290-6753-1-git-send-email-linville@tuxdriver.com>",
        "X-Mailer": "git-send-email 1.9.3",
        "In-Reply-To": "<1405024369-30058-1-git-send-email-linville@tuxdriver.com>",
        "References": "<1405024369-30058-1-git-send-email-linville@tuxdriver.com>",
        "Subject": "[dpdk-dev] [PATCH v2] librte_pmd_packet: add PMD for\n\tAF_PACKET-based virtual devices",
        "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>",
        "X-List-Received-Date": "Mon, 14 Jul 2014 18:29:32 -0000"
    },
    "content": "This is a Linux-specific virtual PMD driver backed by an AF_PACKET\nsocket.  This implementation uses mmap'ed ring buffers to limit copying\nand user/kernel transitions.  The PACKET_FANOUT_HASH behavior of\nAF_PACKET is used for frame reception.  In the current implementation,\nTx and Rx queues are always paired, and therefore are always equal\nin number -- changing this would be a Simple Matter Of Programming.\n\nInterfaces of this type are created with a command line option like\n\"--vdev=eth_packet0,iface=...\".  There are a number of options availabe\nas arguments:\n\n - Interface is chosen by \"iface\" (required)\n - Number of queue pairs set by \"qpairs\" (optional, default: 1)\n - AF_PACKET MMAP block size set by \"blocksz\" (optional, default: 4096)\n - AF_PACKET MMAP frame size set by \"framesz\" (optional, default: 2048)\n - AF_PACKET MMAP frame count set by \"framecnt\" (optional, default: 512)\n\nSigned-off-by: John W. Linville <linville@tuxdriver.com>\n---\nThis PMD is intended to provide a means for using DPDK on a broad\nrange of hardware without hardware-specific PMDs and (hopefully)\nwith better performance than what PCAP offers in Linux.  This might\nbe useful as a development platform for DPDK applications when\nDPDK-supported hardware is expensive or unavailable.\n\nNew in v2:\n\n-- fixup some style issues found by check patch\n-- use if_index as part of fanout group ID\n-- set default number of queue pairs to 1\n\n config/common_bsdapp                   |   5 +\n config/common_linuxapp                 |   5 +\n lib/Makefile                           |   1 +\n lib/librte_eal/linuxapp/eal/Makefile   |   1 +\n lib/librte_pmd_packet/Makefile         |  60 +++\n lib/librte_pmd_packet/rte_eth_packet.c | 826 +++++++++++++++++++++++++++++++++\n lib/librte_pmd_packet/rte_eth_packet.h |  55 +++\n mk/rte.app.mk                          |   4 +\n 8 files changed, 957 insertions(+)\n create mode 100644 lib/librte_pmd_packet/Makefile\n create mode 100644 lib/librte_pmd_packet/rte_eth_packet.c\n create mode 100644 lib/librte_pmd_packet/rte_eth_packet.h",
    "diff": "diff --git a/config/common_bsdapp b/config/common_bsdapp\nindex 943dce8f1ede..c317f031278e 100644\n--- a/config/common_bsdapp\n+++ b/config/common_bsdapp\n@@ -226,6 +226,11 @@ CONFIG_RTE_LIBRTE_PMD_PCAP=y\n CONFIG_RTE_LIBRTE_PMD_BOND=y\n \n #\n+# Compile software PMD backed by AF_PACKET sockets (Linux only)\n+#\n+CONFIG_RTE_LIBRTE_PMD_PACKET=n\n+\n+#\n # Do prefetch of packet data within PMD driver receive function\n #\n CONFIG_RTE_PMD_PACKET_PREFETCH=y\ndiff --git a/config/common_linuxapp b/config/common_linuxapp\nindex 7bf5d80d4e26..f9e7bc3015ec 100644\n--- a/config/common_linuxapp\n+++ b/config/common_linuxapp\n@@ -249,6 +249,11 @@ CONFIG_RTE_LIBRTE_PMD_PCAP=n\n CONFIG_RTE_LIBRTE_PMD_BOND=y\n \n #\n+# Compile software PMD backed by AF_PACKET sockets (Linux only)\n+#\n+CONFIG_RTE_LIBRTE_PMD_PACKET=y\n+\n+#\n # Compile Xen PMD\n #\n CONFIG_RTE_LIBRTE_PMD_XENVIRT=n\ndiff --git a/lib/Makefile b/lib/Makefile\nindex 10c5bb3045bc..930fadf29898 100644\n--- a/lib/Makefile\n+++ b/lib/Makefile\n@@ -47,6 +47,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += librte_pmd_i40e\n DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond\n DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += librte_pmd_ring\n DIRS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += librte_pmd_pcap\n+DIRS-$(CONFIG_RTE_LIBRTE_PMD_PACKET) += librte_pmd_packet\n DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += librte_pmd_virtio\n DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += librte_pmd_vmxnet3\n DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += librte_pmd_xenvirt\ndiff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile\nindex 756d6b0c9301..feed24a63272 100644\n--- a/lib/librte_eal/linuxapp/eal/Makefile\n+++ b/lib/librte_eal/linuxapp/eal/Makefile\n@@ -44,6 +44,7 @@ CFLAGS += -I$(RTE_SDK)/lib/librte_ether\n CFLAGS += -I$(RTE_SDK)/lib/librte_ivshmem\n CFLAGS += -I$(RTE_SDK)/lib/librte_pmd_ring\n CFLAGS += -I$(RTE_SDK)/lib/librte_pmd_pcap\n+CFLAGS += -I$(RTE_SDK)/lib/librte_pmd_packet\n CFLAGS += -I$(RTE_SDK)/lib/librte_pmd_xenvirt\n CFLAGS += $(WERROR_FLAGS) -O3\n \ndiff --git a/lib/librte_pmd_packet/Makefile b/lib/librte_pmd_packet/Makefile\nnew file mode 100644\nindex 000000000000..e1266fb992cd\n--- /dev/null\n+++ b/lib/librte_pmd_packet/Makefile\n@@ -0,0 +1,60 @@\n+#   BSD LICENSE\n+#\n+#   Copyright(c) 2014 John W. Linville <linville@redhat.com>\n+#   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+#   Copyright(c) 2014 6WIND S.A.\n+#   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+#     * Redistributions of source code must retain the above copyright\n+#       notice, this list of conditions and the following disclaimer.\n+#     * Redistributions in binary form must reproduce the above copyright\n+#       notice, this list of conditions and the following disclaimer in\n+#       the documentation and/or other materials provided with the\n+#       distribution.\n+#     * Neither the name of Intel Corporation nor the names of its\n+#       contributors may be used to endorse or promote products derived\n+#       from this software without specific prior written permission.\n+#\n+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+#   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+\n+include $(RTE_SDK)/mk/rte.vars.mk\n+\n+#\n+# library name\n+#\n+LIB = librte_pmd_packet.a\n+\n+CFLAGS += -O3\n+CFLAGS += $(WERROR_FLAGS)\n+\n+#\n+# all source are stored in SRCS-y\n+#\n+SRCS-$(CONFIG_RTE_LIBRTE_PMD_PACKET) += rte_eth_packet.c\n+\n+#\n+# Export include files\n+#\n+SYMLINK-y-include += rte_eth_packet.h\n+\n+# this lib depends upon:\n+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_PACKET) += lib/librte_mbuf\n+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_PACKET) += lib/librte_ether\n+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_PACKET) += lib/librte_malloc\n+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_PACKET) += lib/librte_kvargs\n+\n+include $(RTE_SDK)/mk/rte.lib.mk\ndiff --git a/lib/librte_pmd_packet/rte_eth_packet.c b/lib/librte_pmd_packet/rte_eth_packet.c\nnew file mode 100644\nindex 000000000000..9c82d16e730f\n--- /dev/null\n+++ b/lib/librte_pmd_packet/rte_eth_packet.c\n@@ -0,0 +1,826 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2014 John W. Linville <linville@tuxdriver.com>\n+ *\n+ *   Originally based upon librte_pmd_pcap code:\n+ *\n+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ *   Copyright(c) 2014 6WIND S.A.\n+ *   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+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#include <rte_mbuf.h>\n+#include <rte_ethdev.h>\n+#include <rte_malloc.h>\n+#include <rte_kvargs.h>\n+#include <rte_dev.h>\n+\n+#include <linux/if_ether.h>\n+#include <linux/if_packet.h>\n+#include <arpa/inet.h>\n+#include <net/if.h>\n+#include <sys/types.h>\n+#include <sys/socket.h>\n+#include <sys/ioctl.h>\n+#include <sys/mman.h>\n+#include <unistd.h>\n+#include <poll.h>\n+\n+#include \"rte_eth_packet.h\"\n+\n+#define ETH_PACKET_IFACE_ARG\t\t\"iface\"\n+#define ETH_PACKET_NUM_Q_ARG\t\t\"qpairs\"\n+#define ETH_PACKET_BLOCKSIZE_ARG\t\"blocksz\"\n+#define ETH_PACKET_FRAMESIZE_ARG\t\"framesz\"\n+#define ETH_PACKET_FRAMECOUNT_ARG\t\"framecnt\"\n+\n+#define DFLT_BLOCK_SIZE\t\t(1 << 12)\n+#define DFLT_FRAME_SIZE\t\t(1 << 11)\n+#define DFLT_FRAME_COUNT\t(1 << 9)\n+\n+struct pkt_rx_queue {\n+\tint sockfd;\n+\n+\tstruct iovec *rd;\n+\tuint8_t *map;\n+\tunsigned int framecount;\n+\tunsigned int framenum;\n+\n+\tstruct rte_mempool *mb_pool;\n+\n+\tvolatile unsigned long rx_pkts;\n+\tvolatile unsigned long err_pkts;\n+};\n+\n+struct pkt_tx_queue {\n+\tint sockfd;\n+\n+\tstruct iovec *rd;\n+\tuint8_t *map;\n+\tunsigned int framecount;\n+\tunsigned int framenum;\n+\n+\tvolatile unsigned long tx_pkts;\n+\tvolatile unsigned long err_pkts;\n+};\n+\n+struct pmd_internals {\n+\tunsigned nb_queues;\n+\n+\tint if_index;\n+\tstruct ether_addr eth_addr;\n+\n+\tstruct tpacket_req req;\n+\n+\tstruct pkt_rx_queue rx_queue[RTE_PMD_PACKET_MAX_RINGS];\n+\tstruct pkt_tx_queue tx_queue[RTE_PMD_PACKET_MAX_RINGS];\n+};\n+\n+static const char *valid_arguments[] = {\n+\tETH_PACKET_IFACE_ARG,\n+\tETH_PACKET_NUM_Q_ARG,\n+\tETH_PACKET_BLOCKSIZE_ARG,\n+\tETH_PACKET_FRAMESIZE_ARG,\n+\tETH_PACKET_FRAMECOUNT_ARG,\n+\tNULL\n+};\n+\n+static const char *drivername = \"AF_PACKET PMD\";\n+\n+static struct rte_eth_link pmd_link = {\n+\t.link_speed = 10000,\n+\t.link_duplex = ETH_LINK_FULL_DUPLEX,\n+\t.link_status = 0\n+};\n+\n+static uint16_t\n+eth_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)\n+{\n+\tunsigned i;\n+\tstruct tpacket2_hdr *ppd;\n+\tstruct rte_mbuf *mbuf;\n+\tuint8_t *pbuf;\n+\tstruct pkt_rx_queue *pkt_q = queue;\n+\tuint16_t num_rx = 0;\n+\tunsigned int framecount, framenum;\n+\n+\tif (unlikely(nb_pkts == 0))\n+\t\treturn 0;\n+\n+\t/*\n+\t * Reads the given number of packets from the AF_PACKET socket one by\n+\t * one and copies the packet data into a newly allocated mbuf.\n+\t */\n+\tframecount = pkt_q->framecount;\n+\tframenum = pkt_q->framenum;\n+\tfor (i = 0; i < nb_pkts; i++) {\n+\t\t/* point at the next incoming frame */\n+\t\tppd = (struct tpacket2_hdr *) pkt_q->rd[framenum].iov_base;\n+\t\tif ((ppd->tp_status & TP_STATUS_USER) == 0)\n+\t\t\tbreak;\n+\n+\t\t/* allocate the next mbuf */\n+\t\tmbuf = rte_pktmbuf_alloc(pkt_q->mb_pool);\n+\t\tif (unlikely(mbuf == NULL))\n+\t\t\tbreak;\n+\n+\t\t/* packet will fit in the mbuf, go ahead and receive it */\n+\t\tmbuf->pkt.pkt_len = mbuf->pkt.data_len = ppd->tp_snaplen;\n+\t\tpbuf = (uint8_t *) ppd + ppd->tp_mac;\n+\t\tmemcpy(mbuf->pkt.data, pbuf, mbuf->pkt.data_len);\n+\n+\t\t/* release incoming frame and advance ring buffer */\n+\t\tppd->tp_status = TP_STATUS_KERNEL;\n+\t\tif (++framenum >= framecount)\n+\t\t\tframenum = 0;\n+\n+\t\t/* account for the receive frame */\n+\t\tbufs[i] = mbuf;\n+\t\tnum_rx++;\n+\t}\n+\tpkt_q->framenum = framenum;\n+\tpkt_q->rx_pkts += num_rx;\n+\treturn num_rx;\n+}\n+\n+/*\n+ * Callback to handle sending packets through a real NIC.\n+ */\n+static uint16_t\n+eth_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)\n+{\n+\tstruct tpacket2_hdr *ppd;\n+\tstruct rte_mbuf *mbuf;\n+\tuint8_t *pbuf;\n+\tunsigned int framecount, framenum;\n+\tstruct pollfd pfd;\n+\tstruct pkt_tx_queue *pkt_q = queue;\n+\tuint16_t num_tx = 0;\n+\tint i;\n+\n+\tif (unlikely(nb_pkts == 0))\n+\t\treturn 0;\n+\n+\tmemset(&pfd, 0, sizeof(pfd));\n+\tpfd.fd = pkt_q->sockfd;\n+\tpfd.events = POLLOUT;\n+\tpfd.revents = 0;\n+\n+\tframecount = pkt_q->framecount;\n+\tframenum = pkt_q->framenum;\n+\tppd = (struct tpacket2_hdr *) pkt_q->rd[framenum].iov_base;\n+\tfor (i = 0; i < nb_pkts; i++) {\n+\t\t/* point at the next incoming frame */\n+\t\tif ((ppd->tp_status != TP_STATUS_AVAILABLE) &&\n+\t\t    (poll(&pfd, 1, -1) < 0))\n+\t\t\t\tcontinue;\n+\n+\t\t/* copy the tx frame data */\n+\t\tmbuf = bufs[num_tx];\n+\t\tpbuf = (uint8_t *) ppd + TPACKET2_HDRLEN -\n+\t\t\tsizeof(struct sockaddr_ll);\n+\t\tmemcpy(pbuf, mbuf->pkt.data, mbuf->pkt.data_len);\n+\t\tppd->tp_len = ppd->tp_snaplen = mbuf->pkt.data_len;\n+\n+\t\t/* release incoming frame and advance ring buffer */\n+\t\tppd->tp_status = TP_STATUS_SEND_REQUEST;\n+\t\tif (++framenum >= framecount)\n+\t\t\tframenum = 0;\n+\t\tppd = (struct tpacket2_hdr *) pkt_q->rd[framenum].iov_base;\n+\n+\t\tnum_tx++;\n+\t\trte_pktmbuf_free(mbuf);\n+\t}\n+\n+\t/* kick-off transmits */\n+\tsendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0);\n+\n+\tpkt_q->framenum = framenum;\n+\tpkt_q->tx_pkts += num_tx;\n+\tpkt_q->err_pkts += nb_pkts - num_tx;\n+\treturn num_tx;\n+}\n+\n+static int\n+eth_dev_start(struct rte_eth_dev *dev)\n+{\n+\tdev->data->dev_link.link_status = 1;\n+\treturn 0;\n+}\n+\n+/*\n+ * This function gets called when the current port gets stopped.\n+ */\n+static void\n+eth_dev_stop(struct rte_eth_dev *dev)\n+{\n+\tunsigned i;\n+\tint sockfd;\n+\tstruct pmd_internals *internals = dev->data->dev_private;\n+\n+\tfor (i = 0; i < internals->nb_queues; i++) {\n+\t\tsockfd = internals->rx_queue[i].sockfd;\n+\t\tif (sockfd != -1)\n+\t\t\tclose(sockfd);\n+\t\tsockfd = internals->tx_queue[i].sockfd;\n+\t\tif (sockfd != -1)\n+\t\t\tclose(sockfd);\n+\t}\n+\n+\tdev->data->dev_link.link_status = 0;\n+}\n+\n+static int\n+eth_dev_configure(struct rte_eth_dev *dev __rte_unused)\n+{\n+\treturn 0;\n+}\n+\n+static void\n+eth_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)\n+{\n+\tstruct pmd_internals *internals = dev->data->dev_private;\n+\n+\tdev_info->driver_name = drivername;\n+\tdev_info->if_index = internals->if_index;\n+\tdev_info->max_mac_addrs = 1;\n+\tdev_info->max_rx_pktlen = (uint32_t)ETH_FRAME_LEN;\n+\tdev_info->max_rx_queues = (uint16_t)internals->nb_queues;\n+\tdev_info->max_tx_queues = (uint16_t)internals->nb_queues;\n+\tdev_info->min_rx_bufsize = 0;\n+\tdev_info->pci_dev = NULL;\n+}\n+\n+static void\n+eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats)\n+{\n+\tunsigned i, imax;\n+\tunsigned long rx_total = 0, tx_total = 0, tx_err_total = 0;\n+\tconst struct pmd_internals *internal = dev->data->dev_private;\n+\n+\tmemset(igb_stats, 0, sizeof(*igb_stats));\n+\n+\timax = (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ?\n+\t        internal->nb_queues : RTE_ETHDEV_QUEUE_STAT_CNTRS);\n+\tfor (i = 0; i < imax; i++) {\n+\t\tigb_stats->q_ipackets[i] = internal->rx_queue[i].rx_pkts;\n+\t\trx_total += igb_stats->q_ipackets[i];\n+\t}\n+\n+\timax = (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ?\n+\t        internal->nb_queues : RTE_ETHDEV_QUEUE_STAT_CNTRS);\n+\tfor (i = 0; i < imax; i++) {\n+\t\tigb_stats->q_opackets[i] = internal->tx_queue[i].tx_pkts;\n+\t\tigb_stats->q_errors[i] = internal->tx_queue[i].err_pkts;\n+\t\ttx_total += igb_stats->q_opackets[i];\n+\t\ttx_err_total += igb_stats->q_errors[i];\n+\t}\n+\n+\tigb_stats->ipackets = rx_total;\n+\tigb_stats->opackets = tx_total;\n+\tigb_stats->oerrors = tx_err_total;\n+}\n+\n+static void\n+eth_stats_reset(struct rte_eth_dev *dev)\n+{\n+\tunsigned i;\n+\tstruct pmd_internals *internal = dev->data->dev_private;\n+\n+\tfor (i = 0; i < internal->nb_queues; i++)\n+\t\tinternal->rx_queue[i].rx_pkts = 0;\n+\n+\tfor (i = 0; i < internal->nb_queues; i++) {\n+\t\tinternal->tx_queue[i].tx_pkts = 0;\n+\t\tinternal->tx_queue[i].err_pkts = 0;\n+\t}\n+}\n+\n+static void\n+eth_dev_close(struct rte_eth_dev *dev __rte_unused)\n+{\n+}\n+\n+static void\n+eth_queue_release(void *q __rte_unused)\n+{\n+}\n+\n+static int\n+eth_link_update(struct rte_eth_dev *dev __rte_unused,\n+                int wait_to_complete __rte_unused)\n+{\n+\treturn 0;\n+}\n+\n+static int\n+eth_rx_queue_setup(struct rte_eth_dev *dev,\n+                   uint16_t rx_queue_id,\n+                   uint16_t nb_rx_desc __rte_unused,\n+                   unsigned int socket_id __rte_unused,\n+                   const struct rte_eth_rxconf *rx_conf __rte_unused,\n+                   struct rte_mempool *mb_pool)\n+{\n+\tstruct pmd_internals *internals = dev->data->dev_private;\n+\tstruct pkt_rx_queue *pkt_q = &internals->rx_queue[rx_queue_id];\n+\tstruct rte_pktmbuf_pool_private *mbp_priv;\n+\tuint16_t buf_size;\n+\n+\tpkt_q->mb_pool = mb_pool;\n+\n+\t/* Now get the space available for data in the mbuf */\n+\tmbp_priv = rte_mempool_get_priv(pkt_q->mb_pool);\n+\tbuf_size = (uint16_t) (mbp_priv->mbuf_data_room_size -\n+\t                       RTE_PKTMBUF_HEADROOM);\n+\n+\tif (ETH_FRAME_LEN > buf_size) {\n+\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\"%s: %d bytes will not fit in mbuf (%d bytes)\\n\",\n+\t\t\tdev->data->name, ETH_FRAME_LEN, buf_size);\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\tdev->data->rx_queues[rx_queue_id] = pkt_q;\n+\n+\treturn 0;\n+}\n+\n+static int\n+eth_tx_queue_setup(struct rte_eth_dev *dev,\n+                   uint16_t tx_queue_id,\n+                   uint16_t nb_tx_desc __rte_unused,\n+                   unsigned int socket_id __rte_unused,\n+                   const struct rte_eth_txconf *tx_conf __rte_unused)\n+{\n+\n+\tstruct pmd_internals *internals = dev->data->dev_private;\n+\n+\tdev->data->tx_queues[tx_queue_id] = &internals->tx_queue[tx_queue_id];\n+\treturn 0;\n+}\n+\n+static struct eth_dev_ops ops = {\n+\t.dev_start = eth_dev_start,\n+\t.dev_stop = eth_dev_stop,\n+\t.dev_close = eth_dev_close,\n+\t.dev_configure = eth_dev_configure,\n+\t.dev_infos_get = eth_dev_info,\n+\t.rx_queue_setup = eth_rx_queue_setup,\n+\t.tx_queue_setup = eth_tx_queue_setup,\n+\t.rx_queue_release = eth_queue_release,\n+\t.tx_queue_release = eth_queue_release,\n+\t.link_update = eth_link_update,\n+\t.stats_get = eth_stats_get,\n+\t.stats_reset = eth_stats_reset,\n+};\n+\n+/*\n+ * Opens an AF_PACKET socket\n+ */\n+static int\n+open_packet_iface(const char *key __rte_unused,\n+                  const char *value __rte_unused,\n+                  void *extra_args)\n+{\n+\tint *sockfd = extra_args;\n+\n+\t/* Open an AF_PACKET socket... */\n+\t*sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));\n+\tif (*sockfd == -1) {\n+\t\tRTE_LOG(ERR, PMD, \"Could not open AF_PACKET socket\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n+rte_pmd_init_internals(const char *name,\n+                       const int sockfd,\n+                       const unsigned nb_queues,\n+                       unsigned int blocksize,\n+                       unsigned int blockcnt,\n+                       unsigned int framesize,\n+                       unsigned int framecnt,\n+                       const unsigned numa_node,\n+                       struct pmd_internals **internals,\n+                       struct rte_eth_dev **eth_dev,\n+                       struct rte_kvargs *kvlist)\n+{\n+\tstruct rte_eth_dev_data *data = NULL;\n+\tstruct rte_pci_device *pci_dev = NULL;\n+\tstruct rte_kvargs_pair *pair = NULL;\n+\tstruct ifreq ifr;\n+\tsize_t ifnamelen;\n+\tunsigned k_idx;\n+\tstruct sockaddr_ll sockaddr;\n+\tstruct tpacket_req *req;\n+\tstruct pkt_rx_queue *rx_queue;\n+\tstruct pkt_tx_queue *tx_queue;\n+\tint rc, tpver, discard, bypass;\n+\tunsigned int i, q, rdsize;\n+\tint qsockfd, fanout_arg;\n+\n+\tfor (k_idx = 0; k_idx < kvlist->count; k_idx++) {\n+\t\tpair = &kvlist->pairs[k_idx];\n+\t\tif (strstr(pair->key, ETH_PACKET_IFACE_ARG) != NULL)\n+\t\t\tbreak;\n+\t}\n+\tif (pair == NULL) {\n+\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\"%s: no interface specified for AF_PACKET ethdev\\n\",\n+\t\t        name);\n+\t\tgoto error;\n+\t}\n+\n+\tRTE_LOG(INFO, PMD,\n+\t\t\"%s: creating AF_PACKET-backed ethdev on numa socket %u\\n\",\n+\t\tname, numa_node);\n+\n+\t/*\n+\t * now do all data allocation - for eth_dev structure, dummy pci driver\n+\t * and internal (private) data\n+\t */\n+\tdata = rte_zmalloc_socket(name, sizeof(*data), 0, numa_node);\n+\tif (data == NULL)\n+\t\tgoto error;\n+\n+\tpci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, numa_node);\n+\tif (pci_dev == NULL)\n+\t\tgoto error;\n+\n+\t*internals = rte_zmalloc_socket(name, sizeof(**internals),\n+\t                                0, numa_node);\n+\tif (*internals == NULL)\n+\t\tgoto error;\n+\n+\treq = &((*internals)->req);\n+\n+\treq->tp_block_size = blocksize;\n+\treq->tp_block_nr = blockcnt;\n+\treq->tp_frame_size = framesize;\n+\treq->tp_frame_nr = framecnt;\n+\n+\tifnamelen = strlen(pair->value);\n+\tif (ifnamelen < sizeof(ifr.ifr_name)) {\n+\t\tmemcpy(ifr.ifr_name, pair->value, ifnamelen);\n+\t\tifr.ifr_name[ifnamelen] = '\\0';\n+\t} else {\n+\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\"%s: I/F name too long (%s)\\n\",\n+\t\t\tname, pair->value);\n+\t\tgoto error;\n+\t}\n+\tif (ioctl(sockfd, SIOCGIFINDEX, &ifr) == -1) {\n+\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\"%s: ioctl failed (SIOCGIFINDEX)\\n\",\n+\t\t        name);\n+\t\tgoto error;\n+\t}\n+\t(*internals)->if_index = ifr.ifr_ifindex;\n+\n+\tif (ioctl(sockfd, SIOCGIFHWADDR, &ifr) == -1) {\n+\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\"%s: ioctl failed (SIOCGIFHWADDR)\\n\",\n+\t\t        name);\n+\t\tgoto error;\n+\t}\n+\tmemcpy(&(*internals)->eth_addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);\n+\n+\tmemset(&sockaddr, 0, sizeof(sockaddr));\n+\tsockaddr.sll_family = AF_PACKET;\n+\tsockaddr.sll_protocol = htons(ETH_P_ALL);\n+\tsockaddr.sll_ifindex = (*internals)->if_index;\n+\n+\tfanout_arg = (getpid() ^ (*internals)->if_index) & 0xffff;\n+\tfanout_arg |= (PACKET_FANOUT_HASH | PACKET_FANOUT_FLAG_DEFRAG |\n+\t               PACKET_FANOUT_FLAG_ROLLOVER) << 16;\n+\n+\tfor (q = 0; q < nb_queues; q++) {\n+\t\t/* Open an AF_PACKET socket for this queue... */\n+\t\tqsockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));\n+\t\tif (qsockfd == -1) {\n+\t\t\tRTE_LOG(ERR, PMD,\n+\t\t\t        \"%s: could not open AF_PACKET socket\\n\",\n+\t\t\t        name);\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\ttpver = TPACKET_V2;\n+\t\trc = setsockopt(qsockfd, SOL_PACKET, PACKET_VERSION,\n+\t\t\t\t&tpver, sizeof(tpver));\n+\t\tif (rc == -1) {\n+\t\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\t\"%s: could not set PACKET_VERSION on AF_PACKET \"\n+\t\t\t\t\"socket for %s\\n\", name, pair->value);\n+\t\t\tgoto error;\n+\t\t}\n+\n+\t\tdiscard = 1;\n+\t\trc = setsockopt(qsockfd, SOL_PACKET, PACKET_LOSS,\n+\t\t\t\t&discard, sizeof(discard));\n+\t\tif (rc == -1) {\n+\t\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\t\"%s: could not set PACKET_LOSS on \"\n+\t\t\t        \"AF_PACKET socket for %s\\n\", name, pair->value);\n+\t\t\tgoto error;\n+\t\t}\n+\n+\t\tbypass = 1;\n+\t\trc = setsockopt(qsockfd, SOL_PACKET, PACKET_QDISC_BYPASS,\n+\t\t\t\t&bypass, sizeof(bypass));\n+\t\tif (rc == -1) {\n+\t\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\t\"%s: could not set PACKET_QDISC_BYPASS \"\n+\t\t\t        \"on AF_PACKET socket for %s\\n\", name,\n+\t\t\t        pair->value);\n+\t\t\tgoto error;\n+\t\t}\n+\n+\t\trc = setsockopt(qsockfd, SOL_PACKET, PACKET_RX_RING, req, sizeof(*req));\n+\t\tif (rc == -1) {\n+\t\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\t\"%s: could not set PACKET_RX_RING on AF_PACKET \"\n+\t\t\t\t\"socket for %s\\n\", name, pair->value);\n+\t\t\tgoto error;\n+\t\t}\n+\n+\t\trc = setsockopt(qsockfd, SOL_PACKET, PACKET_TX_RING, req, sizeof(*req));\n+\t\tif (rc == -1) {\n+\t\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\t\"%s: could not set PACKET_TX_RING on AF_PACKET \"\n+\t\t\t\t\"socket for %s\\n\", name, pair->value);\n+\t\t\tgoto error;\n+\t\t}\n+\n+\t\trx_queue = &((*internals)->rx_queue[q]);\n+\t\trx_queue->framecount = req->tp_frame_nr;\n+\n+\t\trx_queue->map = mmap(NULL, 2 * req->tp_block_size * req->tp_block_nr,\n+\t\t\t\t    PROT_READ | PROT_WRITE, MAP_SHARED | MAP_LOCKED,\n+\t\t\t\t    qsockfd, 0);\n+\t\tif (rx_queue->map == MAP_FAILED) {\n+\t\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\t\"%s: call to mmap failed on AF_PACKET socket for %s\\n\",\n+\t\t\t\tname, pair->value);\n+\t\t\tgoto error;\n+\t\t}\n+\n+\t\t/* rdsize is same for both Tx and Rx */\n+\t\trdsize = req->tp_frame_nr * sizeof(*(rx_queue->rd));\n+\n+\t\trx_queue->rd = rte_zmalloc_socket(name, rdsize, 0, numa_node);\n+\t\tfor (i = 0; i < req->tp_frame_nr; ++i) {\n+\t\t\trx_queue->rd[i].iov_base = rx_queue->map + (i * framesize);\n+\t\t\trx_queue->rd[i].iov_len = req->tp_frame_size;\n+\t\t}\n+\t\trx_queue->sockfd = qsockfd;\n+\n+\t\ttx_queue = &((*internals)->tx_queue[q]);\n+\t\ttx_queue->framecount = req->tp_frame_nr;\n+\n+\t\ttx_queue->map = rx_queue->map + req->tp_block_size * req->tp_block_nr;\n+\n+\t\ttx_queue->rd = rte_zmalloc_socket(name, rdsize, 0, numa_node);\n+\t\tfor (i = 0; i < req->tp_frame_nr; ++i) {\n+\t\t\ttx_queue->rd[i].iov_base = tx_queue->map + (i * framesize);\n+\t\t\ttx_queue->rd[i].iov_len = req->tp_frame_size;\n+\t\t}\n+\t\ttx_queue->sockfd = qsockfd;\n+\n+\t\trc = bind(qsockfd, (const struct sockaddr*)&sockaddr, sizeof(sockaddr));\n+\t\tif (rc == -1) {\n+\t\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\t\"%s: could not bind AF_PACKET socket to %s\\n\",\n+\t\t\t        name, pair->value);\n+\t\t\tgoto error;\n+\t\t}\n+\n+\t\trc = setsockopt(qsockfd, SOL_PACKET, PACKET_FANOUT,\n+\t\t\t\t&fanout_arg, sizeof(fanout_arg));\n+\t\tif (rc == -1) {\n+\t\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\t\"%s: could not set PACKET_FANOUT on AF_PACKET socket \"\n+\t\t\t\t\"for %s\\n\", name, pair->value);\n+\t\t\tgoto error;\n+\t\t}\n+\t}\n+\n+\t/* reserve an ethdev entry */\n+\t*eth_dev = rte_eth_dev_allocate(name);\n+\tif (*eth_dev == NULL)\n+\t\tgoto error;\n+\n+\t/*\n+\t * now put it all together\n+\t * - store queue data in internals,\n+\t * - store numa_node info in pci_driver\n+\t * - point eth_dev_data to internals and pci_driver\n+\t * - and point eth_dev structure to new eth_dev_data structure\n+\t */\n+\n+\t(*internals)->nb_queues = nb_queues;\n+\n+\tdata->dev_private = *internals;\n+\tdata->port_id = (*eth_dev)->data->port_id;\n+\tdata->nb_rx_queues = (uint16_t)nb_queues;\n+\tdata->nb_tx_queues = (uint16_t)nb_queues;\n+\tdata->dev_link = pmd_link;\n+\tdata->mac_addrs = &(*internals)->eth_addr;\n+\n+\tpci_dev->numa_node = numa_node;\n+\n+\t(*eth_dev)->data = data;\n+\t(*eth_dev)->dev_ops = &ops;\n+\t(*eth_dev)->pci_dev = pci_dev;\n+\n+\treturn 0;\n+\n+error:\n+\tif (data)\n+\t\trte_free(data);\n+\tif (pci_dev)\n+\t\trte_free(pci_dev);\n+\tfor (q = 0; q < nb_queues; q++) {\n+\t\tif ((*internals)->rx_queue[q].rd)\n+\t\t\trte_free((*internals)->rx_queue[q].rd);\n+\t\tif ((*internals)->tx_queue[q].rd)\n+\t\t\trte_free((*internals)->tx_queue[q].rd);\n+\t}\n+\tif (*internals)\n+\t\trte_free(*internals);\n+\treturn -1;\n+}\n+\n+static int\n+rte_eth_from_packet(const char *name,\n+                    int const *sockfd,\n+                    const unsigned numa_node,\n+                    struct rte_kvargs *kvlist)\n+{\n+\tstruct pmd_internals *internals = NULL;\n+\tstruct rte_eth_dev *eth_dev = NULL;\n+\tstruct rte_kvargs_pair *pair = NULL;\n+\tunsigned k_idx;\n+\tunsigned int blockcount;\n+\tunsigned int blocksize = DFLT_BLOCK_SIZE;\n+\tunsigned int framesize = DFLT_FRAME_SIZE;\n+\tunsigned int framecount = DFLT_FRAME_COUNT;\n+\tunsigned int qpairs = 1;\n+\n+\t/* do some parameter checking */\n+\tif (*sockfd < 0)\n+\t\treturn -1;\n+\n+\t/*\n+\t * Walk arguments for configurable settings\n+\t */\n+\tfor (k_idx = 0; k_idx < kvlist->count; k_idx++) {\n+\t\tpair = &kvlist->pairs[k_idx];\n+\t\tif (strstr(pair->key, ETH_PACKET_NUM_Q_ARG) != NULL) {\n+\t\t\tqpairs = atoi(pair->value);\n+\t\t\tif (qpairs < 1 ||\n+\t\t\t    qpairs > RTE_PMD_PACKET_MAX_RINGS) {\n+\t\t\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\t\t\"%s: invalid qpairs value\\n\",\n+\t\t\t\t        name);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tcontinue;\n+\t\t}\n+\t\tif (strstr(pair->key, ETH_PACKET_BLOCKSIZE_ARG) != NULL) {\n+\t\t\tblocksize = atoi(pair->value);\n+\t\t\tif (!blocksize) {\n+\t\t\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\t\t\"%s: invalid blocksize value\\n\",\n+\t\t\t\t        name);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tcontinue;\n+\t\t}\n+\t\tif (strstr(pair->key, ETH_PACKET_FRAMESIZE_ARG) != NULL) {\n+\t\t\tframesize = atoi(pair->value);\n+\t\t\tif (!framesize) {\n+\t\t\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\t\t\"%s: invalid framesize value\\n\",\n+\t\t\t\t        name);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tcontinue;\n+\t\t}\n+\t\tif (strstr(pair->key, ETH_PACKET_FRAMECOUNT_ARG) != NULL) {\n+\t\t\tframecount = atoi(pair->value);\n+\t\t\tif (!framecount) {\n+\t\t\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\t\t\"%s: invalid framecount value\\n\",\n+\t\t\t\t        name);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tcontinue;\n+\t\t}\n+\t}\n+\n+\tif (framesize > blocksize) {\n+\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\"%s: AF_PACKET MMAP frame size exceeds block size!\\n\",\n+\t\t        name);\n+\t\treturn -1;\n+\t}\n+\n+\tblockcount = framecount / (blocksize / framesize);\n+\tif (!blockcount) {\n+\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\"%s: invalid AF_PACKET MMAP parameters\\n\", name);\n+\t\treturn -1;\n+\t}\n+\n+\tRTE_LOG(INFO, PMD, \"%s: AF_PACKET MMAP parameters:\\n\", name);\n+\tRTE_LOG(INFO, PMD, \"%s:\\tblock size %d\\n\", name, blocksize);\n+\tRTE_LOG(INFO, PMD, \"%s:\\tblock count %d\\n\", name, blockcount);\n+\tRTE_LOG(INFO, PMD, \"%s:\\tframe size %d\\n\", name, framesize);\n+\tRTE_LOG(INFO, PMD, \"%s:\\tframe count %d\\n\", name, framecount);\n+\n+\tif (rte_pmd_init_internals(name, *sockfd, qpairs,\n+\t                           blocksize, blockcount,\n+\t                           framesize, framecount,\n+\t                           numa_node, &internals, &eth_dev,\n+\t                           kvlist) < 0)\n+\t\treturn -1;\n+\n+\teth_dev->rx_pkt_burst = eth_packet_rx;\n+\teth_dev->tx_pkt_burst = eth_packet_tx;\n+\n+\treturn 0;\n+}\n+\n+int\n+rte_pmd_packet_devinit(const char *name, const char *params)\n+{\n+\tunsigned numa_node;\n+\tint ret;\n+\tstruct rte_kvargs *kvlist;\n+\tint sockfd = -1;\n+\n+\tRTE_LOG(INFO, PMD, \"Initializing pmd_packet for %s\\n\", name);\n+\n+\tnuma_node = rte_socket_id();\n+\n+\tkvlist = rte_kvargs_parse(params, valid_arguments);\n+\tif (kvlist == NULL)\n+\t\treturn -1;\n+\n+\t/*\n+\t * If iface argument is passed we open the NICs and use them for\n+\t * reading / writing\n+\t */\n+\tif (rte_kvargs_count(kvlist, ETH_PACKET_IFACE_ARG) == 1) {\n+\n+\t\tret = rte_kvargs_process(kvlist, ETH_PACKET_IFACE_ARG,\n+\t\t                         &open_packet_iface, &sockfd);\n+\t\tif (ret < 0)\n+\t\t\treturn -1;\n+\t}\n+\n+\tret = rte_eth_from_packet(name, &sockfd, numa_node, kvlist);\n+\tclose(sockfd); /* no longer needed */\n+\n+\tif (ret < 0)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+static struct rte_driver pmd_packet_drv = {\n+\t.name = \"eth_packet\",\n+\t.type = PMD_VDEV,\n+\t.init = rte_pmd_packet_devinit,\n+};\n+\n+PMD_REGISTER_DRIVER(pmd_packet_drv);\ndiff --git a/lib/librte_pmd_packet/rte_eth_packet.h b/lib/librte_pmd_packet/rte_eth_packet.h\nnew file mode 100644\nindex 000000000000..f685611da3e9\n--- /dev/null\n+++ b/lib/librte_pmd_packet/rte_eth_packet.h\n@@ -0,0 +1,55 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ *   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+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#ifndef _RTE_ETH_PACKET_H_\n+#define _RTE_ETH_PACKET_H_\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+#define RTE_ETH_PACKET_PARAM_NAME \"eth_packet\"\n+\n+#define RTE_PMD_PACKET_MAX_RINGS 16\n+\n+/**\n+ * For use by the EAL only. Called as part of EAL init to set up any dummy NICs\n+ * configured on command line.\n+ */\n+int rte_pmd_packet_devinit(const char *name, const char *params);\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif\ndiff --git a/mk/rte.app.mk b/mk/rte.app.mk\nindex 34dff2a02a05..a6994c4dbe93 100644\n--- a/mk/rte.app.mk\n+++ b/mk/rte.app.mk\n@@ -210,6 +210,10 @@ ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y)\n LDLIBS += -lrte_pmd_pcap -lpcap\n endif\n \n+ifeq ($(CONFIG_RTE_LIBRTE_PMD_PACKET),y)\n+LDLIBS += -lrte_pmd_packet\n+endif\n+\n endif # plugins\n \n LDLIBS += $(EXECENV_LDLIBS)\n",
    "prefixes": [
        "dpdk-dev",
        "v2"
    ]
}