Show a patch.

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

{
    "id": 431,
    "url": "https://patches.dpdk.org/api/patches/431/?format=api",
    "web_url": "https://patches.dpdk.org/patch/431/",
    "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"
    },
    "msgid": "<1411129659-7132-2-git-send-email-mukawa@igel.co.jp>",
    "date": "2014-09-19T12:27:39",
    "name": "[dpdk-dev,RFC] librte_pmd_null: Add null PMD",
    "commit_ref": null,
    "pull_url": null,
    "state": "rfc",
    "archived": true,
    "hash": "f6de9897dbf62f95fe8de9866515beb89a9c723d",
    "submitter": {
        "id": 64,
        "url": "https://patches.dpdk.org/api/people/64/?format=api",
        "name": "Tetsuya Mukawa",
        "email": "mukawa@igel.co.jp"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/patch/431/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/431/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/431/checks/",
    "tags": {},
    "headers": {
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "Message-Id": "<1411129659-7132-2-git-send-email-mukawa@igel.co.jp>",
        "X-Mailer": "git-send-email 1.9.1",
        "X-Gm-Message-State": "ALoCoQnFTB1SQIriZW27s9Mx1uQCEbbmhhJlm46yv1m3GQv5dy0d0qTBS035SR7YiMGfH4eUTbOv",
        "To": "dev@dpdk.org",
        "Cc": "nakajima.yoshihiro@lab.ntt.co.jp, masutani.hitoshi@lab.ntt.co.jp",
        "X-BeenThere": "dev@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id A2740B3B0;\n\tFri, 19 Sep 2014 14:23:06 +0200 (CEST)",
            "from mail-pd0-f177.google.com (mail-pd0-f177.google.com\n\t[209.85.192.177]) by dpdk.org (Postfix) with ESMTP id 31F2AB3AE\n\tfor <dev@dpdk.org>; Fri, 19 Sep 2014 14:23:03 +0200 (CEST)",
            "by mail-pd0-f177.google.com with SMTP id y10so2469036pdj.8\n\tfor <dev@dpdk.org>; Fri, 19 Sep 2014 05:28:52 -0700 (PDT)",
            "from localhost.localdomain (napt.igel.co.jp. [219.106.231.132])\n\tby mx.google.com with ESMTPSA id\n\tkl3sm1756482pdb.87.2014.09.19.05.28.50 for <multiple recipients>\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tFri, 19 Sep 2014 05:28:51 -0700 (PDT)"
        ],
        "Subject": "[dpdk-dev] [RFC] librte_pmd_null: Add null PMD",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "In-Reply-To": "<1411129659-7132-1-git-send-email-mukawa@igel.co.jp>",
        "Precedence": "list",
        "From": "mukawa@igel.co.jp",
        "X-Received": "by 10.69.27.71 with SMTP id je7mr12558455pbd.155.1411129732144; \n\tFri, 19 Sep 2014 05:28:52 -0700 (PDT)",
        "References": "<mukawa@igel.co.jp>\n\t<1411129659-7132-1-git-send-email-mukawa@igel.co.jp>",
        "X-Original-To": "patchwork@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "Errors-To": "dev-bounces@dpdk.org",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "Delivered-To": "patchwork@dpdk.org",
        "Date": "Fri, 19 Sep 2014 21:27:39 +0900",
        "X-Mailman-Version": "2.1.15",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20130820;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=XxCYHrtIYUGUmy/G0uQkfO1sJDqmgwNr0Qvyyhh0jIo=;\n\tb=hS+hXXU5ft1onCZWtvU3Gs9ygPnGtU++ZfE9W73/gnt+yE4z7TxE8L0R2qlyvlHnGx\n\t0ziO3wcoWN3LPawm7GbCsSkaUqC3j6xLh9SjXU8dIK3s3SdXejMrPbLWkn0uNeiCI+kE\n\tpqlDZhjPUcc7AnECIT4/lYM8F6/LPARcty47QSQXSlCSHf1i8D7LlsEa34onWXWXW/Vq\n\tRwmtgUJ799OCyPAEyivSUKr+IgXHCePcbmZDTUNf63K6+B7SOWPxlcOv7dX8yHOtJ3QJ\n\tcr+UuG4E9dakBrwtLvaHVYByKr8cHXyPZA7urBFoQNUmQ/WLdn5B9UlAlcjXQapr2MH2\n\tU4dg==",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>"
    },
    "content": "From: Tetsuya Mukawa <mukawa@igel.co.jp>\n\n'null PMD' is a virtual device driver particulary designed to measure\nperformance of DPDK applications and DPDK PMDs. When an application call rx,\nnull PMD just allocate mbufs and return those. Also tx, the PMD just free\nmbufs.\n\nThe PMD has following options.\n- size: specify packe size allocated by RX. Default packet size is 64.\n- copy: specify 1 or 0 to enable or disable copy while RX and TX.\n\tDefault value is 0(disbaled).\n\tThis option is used for emulating more realistic data transfer.\n\tCopy size is equal to packet size.\n\nSigned-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>\n---\n config/common_bsdapp               |   5 +\n config/common_linuxapp             |   5 +\n lib/Makefile                       |   1 +\n lib/librte_pmd_null/Makefile       |  58 +++++\n lib/librte_pmd_null/rte_eth_null.c | 474 +++++++++++++++++++++++++++++++++++++\n 5 files changed, 543 insertions(+)\n create mode 100644 lib/librte_pmd_null/Makefile\n create mode 100644 lib/librte_pmd_null/rte_eth_null.c",
    "diff": "diff --git a/config/common_bsdapp b/config/common_bsdapp\nindex 645949f..a86321f 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 null PMD\n+#\n+CONFIG_RTE_LIBRTE_PMD_NULL=y\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 5bee910..e3bd8c0 100644\n--- a/config/common_linuxapp\n+++ b/config/common_linuxapp\n@@ -254,6 +254,11 @@ CONFIG_RTE_LIBRTE_PMD_BOND=y\n CONFIG_RTE_LIBRTE_PMD_XENVIRT=n\n \n #\n+# Compile null PMD\n+#\n+CONFIG_RTE_LIBRTE_PMD_NULL=y\n+\n+#\n # Do prefetch of packet data within PMD driver receive function\n #\n CONFIG_RTE_PMD_PACKET_PREFETCH=y\ndiff --git a/lib/Makefile b/lib/Makefile\nindex 10c5bb3..61d6ed1 100644\n--- a/lib/Makefile\n+++ b/lib/Makefile\n@@ -50,6 +50,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += librte_pmd_pcap\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\n+DIRS-$(CONFIG_RTE_LIBRTE_PMD_NULL) += librte_pmd_null\n DIRS-$(CONFIG_RTE_LIBRTE_HASH) += librte_hash\n DIRS-$(CONFIG_RTE_LIBRTE_LPM) += librte_lpm\n DIRS-$(CONFIG_RTE_LIBRTE_ACL) += librte_acl\ndiff --git a/lib/librte_pmd_null/Makefile b/lib/librte_pmd_null/Makefile\nnew file mode 100644\nindex 0000000..e017918\n--- /dev/null\n+++ b/lib/librte_pmd_null/Makefile\n@@ -0,0 +1,58 @@\n+#   BSD LICENSE\n+#\n+#   Copyright (C) 2014 Nippon Telegraph and Telephone Corporation.\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_null.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_NULL) += rte_eth_null.c\n+\n+#\n+# Export include files\n+#\n+SYMLINK-y-include +=\n+\n+# this lib depends upon:\n+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_NULL) += lib/librte_mbuf\n+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_NULL) += lib/librte_ether\n+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_NULL) += lib/librte_malloc\n+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_NULL) += lib/librte_kvargs\n+\n+include $(RTE_SDK)/mk/rte.lib.mk\ndiff --git a/lib/librte_pmd_null/rte_eth_null.c b/lib/librte_pmd_null/rte_eth_null.c\nnew file mode 100644\nindex 0000000..1a81843\n--- /dev/null\n+++ b/lib/librte_pmd_null/rte_eth_null.c\n@@ -0,0 +1,474 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright (C) 2014 Nippon Telegraph and Telephone Corporation.\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_memcpy.h>\n+#include <rte_dev.h>\n+#include <rte_kvargs.h>\n+\n+#define ETH_NULL_PACKET_SIZE_ARG\t\"size\"\n+#define ETH_NULL_PACKET_COPY_ARG\t\"copy\"\n+\n+static unsigned default_packet_size = 64;\n+static unsigned default_packet_copy;\n+\n+static const char const *valid_arguments[] = {\n+\tETH_NULL_PACKET_SIZE_ARG,\n+\tETH_NULL_PACKET_COPY_ARG,\n+\tNULL\n+};\n+\n+struct pmd_internals;\n+\n+struct null_queue {\n+\tstruct pmd_internals *internals;\n+\n+\tstruct rte_mempool *mb_pool;\n+\tstruct rte_mbuf *dummy_packet;\n+\n+\trte_atomic64_t rx_pkts;\n+\trte_atomic64_t tx_pkts;\n+\trte_atomic64_t err_pkts;\n+};\n+\n+struct pmd_internals {\n+\tunsigned packet_size;\n+\tunsigned packet_copy;\n+\tunsigned numa_node;\n+\n+\tunsigned nb_rx_queues;\n+\tunsigned nb_tx_queues;\n+\n+\tstruct null_queue rx_null_queues[1];\n+\tstruct null_queue tx_null_queues[1];\n+};\n+\n+\n+static struct ether_addr eth_addr = { .addr_bytes = {0} };\n+static const char *drivername = \"Null PMD\";\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_null_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)\n+{\n+\tint i;\n+\tstruct null_queue *h = q;\n+\tunsigned packet_size = h->internals->packet_size;\n+\n+\tfor (i = 0; i < nb_bufs; i++) {\n+\t\tbufs[i] = rte_pktmbuf_alloc(h->mb_pool);\n+\t\tif (!bufs[i])\n+\t\t\tbreak;\n+\t\tbufs[i]->data_len = (uint16_t)packet_size;\n+\t\tbufs[i]->pkt_len = packet_size;\n+\t\tbufs[i]->nb_segs = 1;\n+\t\tbufs[i]->next = NULL;\n+\t}\n+\n+\trte_atomic64_add(&(h->rx_pkts), i);\n+\n+\treturn i;\n+}\n+\n+static uint16_t\n+eth_null_copy_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)\n+{\n+\tint i;\n+\tstruct null_queue *h = q;\n+\tunsigned packet_size = h->internals->packet_size;\n+\n+\tfor (i = 0; i < nb_bufs; i++) {\n+\t\tbufs[i] = rte_pktmbuf_alloc(h->mb_pool);\n+\t\tif (!bufs[i])\n+\t\t\tbreak;\n+\t\trte_memcpy(rte_pktmbuf_mtod(bufs[i], void *), h->dummy_packet,\n+\t\t\t\t\tpacket_size);\n+\t\tbufs[i]->data_len = (uint16_t)packet_size;\n+\t\tbufs[i]->pkt_len = packet_size;\n+\t\tbufs[i]->nb_segs = 1;\n+\t\tbufs[i]->next = NULL;\n+\t}\n+\n+\trte_atomic64_add(&(h->rx_pkts), i);\n+\n+\treturn i;\n+}\n+\n+static uint16_t\n+eth_null_tx(void *q, struct rte_mbuf **bufs __rte_unused, uint16_t nb_bufs)\n+{\n+\tint i;\n+\tstruct null_queue *h = q;\n+\n+\tfor (i = 0; i < nb_bufs; i++)\n+\t\trte_pktmbuf_free(bufs[i]);\n+\n+\trte_atomic64_add(&(h->tx_pkts), i);\n+\n+\treturn i;\n+}\n+\n+static uint16_t\n+eth_null_copy_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)\n+{\n+\tint i;\n+\tstruct null_queue *h = q;\n+\tunsigned packet_size = h->internals->packet_size;\n+\n+\tfor (i = 0; i < nb_bufs; i++) {\n+\t\trte_memcpy(h->dummy_packet, rte_pktmbuf_mtod(bufs[i], void *),\n+\t\t\t\t\tpacket_size);\n+\t\trte_pktmbuf_free(bufs[i]);\n+\t}\n+\n+\trte_atomic64_add(&(h->tx_pkts), i);\n+\n+\treturn i;\n+}\n+\n+static int\n+eth_dev_configure(struct rte_eth_dev *dev __rte_unused) { return 0; }\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+static void\n+eth_dev_stop(struct rte_eth_dev *dev)\n+{\n+\tdev->data->dev_link.link_status = 0;\n+}\n+\n+static int\n+eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,\n+\t\tuint16_t nb_rx_desc __rte_unused,\n+\t\tunsigned int socket_id __rte_unused,\n+\t\tconst struct rte_eth_rxconf *rx_conf __rte_unused,\n+\t\tstruct rte_mempool *mb_pool __rte_unused)\n+{\n+\tstruct rte_mbuf *dummy_packet;\n+\tstruct pmd_internals *internals = dev->data->dev_private;\n+\tunsigned packet_size = internals->packet_size;\n+\n+\tif (rx_queue_id != 0)\n+\t\t\treturn -ENODEV;\n+\n+\tinternals->rx_null_queues[rx_queue_id].mb_pool = mb_pool;\n+\tdev->data->rx_queues[rx_queue_id] =\n+\t\t&internals->rx_null_queues[rx_queue_id];\n+\tdummy_packet = rte_zmalloc_socket(NULL,\n+\t\t\tpacket_size, 0, internals->numa_node);\n+\tif (dummy_packet == NULL)\n+\t\treturn -ENOMEM;\n+\n+\tinternals->rx_null_queues[rx_queue_id].internals = internals;\n+\tinternals->rx_null_queues[rx_queue_id].dummy_packet = dummy_packet;\n+\n+\treturn 0;\n+}\n+\n+static int\n+eth_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,\n+\t\tuint16_t nb_tx_desc __rte_unused,\n+\t\tunsigned int socket_id __rte_unused,\n+\t\tconst struct rte_eth_txconf *tx_conf __rte_unused)\n+{\n+\tstruct rte_mbuf *dummy_packet;\n+\tstruct pmd_internals *internals = dev->data->dev_private;\n+\tunsigned packet_size = internals->packet_size;\n+\n+\tif (tx_queue_id != 0)\n+\t\t\treturn -ENODEV;\n+\n+\tdev->data->tx_queues[tx_queue_id] =\n+\t\t&internals->tx_null_queues[tx_queue_id];\n+\tdummy_packet = rte_zmalloc_socket(NULL,\n+\t\t\tpacket_size, 0, internals->numa_node);\n+\tif (dummy_packet == NULL)\n+\t\treturn -ENOMEM;\n+\n+\tinternals->tx_null_queues[tx_queue_id].internals = internals;\n+\tinternals->tx_null_queues[tx_queue_id].dummy_packet = dummy_packet;\n+\n+\treturn 0;\n+}\n+\n+\n+static void\n+eth_dev_info(struct rte_eth_dev *dev,\n+\t\tstruct 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->max_mac_addrs = 1;\n+\tdev_info->max_rx_pktlen = (uint32_t)-1;\n+\tdev_info->max_rx_queues = (uint16_t)internals->nb_rx_queues;\n+\tdev_info->max_tx_queues = (uint16_t)internals->nb_tx_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;\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+\tfor (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&\n+\t\t\ti < internal->nb_rx_queues; i++) {\n+\t\tigb_stats->q_ipackets[i] =\n+\t\t\tinternal->rx_null_queues[i].rx_pkts.cnt;\n+\t\trx_total += igb_stats->q_ipackets[i];\n+\t}\n+\n+\tfor (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&\n+\t\t\ti < internal->nb_tx_queues; i++) {\n+\t\tigb_stats->q_opackets[i] =\n+\t\t\tinternal->tx_null_queues[i].tx_pkts.cnt;\n+\t\tigb_stats->q_errors[i] =\n+\t\t\tinternal->tx_null_queues[i].err_pkts.cnt;\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_rx_queues; i++)\n+\t\tinternal->rx_null_queues[i].rx_pkts.cnt = 0;\n+\tfor (i = 0; i < internal->nb_tx_queues; i++) {\n+\t\tinternal->tx_null_queues[i].tx_pkts.cnt = 0;\n+\t\tinternal->tx_null_queues[i].err_pkts.cnt = 0;\n+\t}\n+}\n+\n+static void\n+eth_queue_release(void *q __rte_unused) { ; }\n+static int\n+eth_link_update(struct rte_eth_dev *dev __rte_unused,\n+\t\tint wait_to_complete __rte_unused) { return 0; }\n+\n+static struct eth_dev_ops ops = {\n+\t\t.dev_start = eth_dev_start,\n+\t\t.dev_stop = eth_dev_stop,\n+\t\t.dev_configure = eth_dev_configure,\n+\t\t.dev_infos_get = eth_dev_info,\n+\t\t.rx_queue_setup = eth_rx_queue_setup,\n+\t\t.tx_queue_setup = eth_tx_queue_setup,\n+\t\t.rx_queue_release = eth_queue_release,\n+\t\t.tx_queue_release = eth_queue_release,\n+\t\t.link_update = eth_link_update,\n+\t\t.stats_get = eth_stats_get,\n+\t\t.stats_reset = eth_stats_reset,\n+};\n+\n+static int\n+eth_dev_null_create(const char *name __rte_unused,\n+\t\tconst unsigned numa_node,\n+\t\tunsigned packet_size,\n+\t\tunsigned packet_copy)\n+{\n+\tconst unsigned nb_rx_queues = 1;\n+\tconst unsigned nb_tx_queues = 1;\n+\tstruct rte_eth_dev_data *data = NULL;\n+\tstruct rte_pci_device *pci_dev = NULL;\n+\tstruct pmd_internals *internals = NULL;\n+\tstruct rte_eth_dev *eth_dev = NULL;\n+\n+\tRTE_LOG(INFO, PMD, \"Creating null ethdev on numa socket %u\\n\",\n+\t\t\tnuma_node);\n+\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+\tinternals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node);\n+\tif (internals == NULL)\n+\t\tgoto error;\n+\n+\t/* reserve an ethdev entry */\n+\teth_dev = rte_eth_dev_allocate(name);\n+\tif (eth_dev == NULL)\n+\t\tgoto error;\n+\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+\t/* NOTE: we'll replace the data element, of originally allocated eth_dev\n+\t * so the nulls are local per-process */\n+\n+\tinternals->nb_rx_queues = nb_rx_queues;\n+\tinternals->nb_tx_queues = nb_tx_queues;\n+\tinternals->packet_size = packet_size;\n+\tinternals->packet_copy = packet_copy;\n+\tinternals->numa_node = numa_node;\n+\n+\tpci_dev->numa_node = numa_node;\n+\n+\tdata->dev_private = internals;\n+\tdata->port_id = eth_dev->data->port_id;\n+\tdata->nb_rx_queues = (uint16_t)nb_rx_queues;\n+\tdata->nb_tx_queues = (uint16_t)nb_tx_queues;\n+\tdata->dev_link = pmd_link;\n+\tdata->mac_addrs = &eth_addr;\n+\n+\teth_dev->data = data;\n+\teth_dev->dev_ops = &ops;\n+\teth_dev->pci_dev = pci_dev;\n+\n+\t/* finally assign rx and tx ops */\n+\tif (packet_copy) {\n+\t\teth_dev->rx_pkt_burst = eth_null_copy_rx;\n+\t\teth_dev->tx_pkt_burst = eth_null_copy_tx;\n+\t} else {\n+\t\teth_dev->rx_pkt_burst = eth_null_rx;\n+\t\teth_dev->tx_pkt_burst = eth_null_tx;\n+\t}\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+\tif (internals)\n+\t\trte_free(internals);\n+\treturn -1;\n+}\n+\n+static inline int\n+get_packet_size_arg(const char *key __rte_unused,\n+\t\tconst char *value, void *extra_args)\n+{\n+\tconst char *a = value;\n+\tunsigned *packet_size = extra_args;\n+\n+\t*packet_size = (unsigned)strtoul(a, NULL, 0);\n+\tif (*packet_size == UINT_MAX)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+static inline int\n+get_packet_copy_arg(const char *key __rte_unused,\n+\t\tconst char *value, void *extra_args)\n+{\n+\tconst char *a = value;\n+\tunsigned *packet_copy = extra_args;\n+\n+\t*packet_copy = (unsigned)strtoul(a, NULL, 0);\n+\tif (*packet_copy == UINT_MAX)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+static int\n+rte_pmd_null_devinit(const char *name, const char *params)\n+{\n+\tunsigned numa_node;\n+\tunsigned packet_size = default_packet_size;\n+\tunsigned packet_copy = default_packet_copy;\n+\tstruct rte_kvargs *kvlist;\n+\tint ret;\n+\n+\tRTE_LOG(INFO, PMD, \"Initializing pmd_null 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+\tif (rte_kvargs_count(kvlist, ETH_NULL_PACKET_SIZE_ARG) == 1) {\n+\n+\t\tret = rte_kvargs_process(kvlist, ETH_NULL_PACKET_SIZE_ARG,\n+\t\t\t\t&get_packet_size_arg, &packet_size);\n+\t\tif (ret < 0)\n+\t\t\treturn -1;\n+\t}\n+\n+\tif (rte_kvargs_count(kvlist, ETH_NULL_PACKET_COPY_ARG) == 1) {\n+\n+\t\tret = rte_kvargs_process(kvlist, ETH_NULL_PACKET_COPY_ARG,\n+\t\t\t\t&get_packet_copy_arg, &packet_copy);\n+\t\tif (ret < 0)\n+\t\t\treturn -1;\n+\t}\n+\n+\tRTE_LOG(INFO, PMD, \"Configure pmd_null: packet size is %d, \"\n+\t\t\t\"packet copy is %s\\n\", packet_size,\n+\t\t\tpacket_copy ? \"enabled\" : \"disabled\");\n+\n+\treturn eth_dev_null_create(name, numa_node, packet_size, packet_copy);\n+}\n+\n+static struct rte_driver pmd_null_drv = {\n+\t.name = \"eth_null\",\n+\t.type = PMD_VDEV,\n+\t.init = rte_pmd_null_devinit,\n+};\n+\n+PMD_REGISTER_DRIVER(pmd_null_drv);\n",
    "prefixes": [
        "dpdk-dev",
        "RFC"
    ]
}