get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 15146,
    "url": "https://patches.dpdk.org/api/patches/15146/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1470432064-59047-1-git-send-email-jasvinder.singh@intel.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": "<1470432064-59047-1-git-send-email-jasvinder.singh@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1470432064-59047-1-git-send-email-jasvinder.singh@intel.com",
    "date": "2016-08-05T21:21:04",
    "name": "[dpdk-dev,1/3] lib/librte_port: enable file descriptor port support",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "0e3972b295c1c97cca94e8f38ee8c582b524f832",
    "submitter": {
        "id": 285,
        "url": "https://patches.dpdk.org/api/people/285/?format=api",
        "name": "Jasvinder Singh",
        "email": "jasvinder.singh@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1470432064-59047-1-git-send-email-jasvinder.singh@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/15146/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/15146/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 B2D2E2BD3;\n\tFri,  5 Aug 2016 23:13:58 +0200 (CEST)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby dpdk.org (Postfix) with ESMTP id 6D9C92B9A\n\tfor <dev@dpdk.org>; Fri,  5 Aug 2016 23:13:56 +0200 (CEST)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby fmsmga102.fm.intel.com with ESMTP; 05 Aug 2016 14:13:56 -0700",
            "from sie-lab-212-251.ir.intel.com (HELO\n\tsilpixa00381635.ir.intel.com) ([10.237.212.251])\n\tby fmsmga001.fm.intel.com with ESMTP; 05 Aug 2016 14:13:54 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos; i=\"5.28,474,1464678000\"; d=\"scan'208\";\n\ta=\"1020486630\"",
        "From": "Jasvinder Singh <jasvinder.singh@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "cristian.dumitrescu@intel.com",
        "Date": "Fri,  5 Aug 2016 22:21:04 +0100",
        "Message-Id": "<1470432064-59047-1-git-send-email-jasvinder.singh@intel.com>",
        "X-Mailer": "git-send-email 2.5.5",
        "Subject": "[dpdk-dev] [PATCH 1/3] lib/librte_port: enable file descriptor port\n\tsupport",
        "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": "This patch adds File Descriptor(FD) port type (e.g. TAP port) to the\npacket framework library that allows interface with the kernel network\nstack. The FD port APIs are defined that allow port creation, writing\nand reading packet from the kernel interface.\n\nSigned-off-by: Jasvinder Singh <jasvinder.singh@intel.com>\nAcked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>\n---\n lib/librte_port/Makefile             |   2 +\n lib/librte_port/rte_port_fd.c        | 548 +++++++++++++++++++++++++++++++++++\n lib/librte_port/rte_port_fd.h        | 103 +++++++\n lib/librte_port/rte_port_version.map |   9 +\n 4 files changed, 662 insertions(+)\n create mode 100644 lib/librte_port/rte_port_fd.c\n create mode 100644 lib/librte_port/rte_port_fd.h\n\n\\ No newline at end of file",
    "diff": "diff --git a/lib/librte_port/Makefile b/lib/librte_port/Makefile\nindex 3d84a0e..44fa735 100644\n--- a/lib/librte_port/Makefile\n+++ b/lib/librte_port/Makefile\n@@ -56,6 +56,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PORT) += rte_port_frag.c\n SRCS-$(CONFIG_RTE_LIBRTE_PORT) += rte_port_ras.c\n endif\n SRCS-$(CONFIG_RTE_LIBRTE_PORT) += rte_port_sched.c\n+SRCS-$(CONFIG_RTE_LIBRTE_PORT) += rte_port_fd.c\n ifeq ($(CONFIG_RTE_LIBRTE_KNI),y)\n SRCS-$(CONFIG_RTE_LIBRTE_PORT) += rte_port_kni.c\n endif\n@@ -70,6 +71,7 @@ SYMLINK-$(CONFIG_RTE_LIBRTE_PORT)-include += rte_port_frag.h\n SYMLINK-$(CONFIG_RTE_LIBRTE_PORT)-include += rte_port_ras.h\n endif\n SYMLINK-$(CONFIG_RTE_LIBRTE_PORT)-include += rte_port_sched.h\n+SYMLINK-$(CONFIG_RTE_LIBRTE_PORT)-include += rte_port_fd.h\n ifeq ($(CONFIG_RTE_LIBRTE_KNI),y)\n SYMLINK-$(CONFIG_RTE_LIBRTE_PORT)-include += rte_port_kni.h\n endif\ndiff --git a/lib/librte_port/rte_port_fd.c b/lib/librte_port/rte_port_fd.c\nnew file mode 100644\nindex 0000000..c75b602\n--- /dev/null\n+++ b/lib/librte_port/rte_port_fd.c\n@@ -0,0 +1,548 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2016 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+#include <string.h>\n+#include <stdint.h>\n+#include <unistd.h>\n+\n+#include <rte_mbuf.h>\n+#include <rte_malloc.h>\n+\n+#include \"rte_port_fd.h\"\n+\n+/*\n+ * Port FD Reader\n+ */\n+#ifdef RTE_PORT_STATS_COLLECT\n+\n+#define RTE_PORT_FD_READER_STATS_PKTS_IN_ADD(port, val) \\\n+\tport->stats.n_pkts_in += val\n+#define RTE_PORT_FD_READER_STATS_PKTS_DROP_ADD(port, val) \\\n+\tport->stats.n_pkts_drop += val\n+\n+#else\n+\n+#define RTE_PORT_FD_READER_STATS_PKTS_IN_ADD(port, val)\n+#define RTE_PORT_FD_READER_STATS_PKTS_DROP_ADD(port, val)\n+\n+#endif\n+\n+struct rte_port_fd_reader {\n+\tstruct rte_port_in_stats stats;\n+\tint fd;\n+\tuint32_t mtu;\n+\tstruct rte_mempool *mempool;\n+};\n+\n+static void *\n+rte_port_fd_reader_create(void *params, int socket_id)\n+{\n+\tstruct rte_port_fd_reader_params *conf =\n+\t\t\t(struct rte_port_fd_reader_params *) params;\n+\tstruct rte_port_fd_reader *port;\n+\n+\t/* Check input parameters */\n+\tif (conf == NULL) {\n+\t\tRTE_LOG(ERR, PORT, \"%s: params is NULL\\n\", __func__);\n+\t\treturn NULL;\n+\t}\n+\tif (conf->fd < 0) {\n+\t\tRTE_LOG(ERR, PORT, \"%s: Invalid file descriptor\\n\", __func__);\n+\t\treturn NULL;\n+\t}\n+\tif (conf->mtu == 0) {\n+\t\tRTE_LOG(ERR, PORT, \"%s: Invalid MTU\\n\", __func__);\n+\t\treturn NULL;\n+\t}\n+\tif (conf->mempool == NULL) {\n+\t\tRTE_LOG(ERR, PORT, \"%s: Invalid mempool\\n\", __func__);\n+\t\treturn NULL;\n+\t}\n+\n+\t/* Memory allocation */\n+\tport = rte_zmalloc_socket(\"PORT\", sizeof(*port),\n+\t\t\tRTE_CACHE_LINE_SIZE, socket_id);\n+\tif (port == NULL) {\n+\t\tRTE_LOG(ERR, PORT, \"%s: Failed to allocate port\\n\", __func__);\n+\t\treturn NULL;\n+\t}\n+\n+\t/* Initialization */\n+\tport->fd = conf->fd;\n+\tport->mtu = conf->mtu;\n+\tport->mempool = conf->mempool;\n+\n+\treturn port;\n+}\n+\n+static int\n+rte_port_fd_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts)\n+{\n+\tstruct rte_port_fd_reader *p = (struct rte_port_fd_reader *) port;\n+\tuint32_t i;\n+\n+\tif (rte_mempool_get_bulk(p->mempool, (void **) pkts, n_pkts) != 0)\n+\t\treturn 0;\n+\n+\tfor (i = 0; i < n_pkts; i++) {\n+\t\trte_mbuf_refcnt_set(pkts[i], 1);\n+\t\trte_pktmbuf_reset(pkts[i]);\n+\t}\n+\n+\tfor (i = 0; i < n_pkts; i++) {\n+\t\tstruct rte_mbuf *pkt = pkts[i];\n+\t\tvoid *pkt_data = rte_pktmbuf_mtod(pkt, void *);\n+\n+\t\tssize_t n_bytes = read(p->fd, pkt_data, (size_t) p->mtu);\n+\t\tif (n_bytes <= 0)\n+\t\t\tbreak;\n+\n+\t\tpkt->data_len = n_bytes;\n+\t\tpkt->pkt_len = n_bytes;\n+\t}\n+\n+\tfor ( ; i < n_pkts; i++)\n+\t\trte_pktmbuf_free(pkts[i]);\n+\n+\tRTE_PORT_FD_READER_STATS_PKTS_IN_ADD(p, i);\n+\n+\treturn n_pkts;\n+}\n+\n+static int\n+rte_port_fd_reader_free(void *port)\n+{\n+\tif (port == NULL) {\n+\t\tRTE_LOG(ERR, PORT, \"%s: port is NULL\\n\", __func__);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\trte_free(port);\n+\n+\treturn 0;\n+}\n+\n+static int rte_port_fd_reader_stats_read(void *port,\n+\t\tstruct rte_port_in_stats *stats, int clear)\n+{\n+\tstruct rte_port_fd_reader *p =\n+\t\t\t(struct rte_port_fd_reader *) port;\n+\n+\tif (stats != NULL)\n+\t\tmemcpy(stats, &p->stats, sizeof(p->stats));\n+\n+\tif (clear)\n+\t\tmemset(&p->stats, 0, sizeof(p->stats));\n+\n+\treturn 0;\n+}\n+\n+/*\n+ * Port FD Writer\n+ */\n+#ifdef RTE_PORT_STATS_COLLECT\n+\n+#define RTE_PORT_FD_WRITER_STATS_PKTS_IN_ADD(port, val) \\\n+\tport->stats.n_pkts_in += val\n+#define RTE_PORT_FD_WRITER_STATS_PKTS_DROP_ADD(port, val) \\\n+\tport->stats.n_pkts_drop += val\n+\n+#else\n+\n+#define RTE_PORT_FD_WRITER_STATS_PKTS_IN_ADD(port, val)\n+#define RTE_PORT_FD_WRITER_STATS_PKTS_DROP_ADD(port, val)\n+\n+#endif\n+\n+struct rte_port_fd_writer {\n+\tstruct rte_port_out_stats stats;\n+\n+\tstruct rte_mbuf *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX];\n+\tuint32_t tx_burst_sz;\n+\tuint16_t tx_buf_count;\n+\tuint32_t fd;\n+};\n+\n+static void *\n+rte_port_fd_writer_create(void *params, int socket_id)\n+{\n+\tstruct rte_port_fd_writer_params *conf =\n+\t\t(struct rte_port_fd_writer_params *) params;\n+\tstruct rte_port_fd_writer *port;\n+\n+\t/* Check input parameters */\n+\tif ((conf == NULL) ||\n+\t\t(conf->tx_burst_sz == 0) ||\n+\t\t(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||\n+\t\t(!rte_is_power_of_2(conf->tx_burst_sz))) {\n+\t\tRTE_LOG(ERR, PORT, \"%s: Invalid input parameters\\n\", __func__);\n+\t\treturn NULL;\n+\t}\n+\n+\t/* Memory allocation */\n+\tport = rte_zmalloc_socket(\"PORT\", sizeof(*port),\n+\t\tRTE_CACHE_LINE_SIZE, socket_id);\n+\tif (port == NULL) {\n+\t\tRTE_LOG(ERR, PORT, \"%s: Failed to allocate port\\n\", __func__);\n+\t\treturn NULL;\n+\t}\n+\n+\t/* Initialization */\n+\tport->fd = conf->fd;\n+\tport->tx_burst_sz = conf->tx_burst_sz;\n+\tport->tx_buf_count = 0;\n+\n+\treturn port;\n+}\n+\n+static inline void\n+send_burst(struct rte_port_fd_writer *p)\n+{\n+\tuint32_t i;\n+\n+\tfor (i = 0; i < p->tx_buf_count; i++) {\n+\t\tstruct rte_mbuf *pkt = p->tx_buf[i];\n+\t\tvoid *pkt_data = rte_pktmbuf_mtod(pkt, void*);\n+\t\tsize_t n_bytes = rte_pktmbuf_data_len(pkt);\n+\n+\t\tssize_t ret = write(p->fd, pkt_data, n_bytes);\n+\t\tif (ret < 0)\n+\t\t\tbreak;\n+\t}\n+\n+\tRTE_PORT_FD_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - i);\n+\n+\tfor (i = 0; i < p->tx_buf_count; i++)\n+\t\trte_pktmbuf_free(p->tx_buf[i]);\n+\n+\tp->tx_buf_count = 0;\n+}\n+\n+static int\n+rte_port_fd_writer_tx(void *port, struct rte_mbuf *pkt)\n+{\n+\tstruct rte_port_fd_writer *p =\n+\t\t(struct rte_port_fd_writer *) port;\n+\n+\tp->tx_buf[p->tx_buf_count++] = pkt;\n+\tRTE_PORT_FD_WRITER_STATS_PKTS_IN_ADD(p, 1);\n+\tif (p->tx_buf_count >= p->tx_burst_sz)\n+\t\tsend_burst(p);\n+\n+\treturn 0;\n+}\n+\n+static int\n+rte_port_fd_writer_tx_bulk(void *port,\n+\tstruct rte_mbuf **pkts,\n+\tuint64_t pkts_mask)\n+{\n+\tstruct rte_port_fd_writer *p =\n+\t\t(struct rte_port_fd_writer *) port;\n+\tuint32_t tx_buf_count = p->tx_buf_count;\n+\n+\tif ((pkts_mask & (pkts_mask + 1)) == 0) {\n+\t\tuint64_t n_pkts = __builtin_popcountll(pkts_mask);\n+\t\tuint32_t i;\n+\n+\t\tfor (i = 0; i < n_pkts; i++)\n+\t\t\tp->tx_buf[tx_buf_count++] = pkts[i];\n+\t\tRTE_PORT_FD_WRITER_STATS_PKTS_IN_ADD(p, n_pkts);\n+\t} else\n+\t\tfor ( ; pkts_mask; ) {\n+\t\t\tuint32_t pkt_index = __builtin_ctzll(pkts_mask);\n+\t\t\tuint64_t pkt_mask = 1LLU << pkt_index;\n+\t\t\tstruct rte_mbuf *pkt = pkts[pkt_index];\n+\n+\t\t\tp->tx_buf[tx_buf_count++] = pkt;\n+\t\t\tRTE_PORT_FD_WRITER_STATS_PKTS_IN_ADD(p, 1);\n+\t\t\tpkts_mask &= ~pkt_mask;\n+\t\t}\n+\n+\tp->tx_buf_count = tx_buf_count;\n+\tif (tx_buf_count >= p->tx_burst_sz)\n+\t\tsend_burst(p);\n+\n+\treturn 0;\n+}\n+\n+static int\n+rte_port_fd_writer_flush(void *port)\n+{\n+\tstruct rte_port_fd_writer *p =\n+\t\t(struct rte_port_fd_writer *) port;\n+\n+\tif (p->tx_buf_count > 0)\n+\t\tsend_burst(p);\n+\n+\treturn 0;\n+}\n+\n+static int\n+rte_port_fd_writer_free(void *port)\n+{\n+\tif (port == NULL) {\n+\t\tRTE_LOG(ERR, PORT, \"%s: Port is NULL\\n\", __func__);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\trte_port_fd_writer_flush(port);\n+\trte_free(port);\n+\n+\treturn 0;\n+}\n+\n+static int rte_port_fd_writer_stats_read(void *port,\n+\t\tstruct rte_port_out_stats *stats, int clear)\n+{\n+\tstruct rte_port_fd_writer *p =\n+\t\t(struct rte_port_fd_writer *) port;\n+\n+\tif (stats != NULL)\n+\t\tmemcpy(stats, &p->stats, sizeof(p->stats));\n+\n+\tif (clear)\n+\t\tmemset(&p->stats, 0, sizeof(p->stats));\n+\n+\treturn 0;\n+}\n+\n+/*\n+ * Port FD Writer Nodrop\n+ */\n+#ifdef RTE_PORT_STATS_COLLECT\n+\n+#define RTE_PORT_FD_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val) \\\n+\tport->stats.n_pkts_in += val\n+#define RTE_PORT_FD_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val) \\\n+\tport->stats.n_pkts_drop += val\n+\n+#else\n+\n+#define RTE_PORT_FD_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val)\n+#define RTE_PORT_FD_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val)\n+\n+#endif\n+\n+struct rte_port_fd_writer_nodrop {\n+\tstruct rte_port_out_stats stats;\n+\n+\tstruct rte_mbuf *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX];\n+\tuint32_t tx_burst_sz;\n+\tuint16_t tx_buf_count;\n+\tuint64_t n_retries;\n+\tuint32_t fd;\n+};\n+\n+static void *\n+rte_port_fd_writer_nodrop_create(void *params, int socket_id)\n+{\n+\tstruct rte_port_fd_writer_nodrop_params *conf =\n+\t\t\t(struct rte_port_fd_writer_nodrop_params *) params;\n+\tstruct rte_port_fd_writer_nodrop *port;\n+\n+\t/* Check input parameters */\n+\tif ((conf == NULL) ||\n+\t\t(conf->fd < 0) ||\n+\t\t(conf->tx_burst_sz == 0) ||\n+\t\t(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||\n+\t\t(!rte_is_power_of_2(conf->tx_burst_sz))) {\n+\t\tRTE_LOG(ERR, PORT, \"%s: Invalid input parameters\\n\", __func__);\n+\t\treturn NULL;\n+\t}\n+\n+\t/* Memory allocation */\n+\tport = rte_zmalloc_socket(\"PORT\", sizeof(*port),\n+\t\tRTE_CACHE_LINE_SIZE, socket_id);\n+\tif (port == NULL) {\n+\t\tRTE_LOG(ERR, PORT, \"%s: Failed to allocate port\\n\", __func__);\n+\t\treturn NULL;\n+\t}\n+\n+\t/* Initialization */\n+\tport->fd = conf->fd;\n+\tport->tx_burst_sz = conf->tx_burst_sz;\n+\tport->tx_buf_count = 0;\n+\n+\t/*\n+\t * When n_retries is 0 it means that we should wait for every packet to\n+\t * send no matter how many retries should it take. To limit number of\n+\t * branches in fast path, we use UINT64_MAX instead of branching.\n+\t */\n+\tport->n_retries = (conf->n_retries == 0) ? UINT64_MAX : conf->n_retries;\n+\n+\treturn port;\n+}\n+\n+static inline void\n+send_burst_nodrop(struct rte_port_fd_writer_nodrop *p)\n+{\n+\tuint64_t n_retries;\n+\tuint32_t i;\n+\n+\tn_retries = 0;\n+\tfor (i = 0; (i < p->tx_buf_count) && (n_retries < p->n_retries); i++) {\n+\t\tstruct rte_mbuf *pkt = p->tx_buf[i];\n+\t\tvoid *pkt_data = rte_pktmbuf_mtod(pkt, void*);\n+\t\tsize_t n_bytes = rte_pktmbuf_data_len(pkt);\n+\n+\t\tfor ( ; n_retries < p->n_retries; n_retries++) {\n+\t\t\tssize_t ret = write(p->fd, pkt_data, n_bytes);\n+\t\t\tif (ret)\n+\t\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\tRTE_PORT_FD_WRITER_NODROP_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - i);\n+\n+\tfor (i = 0; i < p->tx_buf_count; i++)\n+\t\trte_pktmbuf_free(p->tx_buf[i]);\n+\n+\tp->tx_buf_count = 0;\n+}\n+\n+static int\n+rte_port_fd_writer_nodrop_tx(void *port, struct rte_mbuf *pkt)\n+{\n+\tstruct rte_port_fd_writer_nodrop *p =\n+\t\t(struct rte_port_fd_writer_nodrop *) port;\n+\n+\tp->tx_buf[p->tx_buf_count++] = pkt;\n+\tRTE_PORT_FD_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1);\n+\tif (p->tx_buf_count >= p->tx_burst_sz)\n+\t\tsend_burst_nodrop(p);\n+\n+\treturn 0;\n+}\n+\n+static int\n+rte_port_fd_writer_nodrop_tx_bulk(void *port,\n+\tstruct rte_mbuf **pkts,\n+\tuint64_t pkts_mask)\n+{\n+\tstruct rte_port_fd_writer_nodrop *p =\n+\t\t(struct rte_port_fd_writer_nodrop *) port;\n+\tuint32_t tx_buf_count = p->tx_buf_count;\n+\n+\tif ((pkts_mask & (pkts_mask + 1)) == 0) {\n+\t\tuint64_t n_pkts = __builtin_popcountll(pkts_mask);\n+\t\tuint32_t i;\n+\n+\t\tfor (i = 0; i < n_pkts; i++)\n+\t\t\tp->tx_buf[tx_buf_count++] = pkts[i];\n+\t\tRTE_PORT_FD_WRITER_NODROP_STATS_PKTS_IN_ADD(p, n_pkts);\n+\t} else\n+\t\tfor ( ; pkts_mask; ) {\n+\t\t\tuint32_t pkt_index = __builtin_ctzll(pkts_mask);\n+\t\t\tuint64_t pkt_mask = 1LLU << pkt_index;\n+\t\t\tstruct rte_mbuf *pkt = pkts[pkt_index];\n+\n+\t\t\tp->tx_buf[tx_buf_count++] = pkt;\n+\t\t\tRTE_PORT_FD_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1);\n+\t\t\tpkts_mask &= ~pkt_mask;\n+\t\t}\n+\n+\tp->tx_buf_count = tx_buf_count;\n+\tif (tx_buf_count >= p->tx_burst_sz)\n+\t\tsend_burst_nodrop(p);\n+\n+\treturn 0;\n+}\n+\n+static int\n+rte_port_fd_writer_nodrop_flush(void *port)\n+{\n+\tstruct rte_port_fd_writer_nodrop *p =\n+\t\t(struct rte_port_fd_writer_nodrop *) port;\n+\n+\tif (p->tx_buf_count > 0)\n+\t\tsend_burst_nodrop(p);\n+\n+\treturn 0;\n+}\n+\n+static int\n+rte_port_fd_writer_nodrop_free(void *port)\n+{\n+\tif (port == NULL) {\n+\t\tRTE_LOG(ERR, PORT, \"%s: Port is NULL\\n\", __func__);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\trte_port_fd_writer_nodrop_flush(port);\n+\trte_free(port);\n+\n+return 0;\n+}\n+\n+static int rte_port_fd_writer_nodrop_stats_read(void *port,\n+\t\tstruct rte_port_out_stats *stats, int clear)\n+{\n+\tstruct rte_port_fd_writer_nodrop *p =\n+\t\t(struct rte_port_fd_writer_nodrop *) port;\n+\n+\tif (stats != NULL)\n+\t\tmemcpy(stats, &p->stats, sizeof(p->stats));\n+\n+\tif (clear)\n+\t\tmemset(&p->stats, 0, sizeof(p->stats));\n+\n+\treturn 0;\n+}\n+\n+/*\n+ * Summary of port operations\n+ */\n+struct rte_port_in_ops rte_port_fd_reader_ops = {\n+\t.f_create = rte_port_fd_reader_create,\n+\t.f_free = rte_port_fd_reader_free,\n+\t.f_rx = rte_port_fd_reader_rx,\n+\t.f_stats = rte_port_fd_reader_stats_read,\n+};\n+\n+struct rte_port_out_ops rte_port_fd_writer_ops = {\n+\t.f_create = rte_port_fd_writer_create,\n+\t.f_free = rte_port_fd_writer_free,\n+\t.f_tx = rte_port_fd_writer_tx,\n+\t.f_tx_bulk = rte_port_fd_writer_tx_bulk,\n+\t.f_flush = rte_port_fd_writer_flush,\n+\t.f_stats = rte_port_fd_writer_stats_read,\n+};\n+\n+struct rte_port_out_ops rte_port_fd_writer_nodrop_ops = {\n+\t.f_create = rte_port_fd_writer_nodrop_create,\n+\t.f_free = rte_port_fd_writer_nodrop_free,\n+\t.f_tx = rte_port_fd_writer_nodrop_tx,\n+\t.f_tx_bulk = rte_port_fd_writer_nodrop_tx_bulk,\n+\t.f_flush = rte_port_fd_writer_nodrop_flush,\n+\t.f_stats = rte_port_fd_writer_nodrop_stats_read,\n+};\ndiff --git a/lib/librte_port/rte_port_fd.h b/lib/librte_port/rte_port_fd.h\nnew file mode 100644\nindex 0000000..78396c3\n--- /dev/null\n+++ b/lib/librte_port/rte_port_fd.h\n@@ -0,0 +1,103 @@\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 __INCLUDE_RTE_PORT_FD_H__\n+#define __INCLUDE_RTE_PORT_FD_H__\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+/**\n+ * @file\n+ * RTE Port FD Device\n+ *\n+ * fd_reader: input port built on top of valid non-blocking file descriptor\n+ * fd_writer: output port built on top of valid non-blocking file descriptor\n+ *\n+ ***/\n+\n+#include <stdint.h>\n+\n+#include <rte_mempool.h>\n+#include \"rte_port.h\"\n+\n+/** fd_reader port parameters */\n+struct rte_port_fd_reader_params {\n+\t/** File descriptor */\n+\tint fd;\n+\n+\t/** Maximum Transfer Unit (MTU) */\n+\tuint32_t mtu;\n+\n+\t/** Pre-initialized buffer pool */\n+\tstruct rte_mempool *mempool;\n+};\n+\n+/** fd_reader port operations */\n+extern struct rte_port_in_ops rte_port_fd_reader_ops;\n+\n+/** fd_writer port parameters */\n+struct rte_port_fd_writer_params {\n+\t/** File descriptor */\n+\tint fd;\n+\n+\t/** Recommended write burst size. The actual burst size can be\n+\tbigger or smaller than this value. */\n+\tuint32_t tx_burst_sz;\n+};\n+\n+/** fd_writer port operations */\n+extern struct rte_port_out_ops rte_port_fd_writer_ops;\n+\n+/** fd_writer_nodrop port parameters */\n+struct rte_port_fd_writer_nodrop_params {\n+\t/** File descriptor */\n+\tint fd;\n+\n+\t/** Recommended write burst size. The actual burst size can be\n+\tbigger or smaller than this value. */\n+\tuint32_t tx_burst_sz;\n+\n+\t/** Maximum number of retries, 0 for no limit */\n+\tuint32_t n_retries;\n+};\n+\n+/** fd_writer_nodrop port operations */\n+extern struct rte_port_out_ops rte_port_fd_writer_nodrop_ops;\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif\ndiff --git a/lib/librte_port/rte_port_version.map b/lib/librte_port/rte_port_version.map\nindex 048c20d..82151ae 100644\n--- a/lib/librte_port/rte_port_version.map\n+++ b/lib/librte_port/rte_port_version.map\n@@ -42,3 +42,12 @@ DPDK_16.07 {\n \trte_port_kni_writer_nodrop_ops;\n \n } DPDK_2.2;\n+\n+DPDK_16.11 {\n+\tglobal:\n+\n+\trte_port_fd_reader_ops;\n+\trte_port_fd_writer_ops;\n+\trte_port_fd_writer_nodrop_ops;\n+\n+} DPDK_16.07;\n",
    "prefixes": [
        "dpdk-dev",
        "1/3"
    ]
}