Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/16470/?format=api
http://patchwork.dpdk.org/api/patches/16470/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20161010131946.13303-1-ferruh.yigit@intel.com/", "project": { "id": 1, "url": "http://patchwork.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": "<20161010131946.13303-1-ferruh.yigit@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20161010131946.13303-1-ferruh.yigit@intel.com", "date": "2016-10-10T13:19:46", "name": "[dpdk-dev,v3] net/kni: add KNI PMD", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "5cc6fff1fac761dc3da88a093c950ce93fe3a6f4", "submitter": { "id": 324, "url": "http://patchwork.dpdk.org/api/people/324/?format=api", "name": "Ferruh Yigit", "email": "ferruh.yigit@intel.com" }, "delegate": { "id": 10, "url": "http://patchwork.dpdk.org/api/users/10/?format=api", "username": "bruce", "first_name": "Bruce", "last_name": "Richardson", "email": "bruce.richardson@intel.com" }, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20161010131946.13303-1-ferruh.yigit@intel.com/mbox/", "series": [], "comments": "http://patchwork.dpdk.org/api/patches/16470/comments/", "check": "pending", "checks": "http://patchwork.dpdk.org/api/patches/16470/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 12E1A6C94;\n\tMon, 10 Oct 2016 15:19:53 +0200 (CEST)", "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby dpdk.org (Postfix) with ESMTP id 9FDBC2E41\n\tfor <dev@dpdk.org>; Mon, 10 Oct 2016 15:19:50 +0200 (CEST)", "from orsmga004.jf.intel.com ([10.7.209.38])\n\tby fmsmga101.fm.intel.com with ESMTP; 10 Oct 2016 06:19:49 -0700", "from sivswdev02.ir.intel.com ([10.237.217.46])\n\tby orsmga004.jf.intel.com with ESMTP; 10 Oct 2016 06:19:48 -0700" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.31,324,1473145200\"; d=\"scan'208\";a=\"18486676\"", "From": "Ferruh Yigit <ferruh.yigit@intel.com>", "To": "dev@dpdk.org", "Cc": "Ferruh Yigit <ferruh.yigit@intel.com>", "Date": "Mon, 10 Oct 2016 14:19:46 +0100", "Message-Id": "<20161010131946.13303-1-ferruh.yigit@intel.com>", "X-Mailer": "git-send-email 2.8.4", "In-Reply-To": "<1474025398-18553-1-git-send-email-ferruh.yigit@intel.com>", "References": "<1474025398-18553-1-git-send-email-ferruh.yigit@intel.com>", "Subject": "[dpdk-dev] [PATCH v3] net/kni: add KNI PMD", "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": "Add KNI PMD which wraps librte_kni for ease of use.\n\nKNI PMD can be used as any regular PMD to send / receive packets to the\nLinux networking stack.\n\nSigned-off-by: Ferruh Yigit <ferruh.yigit@intel.com>\n---\n\nv3:\n* rebase on top of latest master\n\nv2:\n* updated driver name eth_kni -> net_kni\n---\n config/common_base | 1 +\n config/common_linuxapp | 1 +\n drivers/net/Makefile | 1 +\n drivers/net/kni/Makefile | 63 +++++\n drivers/net/kni/rte_eth_kni.c | 463 ++++++++++++++++++++++++++++++++\n drivers/net/kni/rte_pmd_kni_version.map | 4 +\n mk/rte.app.mk | 10 +-\n 7 files changed, 538 insertions(+), 5 deletions(-)\n create mode 100644 drivers/net/kni/Makefile\n create mode 100644 drivers/net/kni/rte_eth_kni.c\n create mode 100644 drivers/net/kni/rte_pmd_kni_version.map", "diff": "diff --git a/config/common_base b/config/common_base\nindex f5d2eff..03b93c7 100644\n--- a/config/common_base\n+++ b/config/common_base\n@@ -543,6 +543,7 @@ CONFIG_RTE_PIPELINE_STATS_COLLECT=n\n # Compile librte_kni\n #\n CONFIG_RTE_LIBRTE_KNI=n\n+CONFIG_RTE_LIBRTE_PMD_KNI=n\n CONFIG_RTE_KNI_KMOD=n\n CONFIG_RTE_KNI_PREEMPT_DEFAULT=y\n CONFIG_RTE_KNI_KO_DEBUG=n\ndiff --git a/config/common_linuxapp b/config/common_linuxapp\nindex 2483dfa..2ecd510 100644\n--- a/config/common_linuxapp\n+++ b/config/common_linuxapp\n@@ -39,6 +39,7 @@ CONFIG_RTE_EAL_IGB_UIO=y\n CONFIG_RTE_EAL_VFIO=y\n CONFIG_RTE_KNI_KMOD=y\n CONFIG_RTE_LIBRTE_KNI=y\n+CONFIG_RTE_LIBRTE_PMD_KNI=y\n CONFIG_RTE_LIBRTE_VHOST=y\n CONFIG_RTE_LIBRTE_PMD_VHOST=y\n CONFIG_RTE_LIBRTE_PMD_AF_PACKET=y\ndiff --git a/drivers/net/Makefile b/drivers/net/Makefile\nindex bc93230..c4771cd 100644\n--- a/drivers/net/Makefile\n+++ b/drivers/net/Makefile\n@@ -41,6 +41,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += enic\n DIRS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k\n DIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e\n DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe\n+DIRS-$(CONFIG_RTE_LIBRTE_PMD_KNI) += kni\n DIRS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4\n DIRS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5\n DIRS-$(CONFIG_RTE_LIBRTE_MPIPE_PMD) += mpipe\ndiff --git a/drivers/net/kni/Makefile b/drivers/net/kni/Makefile\nnew file mode 100644\nindex 0000000..0b7cf91\n--- /dev/null\n+++ b/drivers/net/kni/Makefile\n@@ -0,0 +1,63 @@\n+# BSD LICENSE\n+#\n+# Copyright(c) 2016 Intel Corporation. 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_kni.a\n+\n+CFLAGS += -O3\n+CFLAGS += $(WERROR_FLAGS)\n+LDLIBS += -lpthread\n+\n+EXPORT_MAP := rte_pmd_kni_version.map\n+\n+LIBABIVER := 1\n+\n+#\n+# all source are stored in SRCS-y\n+#\n+SRCS-$(CONFIG_RTE_LIBRTE_PMD_KNI) += rte_eth_kni.c\n+\n+#\n+# Export include files\n+#\n+SYMLINK-y-include +=\n+\n+# this lib depends upon:\n+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_KNI) += lib/librte_eal\n+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_KNI) += lib/librte_ether\n+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_KNI) += lib/librte_kni\n+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_KNI) += lib/librte_mbuf\n+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_KNI) += lib/librte_mempool\n+\n+include $(RTE_SDK)/mk/rte.lib.mk\ndiff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c\nnew file mode 100644\nindex 0000000..ce9e758\n--- /dev/null\n+++ b/drivers/net/kni/rte_eth_kni.c\n@@ -0,0 +1,463 @@\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+\n+#include <fcntl.h>\n+#include <pthread.h>\n+#include <unistd.h>\n+\n+#include <rte_ethdev.h>\n+#include <rte_kni.h>\n+#include <rte_malloc.h>\n+#include <rte_vdev.h>\n+\n+#define KNI_MAX_QUEUE_PER_PORT 8\n+#define MAX_PACKET_SZ 2048\n+#define MAX_KNI_PORTS 8\n+#define DRV_NAME net_kni\n+\n+struct pmd_queue_stats {\n+\tuint64_t pkts;\n+\tuint64_t bytes;\n+\tuint64_t err_pkts;\n+};\n+\n+struct pmd_queue {\n+\tstruct pmd_internals *internals;\n+\tstruct rte_mempool *mb_pool;\n+\n+\tstruct pmd_queue_stats rx;\n+\tstruct pmd_queue_stats tx;\n+};\n+\n+struct pmd_internals {\n+\tstruct rte_kni *kni;\n+\tint is_kni_started;\n+\n+\tpthread_t thread;\n+\tint stop_thread;\n+\n+\tstruct pmd_queue rx_queues[KNI_MAX_QUEUE_PER_PORT];\n+\tstruct pmd_queue tx_queues[KNI_MAX_QUEUE_PER_PORT];\n+};\n+\n+static struct ether_addr eth_addr;\n+static const char *drivername = RTE_STR(DRV_NAME);\n+static struct rte_eth_link pmd_link = {\n+\t\t.link_speed = 10000,\n+\t\t.link_duplex = ETH_LINK_FULL_DUPLEX,\n+\t\t.link_status = 0\n+};\n+static int is_kni_initialized;\n+\n+static uint16_t\n+eth_kni_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)\n+{\n+\tstruct pmd_queue *kni_q = q;\n+\tstruct rte_kni *kni = kni_q->internals->kni;\n+\tuint16_t nb_pkts;\n+\n+\tnb_pkts = rte_kni_rx_burst(kni, bufs, nb_bufs);\n+\n+\tkni_q->rx.pkts += nb_pkts;\n+\tkni_q->rx.err_pkts += nb_bufs - nb_pkts;\n+\n+\treturn nb_pkts;\n+}\n+\n+static uint16_t\n+eth_kni_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)\n+{\n+\tstruct pmd_queue *kni_q = q;\n+\tstruct rte_kni *kni = kni_q->internals->kni;\n+\tuint16_t nb_pkts;\n+\n+\tnb_pkts = rte_kni_tx_burst(kni, bufs, nb_bufs);\n+\n+\tkni_q->tx.pkts += nb_pkts;\n+\tkni_q->tx.err_pkts += nb_bufs - nb_pkts;\n+\n+\treturn nb_pkts;\n+}\n+\n+static void *\n+kni_handle_request(void *param)\n+{\n+\tstruct pmd_internals *internals = param;\n+#define MS 1000\n+\n+\twhile (!internals->stop_thread) {\n+\t\trte_kni_handle_request(internals->kni);\n+\t\tusleep(500 * MS);\n+\t}\n+\n+\treturn param;\n+}\n+\n+static int\n+eth_kni_start(struct rte_eth_dev *dev)\n+{\n+\tstruct pmd_internals *internals = dev->data->dev_private;\n+\tuint16_t port_id = dev->data->port_id;\n+\tstruct rte_mempool *mb_pool;\n+\tstruct rte_kni_conf conf;\n+\tconst char *name = dev->data->name + 4; /* remove eth_ */\n+\n+\tsnprintf(conf.name, RTE_KNI_NAMESIZE, \"%s\", name);\n+\tconf.force_bind = 0;\n+\tconf.group_id = port_id;\n+\tconf.mbuf_size = MAX_PACKET_SZ;\n+\tmb_pool = internals->rx_queues[0].mb_pool;\n+\n+\tinternals->kni = rte_kni_alloc(mb_pool, &conf, NULL);\n+\tif (internals->kni == NULL) {\n+\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\"Fail to create kni for port: %d\\n\", port_id);\n+\t\treturn -1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n+eth_kni_dev_start(struct rte_eth_dev *dev)\n+{\n+\tstruct pmd_internals *internals = dev->data->dev_private;\n+\tint ret;\n+\n+\tif (internals->is_kni_started == 0) {\n+\t\tret = eth_kni_start(dev);\n+\t\tif (ret)\n+\t\t\treturn -1;\n+\t\tinternals->is_kni_started = 1;\n+\t}\n+\n+\tret = pthread_create(&internals->thread, NULL, kni_handle_request,\n+\t\t\tinternals);\n+\tif (ret) {\n+\t\tRTE_LOG(ERR, PMD, \"Fail to create kni request thread\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tdev->data->dev_link.link_status = 1;\n+\n+\treturn 0;\n+}\n+\n+static void\n+eth_kni_dev_stop(struct rte_eth_dev *dev)\n+{\n+\tstruct pmd_internals *internals = dev->data->dev_private;\n+\tint ret;\n+\n+\tinternals->stop_thread = 1;\n+\n+\tret = pthread_cancel(internals->thread);\n+\tif (ret)\n+\t\tRTE_LOG(ERR, PMD, \"Can't cancel the thread\\n\");\n+\n+\tret = pthread_join(internals->thread, NULL);\n+\tif (ret)\n+\t\tRTE_LOG(ERR, PMD, \"Can't join the thread\\n\");\n+\n+\tinternals->stop_thread = 0;\n+\n+\tdev->data->dev_link.link_status = 0;\n+}\n+\n+static int\n+eth_kni_dev_configure(struct rte_eth_dev *dev __rte_unused)\n+{\n+\treturn 0;\n+}\n+\n+static void\n+eth_kni_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)\n+{\n+\tstruct rte_eth_dev_data *data = dev->data;\n+\tstruct pmd_internals *internals = data->dev_private;\n+\n+\tdev_info->driver_name = data->drv_name;\n+\tdev_info->max_mac_addrs = 1;\n+\tdev_info->max_rx_pktlen = (uint32_t)-1;\n+\tdev_info->max_rx_queues = RTE_DIM(internals->rx_queues);\n+\tdev_info->max_tx_queues = RTE_DIM(internals->tx_queues);\n+\tdev_info->min_rx_bufsize = 0;\n+\tdev_info->pci_dev = NULL;\n+}\n+\n+static int\n+eth_kni_rx_queue_setup(struct rte_eth_dev *dev,\n+\t\tuint16_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)\n+{\n+\tstruct pmd_internals *internals = dev->data->dev_private;\n+\tstruct pmd_queue *q;\n+\n+\tq = &internals->rx_queues[rx_queue_id];\n+\tq->internals = internals;\n+\tq->mb_pool = mb_pool;\n+\n+\tdev->data->rx_queues[rx_queue_id] = q;\n+\n+\treturn 0;\n+}\n+\n+static int\n+eth_kni_tx_queue_setup(struct rte_eth_dev *dev,\n+\t\tuint16_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 pmd_internals *internals = dev->data->dev_private;\n+\tstruct pmd_queue *q;\n+\n+\tq = &internals->tx_queues[tx_queue_id];\n+\tq->internals = internals;\n+\n+\tdev->data->tx_queues[tx_queue_id] = q;\n+\n+\treturn 0;\n+}\n+\n+static void\n+eth_kni_queue_release(void *q __rte_unused)\n+{\n+}\n+\n+static int\n+eth_kni_link_update(struct rte_eth_dev *dev __rte_unused,\n+\t\tint wait_to_complete __rte_unused)\n+{\n+\treturn 0;\n+}\n+\n+static void\n+eth_kni_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)\n+{\n+\tunsigned long rx_packets_total = 0, rx_bytes_total = 0;\n+\tunsigned long tx_packets_total = 0, tx_bytes_total = 0;\n+\tstruct rte_eth_dev_data *data = dev->data;\n+\tunsigned long tx_packets_err_total = 0;\n+\tunsigned int i, num_stats;\n+\tstruct pmd_queue *q;\n+\n+\tnum_stats = RTE_MIN((unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS,\n+\t\t\tdata->nb_rx_queues);\n+\tfor (i = 0; i < num_stats; i++) {\n+\t\tq = data->rx_queues[i];\n+\t\tstats->q_ipackets[i] = q->rx.pkts;\n+\t\tstats->q_ibytes[i] = q->rx.bytes;\n+\t\trx_packets_total += stats->q_ipackets[i];\n+\t\trx_bytes_total += stats->q_ibytes[i];\n+\t}\n+\n+\tnum_stats = RTE_MIN((unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS,\n+\t\t\tdata->nb_tx_queues);\n+\tfor (i = 0; i < num_stats; i++) {\n+\t\tq = data->tx_queues[i];\n+\t\tstats->q_opackets[i] = q->tx.pkts;\n+\t\tstats->q_obytes[i] = q->tx.bytes;\n+\t\tstats->q_errors[i] = q->tx.err_pkts;\n+\t\ttx_packets_total += stats->q_opackets[i];\n+\t\ttx_bytes_total += stats->q_obytes[i];\n+\t\ttx_packets_err_total += stats->q_errors[i];\n+\t}\n+\n+\tstats->ipackets = rx_packets_total;\n+\tstats->ibytes = rx_bytes_total;\n+\tstats->opackets = tx_packets_total;\n+\tstats->obytes = tx_bytes_total;\n+\tstats->oerrors = tx_packets_err_total;\n+}\n+\n+static void\n+eth_kni_stats_reset(struct rte_eth_dev *dev)\n+{\n+\tstruct rte_eth_dev_data *data = dev->data;\n+\tstruct pmd_queue *q;\n+\tunsigned int i;\n+\n+\tfor (i = 0; i < data->nb_rx_queues; i++) {\n+\t\tq = data->rx_queues[i];\n+\t\tq->rx.pkts = 0;\n+\t\tq->rx.bytes = 0;\n+\t}\n+\tfor (i = 0; i < data->nb_tx_queues; i++) {\n+\t\tq = data->tx_queues[i];\n+\t\tq->tx.pkts = 0;\n+\t\tq->tx.bytes = 0;\n+\t\tq->tx.err_pkts = 0;\n+\t}\n+}\n+\n+static const struct eth_dev_ops eth_kni_ops = {\n+\t.dev_start = eth_kni_dev_start,\n+\t.dev_stop = eth_kni_dev_stop,\n+\t.dev_configure = eth_kni_dev_configure,\n+\t.dev_infos_get = eth_kni_dev_info,\n+\t.rx_queue_setup = eth_kni_rx_queue_setup,\n+\t.tx_queue_setup = eth_kni_tx_queue_setup,\n+\t.rx_queue_release = eth_kni_queue_release,\n+\t.tx_queue_release = eth_kni_queue_release,\n+\t.link_update = eth_kni_link_update,\n+\t.stats_get = eth_kni_stats_get,\n+\t.stats_reset = eth_kni_stats_reset,\n+};\n+\n+static struct rte_eth_dev *\n+eth_kni_create(const char *name, unsigned int numa_node)\n+{\n+\tstruct pmd_internals *internals = NULL;\n+\tstruct rte_eth_dev_data *data;\n+\tstruct rte_eth_dev *eth_dev;\n+\tuint16_t nb_rx_queues = 1;\n+\tuint16_t nb_tx_queues = 1;\n+\n+\tRTE_LOG(INFO, PMD, \"Creating kni ethdev on numa socket %u\\n\",\n+\t\t\tnuma_node);\n+\n+\tdata = rte_zmalloc_socket(name, sizeof(*data), 0, numa_node);\n+\tif (data == 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+\tdata->dev_private = internals;\n+\tdata->port_id = eth_dev->data->port_id;\n+\tmemmove(data->name, eth_dev->data->name, sizeof(data->name));\n+\tdata->nb_rx_queues = nb_rx_queues;\n+\tdata->nb_tx_queues = nb_tx_queues;\n+\tdata->dev_link = pmd_link;\n+\tdata->mac_addrs = ð_addr;\n+\n+\teth_dev->data = data;\n+\teth_dev->dev_ops = ð_kni_ops;\n+\teth_dev->driver = NULL;\n+\n+\tdata->dev_flags = RTE_ETH_DEV_DETACHABLE;\n+\tdata->kdrv = RTE_KDRV_NONE;\n+\tdata->drv_name = drivername;\n+\tdata->numa_node = numa_node;\n+\n+\treturn eth_dev;\n+\n+error:\n+\trte_free(data);\n+\trte_free(internals);\n+\n+\treturn NULL;\n+}\n+\n+static int\n+kni_init(void)\n+{\n+\tif (is_kni_initialized == 0)\n+\t\trte_kni_init(MAX_KNI_PORTS);\n+\n+\tis_kni_initialized += 1;\n+\n+\treturn 0;\n+}\n+\n+static int\n+eth_kni_probe(const char *name, const char *params __rte_unused)\n+{\n+\tstruct rte_eth_dev *eth_dev;\n+\tint ret;\n+\n+\tRTE_LOG(INFO, PMD, \"Initializing eth_kni for %s\\n\", name);\n+\n+\tret = kni_init();\n+\tif (ret < 0)\n+\t\t/* Not return error to prevent panic in rte_eal_init() */\n+\t\treturn 0;\n+\n+\teth_dev = eth_kni_create(name, rte_socket_id());\n+\tif (eth_dev == NULL)\n+\t\treturn -1;\n+\n+\teth_dev->rx_pkt_burst = eth_kni_rx;\n+\teth_dev->tx_pkt_burst = eth_kni_tx;\n+\n+\treturn 0;\n+}\n+\n+static int\n+eth_kni_remove(const char *name)\n+{\n+\tstruct rte_eth_dev *eth_dev;\n+\tstruct pmd_internals *internals;\n+\n+\tRTE_LOG(INFO, PMD, \"Un-Initializing eth_kni for %s\\n\", name);\n+\n+\t/* find the ethdev entry */\n+\teth_dev = rte_eth_dev_allocated(name);\n+\tif (eth_dev == NULL)\n+\t\treturn -1;\n+\n+\teth_kni_dev_stop(eth_dev);\n+\n+\tif (eth_dev->data) {\n+\t\tinternals = eth_dev->data->dev_private;\n+\t\trte_kni_release(internals->kni);\n+\n+\t\trte_free(internals);\n+\t}\n+\trte_free(eth_dev->data);\n+\n+\trte_eth_dev_release_port(eth_dev);\n+\n+\tis_kni_initialized -= 1;\n+\tif (is_kni_initialized == 0)\n+\t\trte_kni_close();\n+\n+\treturn 0;\n+}\n+\n+static struct rte_vdev_driver eth_kni_drv = {\n+\t.probe = eth_kni_probe,\n+\t.remove = eth_kni_remove,\n+};\n+\n+DRIVER_REGISTER_VDEV(DRV_NAME, eth_kni_drv);\ndiff --git a/drivers/net/kni/rte_pmd_kni_version.map b/drivers/net/kni/rte_pmd_kni_version.map\nnew file mode 100644\nindex 0000000..61463bf\n--- /dev/null\n+++ b/drivers/net/kni/rte_pmd_kni_version.map\n@@ -0,0 +1,4 @@\n+DPDK_16.11 {\n+\n+\tlocal: *;\n+};\ndiff --git a/mk/rte.app.mk b/mk/rte.app.mk\nindex ac50a21..a94983b 100644\n--- a/mk/rte.app.mk\n+++ b/mk/rte.app.mk\n@@ -59,11 +59,6 @@ _LDLIBS-y += -L$(RTE_SDK_BIN)/lib\n #\n # Order is important: from higher level to lower level\n #\n-\n-ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)\n-_LDLIBS-$(CONFIG_RTE_LIBRTE_KNI) += -lrte_kni\n-endif\n-\n _LDLIBS-$(CONFIG_RTE_LIBRTE_PIPELINE) += -lrte_pipeline\n _LDLIBS-$(CONFIG_RTE_LIBRTE_TABLE) += -lrte_table\n _LDLIBS-$(CONFIG_RTE_LIBRTE_PORT) += -lrte_port\n@@ -84,6 +79,10 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_POWER) += -lrte_power\n \n _LDLIBS-y += --whole-archive\n \n+ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)\n+_LDLIBS-$(CONFIG_RTE_LIBRTE_KNI) += -lrte_kni\n+endif\n+\n _LDLIBS-$(CONFIG_RTE_LIBRTE_TIMER) += -lrte_timer\n _LDLIBS-$(CONFIG_RTE_LIBRTE_HASH) += -lrte_hash\n _LDLIBS-$(CONFIG_RTE_LIBRTE_VHOST) += -lrte_vhost\n@@ -114,6 +113,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += -lrte_pmd_enic\n _LDLIBS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += -lrte_pmd_fm10k\n _LDLIBS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += -lrte_pmd_i40e\n _LDLIBS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += -lrte_pmd_ixgbe\n+_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_KNI) += -lrte_pmd_kni\n _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += -lrte_pmd_mlx4 -libverbs\n _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += -lrte_pmd_mlx5 -libverbs\n _LDLIBS-$(CONFIG_RTE_LIBRTE_MPIPE_PMD) += -lrte_pmd_mpipe -lgxio\n", "prefixes": [ "dpdk-dev", "v3" ] }{ "id": 16470, "url": "