get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2990,
    "url": "http://patches.dpdk.org/api/patches/2990/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1423098809-21305-5-git-send-email-stephen@networkplumber.org/",
    "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": "<1423098809-21305-5-git-send-email-stephen@networkplumber.org>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1423098809-21305-5-git-send-email-stephen@networkplumber.org",
    "date": "2015-02-05T01:13:26",
    "name": "[dpdk-dev,4/7] hv: uio driver",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "0d963142c4fe02ba781cc2778ad1c21863fbcf65",
    "submitter": {
        "id": 27,
        "url": "http://patches.dpdk.org/api/people/27/?format=api",
        "name": "Stephen Hemminger",
        "email": "stephen@networkplumber.org"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1423098809-21305-5-git-send-email-stephen@networkplumber.org/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/2990/comments/",
    "check": "pending",
    "checks": "http://patches.dpdk.org/api/patches/2990/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 714B4B40F;\n\tThu,  5 Feb 2015 02:13:43 +0100 (CET)",
            "from mail-pd0-f179.google.com (mail-pd0-f179.google.com\n\t[209.85.192.179]) by dpdk.org (Postfix) with ESMTP id 6B72CB3E9\n\tfor <dev@dpdk.org>; Thu,  5 Feb 2015 02:13:39 +0100 (CET)",
            "by pdbfl12 with SMTP id fl12so4221730pdb.6\n\tfor <dev@dpdk.org>; Wed, 04 Feb 2015 17:13:38 -0800 (PST)",
            "from urahara.brocade.com\n\t(static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155])\n\tby mx.google.com with ESMTPSA id\n\tcz1sm3236673pdb.32.2015.02.04.17.13.37\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tWed, 04 Feb 2015 17:13:37 -0800 (PST)"
        ],
        "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=PcT+3AnNgsH1kAuzDfcngmWl7WdjVrhVVVsQy7HCPW4=;\n\tb=V0bII8GCbyS6nmJ5diKIEAgg548w4prg2bnylHCckQsYyzZT8sS50MpYxYYrm0uf2s\n\tszw6og6+XL1TXH6JIuhZ/8qY/2DES6olGP35N3UUtOJcz8iG89CA+hf1r+JjRH0He2dQ\n\tZGfX4wBxkQImcFtE3NUurQV87fVlAdnWJbo1C/Xhsd/QIA7b0UhReUhSX7L6HKwydlai\n\thk9QcdHDN/uOpCPeKUkVxoqcz+LVHGtFQJVo8ndR5fb8SJm98D+rrHJZiL/uvv8OuwB3\n\tYf+IJi578RTOkJhIAejLs+19zW88PSi+SlHWRk1YVfUdOi+Gabyst6CMlfVKIAJ+HIYS\n\t+G9w==",
        "X-Gm-Message-State": "ALoCoQmfpNlya/IKQzSiD4aG+Pfe3LWp0xhVF+dG6OiZjHTlG3vZya1MCn7qens8wRJQR0IoIqxJ",
        "X-Received": "by 10.68.208.101 with SMTP id md5mr1805410pbc.28.1423098818739; \n\tWed, 04 Feb 2015 17:13:38 -0800 (PST)",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "To": "dev@dpdk.org",
        "Date": "Wed,  4 Feb 2015 17:13:26 -0800",
        "Message-Id": "<1423098809-21305-5-git-send-email-stephen@networkplumber.org>",
        "X-Mailer": "git-send-email 2.1.4",
        "In-Reply-To": "<1423098809-21305-1-git-send-email-stephen@networkplumber.org>",
        "References": "<1423098809-21305-1-git-send-email-stephen@networkplumber.org>",
        "Cc": "KY Srinivasan <kys@microsoft.com>, Stas Egorov <segorov@mirantis.com>,\n\tStephen Hemminger <shemming@brocade.com>",
        "Subject": "[dpdk-dev] [PATCH 4/7] hv: uio driver",
        "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": "From: Stephen Hemminger <shemming@brocade.com>\n\nAdd new UIO driver in kernel to support DPDK Poll Mode Driver.\n\nSigned-off-by: Stas Egorov <segorov@mirantis.com>\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n lib/librte_eal/linuxapp/Makefile            |   3 +\n lib/librte_eal/linuxapp/hv_uio/Makefile     |  57 ++\n lib/librte_eal/linuxapp/hv_uio/hv_uio.c     | 551 +++++++++++++++++\n lib/librte_eal/linuxapp/hv_uio/hyperv_net.h | 907 ++++++++++++++++++++++++++++\n 4 files changed, 1518 insertions(+)\n create mode 100644 lib/librte_eal/linuxapp/hv_uio/Makefile\n create mode 100644 lib/librte_eal/linuxapp/hv_uio/hv_uio.c\n create mode 100644 lib/librte_eal/linuxapp/hv_uio/hyperv_net.h",
    "diff": "diff --git a/lib/librte_eal/linuxapp/Makefile b/lib/librte_eal/linuxapp/Makefile\nindex 8fcfdf6..a28d289 100644\n--- a/lib/librte_eal/linuxapp/Makefile\n+++ b/lib/librte_eal/linuxapp/Makefile\n@@ -41,5 +41,8 @@ endif\n ifeq ($(CONFIG_RTE_LIBRTE_XEN_DOM0),y)\n DIRS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += xen_dom0\n endif\n+ifeq ($(CONFIG_RTE_LIBRTE_HV_PMD),y)\n+DIRS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += hv_uio\n+endif\n \n include $(RTE_SDK)/mk/rte.subdir.mk\ndiff --git a/lib/librte_eal/linuxapp/hv_uio/Makefile b/lib/librte_eal/linuxapp/hv_uio/Makefile\nnew file mode 100644\nindex 0000000..2ed7771\n--- /dev/null\n+++ b/lib/librte_eal/linuxapp/hv_uio/Makefile\n@@ -0,0 +1,57 @@\n+#   BSD LICENSE\n+#\n+#   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.\n+#   Copyright(c) 2013-2015 Brocade Communications Systems, Inc.\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+# module name and path\n+#\n+MODULE = hv_uio\n+MODULE_PATH = drivers/net/hv_uio\n+\n+#\n+# CFLAGS\n+#\n+MODULE_CFLAGS += -I$(SRCDIR) --param max-inline-insns-single=100\n+MODULE_CFLAGS += -I$(RTE_OUTPUT)/include\n+MODULE_CFLAGS += -Winline -Wall -Werror\n+MODULE_CFLAGS += -include $(RTE_OUTPUT)/include/rte_config.h\n+ifeq ($(CONFIG_RTE_LIBRTE_HV_DEBUG),y)\n+MODULE_CFLAGS += -DDBG\n+endif\n+\n+#\n+# all source are stored in SRCS-y\n+#\n+SRCS-y := hv_uio.c\n+\n+include $(RTE_SDK)/mk/rte.module.mk\ndiff --git a/lib/librte_eal/linuxapp/hv_uio/hv_uio.c b/lib/librte_eal/linuxapp/hv_uio/hv_uio.c\nnew file mode 100644\nindex 0000000..4cac075\n--- /dev/null\n+++ b/lib/librte_eal/linuxapp/hv_uio/hv_uio.c\n@@ -0,0 +1,551 @@\n+/*\n+ * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.\n+ *\n+ * This program is free software; you can redistribute it and/or modify it\n+ * under the terms and conditions of the GNU General Public License,\n+ * version 2, as published by the Free Software Foundation.\n+ *\n+ * This program is distributed in the hope it will be useful, but WITHOUT\n+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\n+ * more details.\n+ *\n+ * You should have received a copy of the GNU General Public License along with\n+ * this program; if not, see <http://www.gnu.org/licenses/>.\n+ *\n+ */\n+#define pr_fmt(fmt) KBUILD_MODNAME \": \" fmt\n+\n+#include <linux/device.h>\n+#include <linux/kernel.h>\n+#include <linux/module.h>\n+#include <linux/netdevice.h>\n+#include <linux/if_ether.h>\n+#include <linux/uio_driver.h>\n+#include <linux/slab.h>\n+\n+#include \"hyperv_net.h\"\n+\n+#define HV_DEVICE_ADD    0\n+#define HV_DEVICE_REMOVE 1\n+#define HV_RING_SIZE \t 512\n+\n+static uint mtu = ETH_DATA_LEN;\n+/*\n+ * List of resources to be mapped to uspace\n+ * can be extended up to MAX_UIO_MAPS(5) items\n+ */\n+enum {\n+\tTXRX_RING_MAP,\n+\tINT_PAGE_MAP,\n+\tMON_PAGE_MAP,\n+\tRECV_BUF_MAP\n+};\n+\n+struct hyperv_private_data {\n+\tstruct netvsc_device *net_device;\n+\tstruct uio_info *info;\n+};\n+\n+extern void vmbus_get_monitor_pages(unsigned long *int_page,\n+\t\t\t\t    unsigned long monitor_pages[2]);\n+\n+/* phys addrs of pages in vmbus_connection from hv_vmbus */\n+static long unsigned int_page, monitor_pages[2];\n+\n+static inline int\n+hyperv_uio_find_mem_index(struct uio_info *info, struct vm_area_struct *vma)\n+{\n+\tif (vma->vm_pgoff < MAX_UIO_MAPS) {\n+\t\tif (unlikely(info->mem[vma->vm_pgoff].size == 0))\n+\t\t\treturn -1;\n+\t\treturn (int)vma->vm_pgoff;\n+\t}\n+\treturn -1;\n+}\n+\n+static int\n+hyperv_uio_mmap(struct uio_info *info, struct vm_area_struct *vma)\n+{\n+\tint mi = hyperv_uio_find_mem_index(info, vma);\n+\tif (mi < 0)\n+\t\treturn -EINVAL;\n+\n+\treturn remap_pfn_range(vma,\n+\t\t\tvma->vm_start,\n+\t\t\tvirt_to_phys((void*)info->mem[mi].addr) >> PAGE_SHIFT,\n+\t\t\tvma->vm_end - vma->vm_start,\n+\t\t\tvma->vm_page_prot);\n+}\n+\n+static struct netvsc_device *\n+alloc_net_device(struct hv_device *dev)\n+{\n+\tstruct netvsc_device *net_device;\n+\n+\tnet_device = kzalloc(sizeof(struct netvsc_device), GFP_KERNEL);\n+\tif (!net_device) {\n+\t\tpr_err(\"unable to allocate memory for netvsc_device\\n\");\n+\t\treturn NULL;\n+\t}\n+\n+\tinit_waitqueue_head(&net_device->wait_drain);\n+\tnet_device->start_remove = false;\n+\tnet_device->destroy = false;\n+\tnet_device->dev = dev;\n+\tnet_device->ndev = hv_get_drvdata(dev);\n+\tnet_device->recv_section_cnt = 0;\n+\n+\treturn net_device;\n+}\n+\n+/* Negotiate NVSP protocol version */\n+static int\n+negotiate_nvsp_ver(struct hv_device *dev,\n+\t\t   struct netvsc_device *net_device,\n+\t\t   struct nvsp_message *init_packet,\n+\t\t   u32 nvsp_ver)\n+{\n+\tint ret;\n+\n+\tmemset(init_packet, 0, sizeof(struct nvsp_message));\n+\tinit_packet->hdr.msg_type = NVSP_MSG_TYPE_INIT;\n+\tinit_packet->msg.init_msg.init.min_protocol_ver = nvsp_ver;\n+\tinit_packet->msg.init_msg.init.max_protocol_ver = nvsp_ver;\n+\n+\t/* Send the init request */\n+\tret = vmbus_sendpacket(dev->channel, init_packet,\n+\t\t\t       sizeof(struct nvsp_message),\n+\t\t\t       (unsigned long)init_packet,\n+\t\t\t       VM_PKT_DATA_INBAND,\n+\t\t\t       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);\n+\n+\tif (ret) {\n+\t\tpr_err(\"unable to send nvsp negotiation packet\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\tif (nvsp_ver != NVSP_PROTOCOL_VERSION_2)\n+\t\treturn 0;\n+\n+\t/* NVSPv2 only: Send NDIS config */\n+\tmemset(init_packet, 0, sizeof(struct nvsp_message));\n+\tinit_packet->hdr.msg_type = NVSP_MSG2_TYPE_SEND_NDIS_CONFIG;\n+\tinit_packet->msg.v2_msg.send_ndis_config.mtu = mtu;\n+\tinit_packet->msg.v2_msg.send_ndis_config.capability.ieee8021q = 1;\n+\n+\tret = vmbus_sendpacket(dev->channel, init_packet,\n+\t\t\t       sizeof(struct nvsp_message),\n+\t\t\t       (unsigned long)init_packet,\n+\t\t\t       VM_PKT_DATA_INBAND, 0);\n+\n+\treturn ret;\n+}\n+\n+static int\n+netvsc_destroy_recv_buf(struct netvsc_device *net_device)\n+{\n+\tstruct nvsp_message *revoke_packet;\n+\tint ret = 0;\n+\n+\t/*\n+\t * If we got a section count, it means we received a\n+\t * SendReceiveBufferComplete msg (ie sent\n+\t * NvspMessage1TypeSendReceiveBuffer msg) therefore, we need\n+\t * to send a revoke msg here\n+\t */\n+\tif (net_device->recv_section_cnt) {\n+\t\t/* Send the revoke receive buffer */\n+\t\trevoke_packet = &net_device->revoke_packet;\n+\t\tmemset(revoke_packet, 0, sizeof(struct nvsp_message));\n+\n+\t\trevoke_packet->hdr.msg_type =\n+\t\t\tNVSP_MSG1_TYPE_REVOKE_RECV_BUF;\n+\t\trevoke_packet->msg.v1_msg.\n+\t\trevoke_recv_buf.id = NETVSC_RECEIVE_BUFFER_ID;\n+\n+\t\tret = vmbus_sendpacket(net_device->dev->channel,\n+\t\t\t\t       revoke_packet,\n+\t\t\t\t       sizeof(struct nvsp_message),\n+\t\t\t\t       (unsigned long)revoke_packet,\n+\t\t\t\t       VM_PKT_DATA_INBAND, 0);\n+\t\t/*\n+\t\t * If we failed here, we might as well return and\n+\t\t * have a leak rather than continue and a bugchk\n+\t\t */\n+\t\tif (ret != 0) {\n+\t\t\tpr_err(\"unable to send \"\n+\t\t\t\t\"revoke receive buffer to netvsp\\n\");\n+\t\t\treturn ret;\n+\t\t}\n+\t}\n+\n+\t/* Teardown the gpadl on the vsp end */\n+\tif (net_device->recv_buf_gpadl_handle) {\n+\t\tpr_devel(\"trying to teardown gpadl...\\n\");\n+\t\tret = vmbus_teardown_gpadl(net_device->dev->channel,\n+\t\t\t   net_device->recv_buf_gpadl_handle);\n+\n+\t\tif (ret) {\n+\t\t\tpr_err(\"unable to teardown receive buffer's gpadl\\n\");\n+\t\t\treturn ret;\n+\t\t}\n+\t\tnet_device->recv_buf_gpadl_handle = 0;\n+\t}\n+\n+\tif (net_device->recv_buf) {\n+\t\t/* Free up the receive buffer */\n+\t\tfree_pages((unsigned long)net_device->recv_buf,\n+\t\t\t\tget_order(net_device->recv_buf_size));\n+\t\tnet_device->recv_buf = NULL;\n+\t}\n+\n+\tif (net_device->recv_section) {\n+\t\tnet_device->recv_section_cnt = 0;\n+\t\tkfree(net_device->recv_section);\n+\t\tnet_device->recv_section = NULL;\n+\t}\n+\n+\treturn ret;\n+}\n+\n+static int\n+netvsc_init_recv_buf(struct hv_device *dev, struct netvsc_device *net_dev)\n+{\n+\tint ret = 0;\n+\tstruct nvsp_message *init_packet;\n+\n+\tif (!net_dev)\n+\t\treturn -ENODEV;\n+\n+\tnet_dev->recv_buf = (void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,\n+\t\t\tget_order(net_dev->recv_buf_size));\n+\tif (!net_dev->recv_buf) {\n+\t\tpr_err(\"unable to allocate receive \"\n+\t\t\t\t\"buffer of size %d\\n\", net_dev->recv_buf_size);\n+\t\tret = -ENOMEM;\n+\t\tgoto cleanup;\n+\t}\n+\n+\t/*\n+\t * Establish the gpadl handle for this buffer on this\n+\t * channel.  Note: This call uses the vmbus connection rather\n+\t * than the channel to establish the gpadl handle.\n+\t */\n+\tret = vmbus_establish_gpadl(dev->channel, net_dev->recv_buf,\n+\t\t\t\t    net_dev->recv_buf_size,\n+\t\t\t\t    &net_dev->recv_buf_gpadl_handle);\n+\tif (ret != 0) {\n+\t\tpr_err(\"unable to establish receive buffer's gpadl\\n\");\n+\t\tgoto cleanup;\n+\t}\n+\n+\n+\t/* Notify the NetVsp of the gpadl handle */\n+\tinit_packet = &net_dev->channel_init_pkt;\n+\n+\tmemset(init_packet, 0, sizeof(struct nvsp_message));\n+\n+\tinit_packet->hdr.msg_type = NVSP_MSG1_TYPE_SEND_RECV_BUF;\n+\tinit_packet->msg.v1_msg.send_recv_buf.\n+\t\tgpadl_handle = net_dev->recv_buf_gpadl_handle;\n+\tinit_packet->msg.v1_msg.\n+\t\tsend_recv_buf.id = NETVSC_RECEIVE_BUFFER_ID;\n+\n+\t/* Send the gpadl notification request */\n+\tret = vmbus_sendpacket(dev->channel, init_packet,\n+\t\t\t       sizeof(struct nvsp_message),\n+\t\t\t       (unsigned long)init_packet,\n+\t\t\t       VM_PKT_DATA_INBAND,\n+\t\t\t       VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);\n+\tif (ret != 0) {\n+\t\tpr_err(\"unable to send receive buffer's gpadl to netvsp\\n\");\n+\t\tgoto cleanup;\n+\t}\n+\n+\tnet_dev->recv_section_cnt = 1;\n+\tgoto exit;\n+\n+cleanup:\n+\tnetvsc_destroy_recv_buf(net_dev);\n+\n+exit:\n+\treturn ret;\n+}\n+\n+static int\n+netvsc_connect_vsp(struct hv_device *dev, struct netvsc_device *net_dev)\n+{\n+\tint ret;\n+\tstruct nvsp_message *init_packet;\n+\tint ndis_version;\n+\n+\tif (!net_dev)\n+\t\treturn -ENODEV;\n+\n+\tinit_packet = &net_dev->channel_init_pkt;\n+\n+\t/* Negotiate the latest NVSP protocol supported */\n+\tif (negotiate_nvsp_ver(dev, net_dev, init_packet,\n+\t\t\t       NVSP_PROTOCOL_VERSION_2) == 0) {\n+\t\tnet_dev->nvsp_version = NVSP_PROTOCOL_VERSION_2;\n+\t} else if (negotiate_nvsp_ver(dev, net_dev, init_packet,\n+\t\t\t\t    NVSP_PROTOCOL_VERSION_1) == 0) {\n+\t\tnet_dev->nvsp_version = NVSP_PROTOCOL_VERSION_1;\n+\t} else {\n+\t\treturn -EPROTO;\n+\t}\n+\n+\tpr_devel(\"Negotiated NVSP version:%x\\n\", net_dev->nvsp_version);\n+\n+\t/* Send the ndis version */\n+\tmemset(init_packet, 0, sizeof(struct nvsp_message));\n+\n+\tndis_version = 0x00050001;\n+\n+\tinit_packet->hdr.msg_type = NVSP_MSG1_TYPE_SEND_NDIS_VER;\n+\tinit_packet->msg.v1_msg.\n+\t\tsend_ndis_ver.ndis_major_ver =\n+\t\t\t\t(ndis_version & 0xFFFF0000) >> 16;\n+\tinit_packet->msg.v1_msg.\n+\t\tsend_ndis_ver.ndis_minor_ver =\n+\t\t\t\tndis_version & 0xFFFF;\n+\n+\t/* Send the init request */\n+\tret = vmbus_sendpacket(dev->channel, init_packet,\n+\t\t\t\tsizeof(struct nvsp_message),\n+\t\t\t\t(unsigned long)init_packet,\n+\t\t\t\tVM_PKT_DATA_INBAND, 0);\n+\tif (ret != 0) {\n+\t\tpr_err(\"unable to send init_packet via vmbus\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\t/* Post the big receive buffer to NetVSP */\n+\tret = netvsc_init_recv_buf(dev, net_dev);\n+\n+\treturn ret;\n+}\n+\n+static int\n+hyperv_dev_add(struct hv_device *dev, struct netvsc_device *net_dev)\n+{\n+\tint ret = 0;\n+\n+\tnet_dev->recv_buf_size = NETVSC_RECEIVE_BUFFER_SIZE;\n+\n+\tret = vmbus_open(dev->channel, HV_RING_SIZE * PAGE_SIZE,\n+\t\t\tHV_RING_SIZE * PAGE_SIZE, NULL, 0, NULL, dev);\n+\tif (ret) {\n+\t\tpr_err(\"unable to open channel: %d\\n\", ret);\n+\t\treturn ret;\n+\t}\n+\tdev->channel->inbound.ring_buffer->interrupt_mask = 1;\n+\n+\tret = netvsc_connect_vsp(dev, net_dev);\n+\tif (ret) {\n+\t\tpr_err(\"unable to connect to NetVSP: %d\\n\", ret);\n+\t\tgoto close;\n+\t}\n+\n+\treturn ret;\n+\n+close:\n+\tvmbus_close(dev->channel);\n+\n+\treturn ret;\n+}\n+\n+static void\n+hyperv_dev_remove(struct hv_device *dev, struct netvsc_device *net_dev)\n+{\n+\tif (net_dev->recv_buf) {\n+\t\tnetvsc_destroy_recv_buf(net_dev);\n+\t\tvmbus_close(dev->channel);\n+\t}\n+}\n+\n+#define MAX_HV_DEVICE_NUM 256\n+static struct hv_device *hv_device_list[MAX_HV_DEVICE_NUM];\n+\n+/*\n+ * This callback is set as irqcontrol for uio, it can be used for mtu changing\n+ * The variable arg consists of command, device number(see HV_DEV_ID)\n+ * and value of MTU(see HV_MTU)\n+ */\n+static int\n+hyperv_write_cb(struct uio_info *info, s32 arg)\n+{\n+\tstruct hv_device *dev;\n+\tint ret, cmd = arg & 1, dev_num = (arg >> 1) & 0xFF;\n+\tstruct hyperv_private_data *pdata;\n+\tstruct netvsc_device *net_device;\n+\n+\tdev = hv_device_list[dev_num];\n+\tif (!dev)\n+\t\treturn 0;\n+\tpdata = hv_get_drvdata(dev);\n+\tnet_device = pdata->net_device;\n+\tswitch (cmd) {\n+\tcase HV_DEVICE_ADD:\n+\t\tmtu = arg >> 9;\n+\t\tpr_devel(\"New mtu = %u\\n\", mtu);\n+\t\tret = hyperv_dev_add(dev, net_device);\n+\t\tif (!ret) {\n+\t\t\tinfo->mem[TXRX_RING_MAP].addr =\n+\t\t\t\t(phys_addr_t)(dev->channel->ringbuffer_pages);\n+\t\t\tinfo->mem[RECV_BUF_MAP].addr = (phys_addr_t)(net_device->recv_buf);\n+\t\t\treturn sizeof(s32);\n+\t\t}\n+\t\tbreak;\n+\tcase HV_DEVICE_REMOVE:\n+\t\thyperv_dev_remove(dev, net_device);\n+\t\treturn sizeof(s32);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n+hyperv_probe(struct hv_device *dev,\n+\t\tconst struct hv_vmbus_device_id *dev_id)\n+{\n+\tint ret;\n+\tstruct hyperv_private_data *pdata;\n+\tstruct uio_info *info;\n+\tstruct netvsc_device *net_device;\n+\n+\tpdata = kzalloc(sizeof(struct hyperv_private_data), GFP_KERNEL);\n+\tif (!pdata) {\n+\t\tpr_err(\"Failed to allocate hyperv_private_data\\n\");\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\tinfo = kzalloc(sizeof(struct uio_info), GFP_KERNEL);\n+\tif (!info) {\n+\t\tpr_err(\"Failed to allocate uio_info\\n\");\n+\t\tkfree(pdata);\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\tnet_device = alloc_net_device(dev);\n+\tif (!net_device) {\n+\t\tkfree(pdata);\n+\t\tkfree(info);\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\tret = hyperv_dev_add(dev, net_device);\n+\tif (ret) {\n+\t\tkfree(pdata);\n+\t\tkfree(info);\n+\t\tkfree(net_device);\n+\t\treturn ret;\n+\t}\n+\n+\t/* Fill general uio info */\n+\tinfo->name = \"hv_uio\";\n+\tinfo->version = \"1.0\";\n+\tinfo->irqcontrol = hyperv_write_cb;\n+\tinfo->irq = UIO_IRQ_CUSTOM;\n+\n+\t/* mem resources */\n+\tinfo->mem[TXRX_RING_MAP].name = \"txrx_rings\";\n+\tinfo->mem[TXRX_RING_MAP].addr =\n+\t\t(phys_addr_t)(dev->channel->ringbuffer_pages);\n+\tinfo->mem[TXRX_RING_MAP].size = HV_RING_SIZE * PAGE_SIZE * 2;\n+\tinfo->mem[TXRX_RING_MAP].memtype = UIO_MEM_LOGICAL;\n+\n+\tinfo->mem[INT_PAGE_MAP].name = \"int_page\";\n+\tinfo->mem[INT_PAGE_MAP].addr =\n+\t\t(phys_addr_t)(int_page);\n+\tinfo->mem[INT_PAGE_MAP].size = PAGE_SIZE;\n+\tinfo->mem[INT_PAGE_MAP].memtype = UIO_MEM_LOGICAL;\n+\n+\tinfo->mem[MON_PAGE_MAP].name = \"monitor_pages\";\n+\tinfo->mem[MON_PAGE_MAP].addr =\n+\t\t(phys_addr_t)(monitor_pages[1]);\n+\tinfo->mem[MON_PAGE_MAP].size = PAGE_SIZE;\n+\tinfo->mem[MON_PAGE_MAP].memtype = UIO_MEM_LOGICAL;\n+\n+\tinfo->mem[RECV_BUF_MAP].name = \"recv_buf\";\n+\tinfo->mem[RECV_BUF_MAP].addr = (phys_addr_t)(net_device->recv_buf);\n+\tinfo->mem[RECV_BUF_MAP].size = net_device->recv_buf_size;\n+\tinfo->mem[RECV_BUF_MAP].memtype = UIO_MEM_LOGICAL;\n+\n+\tinfo->mmap = hyperv_uio_mmap;\n+\n+\tpr_devel(\"register hyperv driver for hv_device {%pUl}\\n\", dev->dev_instance.b);\n+\tret = uio_register_device(&dev->device, info);\n+\tif (ret)\n+\t\tpr_err(\"Failed to register uio device for hyperv\\n\");\n+\telse\n+\t\thv_device_list[dev->channel->offermsg.child_relid] = dev;\n+\n+\tpdata->info = info;\n+\tpdata->net_device = net_device;\n+\thv_set_drvdata(dev, pdata);\n+\n+\treturn ret;\n+}\n+\n+static int\n+hyperv_remove(struct hv_device *dev)\n+{\n+\tstruct hyperv_private_data *pdata;\n+\tstruct uio_info *info;\n+\tstruct netvsc_device *net_dev;\n+\n+\tpr_devel(\"unregister hyperv driver for hv_device {%pUl}\\n\",\n+\t       dev->dev_instance.b);\n+\n+\tpdata = hv_get_drvdata(dev);\n+\tinfo = pdata->info;\n+\tuio_unregister_device(info);\n+\tkfree(info);\n+\n+\tnet_dev = pdata->net_device;\n+\thv_set_drvdata(dev, NULL);\n+\n+\thyperv_dev_remove(dev, net_dev);\n+\n+\tkfree(net_dev);\n+\tkfree(pdata);\n+\n+\treturn 0;\n+}\n+\n+static const struct hv_vmbus_device_id hyperv_id_table[] = {\n+\t{ HV_NIC_GUID, },\n+\t{ },\n+};\n+\n+MODULE_DEVICE_TABLE(vmbus, hyperv_id_table);\n+\n+static struct hv_driver hv_uio_drv = {\n+\t.name = KBUILD_MODNAME,\n+\t.id_table = hyperv_id_table,\n+\t.probe = hyperv_probe,\n+\t.remove = hyperv_remove,\n+};\n+\n+static int __init\n+hyperv_module_init(void)\n+{\n+\tvmbus_get_monitor_pages(&int_page, monitor_pages);\n+\n+\treturn vmbus_driver_register(&hv_uio_drv);\n+}\n+\n+static void __exit\n+hyperv_module_exit(void)\n+{\n+\tvmbus_driver_unregister(&hv_uio_drv);\n+}\n+\n+module_init(hyperv_module_init);\n+module_exit(hyperv_module_exit);\n+\n+MODULE_DESCRIPTION(\"UIO driver for Hyper-V netVSC\");\n+MODULE_LICENSE(\"GPL\");\n+MODULE_AUTHOR(\"Brocade\");\ndiff --git a/lib/librte_eal/linuxapp/hv_uio/hyperv_net.h b/lib/librte_eal/linuxapp/hv_uio/hyperv_net.h\nnew file mode 100644\nindex 0000000..8097779\n--- /dev/null\n+++ b/lib/librte_eal/linuxapp/hv_uio/hyperv_net.h\n@@ -0,0 +1,907 @@\n+/*\n+ *\n+ * Copyright (c) 2011, Microsoft Corporation.\n+ * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.\n+ *\n+ * This program is free software; you can redistribute it and/or modify it\n+ * under the terms and conditions of the GNU General Public License,\n+ * version 2, as published by the Free Software Foundation.\n+ *\n+ * This program is distributed in the hope it will be useful, but WITHOUT\n+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\n+ * more details.\n+ *\n+ * You should have received a copy of the GNU General Public License along with\n+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple\n+ * Place - Suite 330, Boston, MA 02111-1307 USA.\n+ *\n+ * Authors:\n+ *   Haiyang Zhang <haiyangz@microsoft.com>\n+ *   Hank Janssen  <hjanssen@microsoft.com>\n+ *   K. Y. Srinivasan <kys@microsoft.com>\n+ *\n+ */\n+\n+#ifndef _HYPERV_NET_H\n+#define _HYPERV_NET_H\n+\n+#include <linux/list.h>\n+#include <linux/hyperv.h>\n+#include <linux/rndis.h>\n+\n+/* Fwd declaration */\n+struct hv_netvsc_packet;\n+\n+/* Represent the xfer page packet which contains 1 or more netvsc packet */\n+struct xferpage_packet {\n+\tstruct list_head list_ent;\n+\tu32 status;\n+\n+\t/* # of netvsc packets this xfer packet contains */\n+\tu32 count;\n+};\n+\n+/*\n+ * Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame\n+ * within the RNDIS\n+ */\n+struct hv_netvsc_packet {\n+\t/* Bookkeeping stuff */\n+\tstruct list_head list_ent;\n+\tu32 status;\n+\n+\tstruct hv_device *device;\n+\tbool is_data_pkt;\n+\tu16 vlan_tci;\n+\n+\t/*\n+\t * Valid only for receives when we break a xfer page packet\n+\t * into multiple netvsc packets\n+\t */\n+\tstruct xferpage_packet *xfer_page_pkt;\n+\n+\tunion {\n+\t\tstruct {\n+\t\t\tu64 recv_completion_tid;\n+\t\t\tvoid *recv_completion_ctx;\n+\t\t\tvoid (*recv_completion)(void *context);\n+\t\t} recv;\n+\t\tstruct {\n+\t\t\tu64 send_completion_tid;\n+\t\t\tvoid *send_completion_ctx;\n+\t\t\tvoid (*send_completion)(void *context);\n+\t\t} send;\n+\t} completion;\n+\n+\t/* This points to the memory after page_buf */\n+\tvoid *extension;\n+\n+\tu32 total_data_buflen;\n+\t/* Points to the send/receive buffer where the ethernet frame is */\n+\tvoid *data;\n+\tu32 page_buf_cnt;\n+\tstruct hv_page_buffer page_buf[0];\n+};\n+\n+struct netvsc_device_info {\n+\tunsigned char mac_adr[ETH_ALEN];\n+\tbool link_state;\t/* 0 - link up, 1 - link down */\n+\tint  ring_size;\n+};\n+\n+enum rndis_device_state {\n+\tRNDIS_DEV_UNINITIALIZED = 0,\n+\tRNDIS_DEV_INITIALIZING,\n+\tRNDIS_DEV_INITIALIZED,\n+\tRNDIS_DEV_DATAINITIALIZED,\n+};\n+\n+struct rndis_device {\n+\tstruct netvsc_device *net_dev;\n+\n+\tenum rndis_device_state state;\n+\tbool link_state;\n+\tatomic_t new_req_id;\n+\n+\tspinlock_t request_lock;\n+\tstruct list_head req_list;\n+\n+\tunsigned char hw_mac_adr[ETH_ALEN];\n+};\n+\n+\n+/* Interface */\n+int netvsc_device_add(struct hv_device *device, void *additional_info);\n+int netvsc_device_remove(struct hv_device *device);\n+int netvsc_send(struct hv_device *device,\n+\t\tstruct hv_netvsc_packet *packet);\n+void netvsc_linkstatus_callback(struct hv_device *device_obj,\n+\t\t\t\tunsigned int status);\n+int netvsc_recv_callback(struct hv_device *device_obj,\n+\t\t\tstruct hv_netvsc_packet *packet);\n+int rndis_filter_open(struct hv_device *dev);\n+int rndis_filter_close(struct hv_device *dev);\n+int rndis_filter_device_add(struct hv_device *dev,\n+\t\t\tvoid *additional_info);\n+void rndis_filter_device_remove(struct hv_device *dev);\n+int rndis_filter_receive(struct hv_device *dev,\n+\t\t\tstruct hv_netvsc_packet *pkt);\n+\n+\n+\n+int rndis_filter_send(struct hv_device *dev,\n+\t\t\tstruct hv_netvsc_packet *pkt);\n+\n+int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter);\n+int rndis_filter_set_device_mac(struct hv_device *hdev, char *mac);\n+\n+\n+#define NVSP_INVALID_PROTOCOL_VERSION\t((u32)0xFFFFFFFF)\n+\n+#define NVSP_PROTOCOL_VERSION_1\t\t2\n+#define NVSP_PROTOCOL_VERSION_2\t\t0x30002\n+\n+enum {\n+\tNVSP_MSG_TYPE_NONE = 0,\n+\n+\t/* Init Messages */\n+\tNVSP_MSG_TYPE_INIT\t\t\t= 1,\n+\tNVSP_MSG_TYPE_INIT_COMPLETE\t\t= 2,\n+\n+\tNVSP_VERSION_MSG_START\t\t\t= 100,\n+\n+\t/* Version 1 Messages */\n+\tNVSP_MSG1_TYPE_SEND_NDIS_VER\t\t= NVSP_VERSION_MSG_START,\n+\n+\tNVSP_MSG1_TYPE_SEND_RECV_BUF,\n+\tNVSP_MSG1_TYPE_SEND_RECV_BUF_COMPLETE,\n+\tNVSP_MSG1_TYPE_REVOKE_RECV_BUF,\n+\n+\tNVSP_MSG1_TYPE_SEND_SEND_BUF,\n+\tNVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE,\n+\tNVSP_MSG1_TYPE_REVOKE_SEND_BUF,\n+\n+\tNVSP_MSG1_TYPE_SEND_RNDIS_PKT,\n+\tNVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE,\n+\n+\t/* Version 2 messages */\n+\tNVSP_MSG2_TYPE_SEND_CHIMNEY_DELEGATED_BUF,\n+\tNVSP_MSG2_TYPE_SEND_CHIMNEY_DELEGATED_BUF_COMP,\n+\tNVSP_MSG2_TYPE_REVOKE_CHIMNEY_DELEGATED_BUF,\n+\n+\tNVSP_MSG2_TYPE_RESUME_CHIMNEY_RX_INDICATION,\n+\n+\tNVSP_MSG2_TYPE_TERMINATE_CHIMNEY,\n+\tNVSP_MSG2_TYPE_TERMINATE_CHIMNEY_COMP,\n+\n+\tNVSP_MSG2_TYPE_INDICATE_CHIMNEY_EVENT,\n+\n+\tNVSP_MSG2_TYPE_SEND_CHIMNEY_PKT,\n+\tNVSP_MSG2_TYPE_SEND_CHIMNEY_PKT_COMP,\n+\n+\tNVSP_MSG2_TYPE_POST_CHIMNEY_RECV_REQ,\n+\tNVSP_MSG2_TYPE_POST_CHIMNEY_RECV_REQ_COMP,\n+\n+\tNVSP_MSG2_TYPE_ALLOC_RXBUF,\n+\tNVSP_MSG2_TYPE_ALLOC_RXBUF_COMP,\n+\n+\tNVSP_MSG2_TYPE_FREE_RXBUF,\n+\n+\tNVSP_MSG2_TYPE_SEND_VMQ_RNDIS_PKT,\n+\tNVSP_MSG2_TYPE_SEND_VMQ_RNDIS_PKT_COMP,\n+\n+\tNVSP_MSG2_TYPE_SEND_NDIS_CONFIG,\n+\n+\tNVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE,\n+\tNVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE_COMP,\n+};\n+\n+enum {\n+\tNVSP_STAT_NONE = 0,\n+\tNVSP_STAT_SUCCESS,\n+\tNVSP_STAT_FAIL,\n+\tNVSP_STAT_PROTOCOL_TOO_NEW,\n+\tNVSP_STAT_PROTOCOL_TOO_OLD,\n+\tNVSP_STAT_INVALID_RNDIS_PKT,\n+\tNVSP_STAT_BUSY,\n+\tNVSP_STAT_PROTOCOL_UNSUPPORTED,\n+\tNVSP_STAT_MAX,\n+};\n+\n+struct nvsp_message_header {\n+\tu32 msg_type;\n+};\n+\n+/* Init Messages */\n+\n+/*\n+ * This message is used by the VSC to initialize the channel after the channels\n+ * has been opened. This message should never include anything other then\n+ * versioning (i.e. this message will be the same for ever).\n+ */\n+struct nvsp_message_init {\n+\tu32 min_protocol_ver;\n+\tu32 max_protocol_ver;\n+} __packed;\n+\n+/*\n+ * This message is used by the VSP to complete the initialization of the\n+ * channel. This message should never include anything other then versioning\n+ * (i.e. this message will be the same for ever).\n+ */\n+struct nvsp_message_init_complete {\n+\tu32 negotiated_protocol_ver;\n+\tu32 max_mdl_chain_len;\n+\tu32 status;\n+} __packed;\n+\n+union nvsp_message_init_uber {\n+\tstruct nvsp_message_init init;\n+\tstruct nvsp_message_init_complete init_complete;\n+} __packed;\n+\n+/* Version 1 Messages */\n+\n+/*\n+ * This message is used by the VSC to send the NDIS version to the VSP. The VSP\n+ * can use this information when handling OIDs sent by the VSC.\n+ */\n+struct nvsp_1_message_send_ndis_version {\n+\tu32 ndis_major_ver;\n+\tu32 ndis_minor_ver;\n+} __packed;\n+\n+/*\n+ * This message is used by the VSC to send a receive buffer to the VSP. The VSP\n+ * can then use the receive buffer to send data to the VSC.\n+ */\n+struct nvsp_1_message_send_receive_buffer {\n+\tu32 gpadl_handle;\n+\tu16 id;\n+} __packed;\n+\n+struct nvsp_1_receive_buffer_section {\n+\tu32 offset;\n+\tu32 sub_alloc_size;\n+\tu32 num_sub_allocs;\n+\tu32 end_offset;\n+} __packed;\n+\n+/*\n+ * This message is used by the VSP to acknowledge a receive buffer send by the\n+ * VSC. This message must be sent by the VSP before the VSP uses the receive\n+ * buffer.\n+ */\n+struct nvsp_1_message_send_receive_buffer_complete {\n+\tu32 status;\n+\tu32 num_sections;\n+\n+\t/*\n+\t * The receive buffer is split into two parts, a large suballocation\n+\t * section and a small suballocation section. These sections are then\n+\t * suballocated by a certain size.\n+\t */\n+\n+\t/*\n+\t * For example, the following break up of the receive buffer has 6\n+\t * large suballocations and 10 small suballocations.\n+\t */\n+\n+\t/*\n+\t * |            Large Section          |  |   Small Section   |\n+\t * ------------------------------------------------------------\n+\t * |     |     |     |     |     |     |  | | | | | | | | | | |\n+\t * |                                      |\n+\t *  LargeOffset                            SmallOffset\n+\t */\n+\n+\tstruct nvsp_1_receive_buffer_section sections[1];\n+} __packed;\n+\n+/*\n+ * This message is sent by the VSC to revoke the receive buffer.  After the VSP\n+ * completes this transaction, the vsp should never use the receive buffer\n+ * again.\n+ */\n+struct nvsp_1_message_revoke_receive_buffer {\n+\tu16 id;\n+};\n+\n+/*\n+ * This message is used by the VSC to send a send buffer to the VSP. The VSC\n+ * can then use the send buffer to send data to the VSP.\n+ */\n+struct nvsp_1_message_send_send_buffer {\n+\tu32 gpadl_handle;\n+\tu16 id;\n+} __packed;\n+\n+/*\n+ * This message is used by the VSP to acknowledge a send buffer sent by the\n+ * VSC. This message must be sent by the VSP before the VSP uses the sent\n+ * buffer.\n+ */\n+struct nvsp_1_message_send_send_buffer_complete {\n+\tu32 status;\n+\n+\t/*\n+\t * The VSC gets to choose the size of the send buffer and the VSP gets\n+\t * to choose the sections size of the buffer.  This was done to enable\n+\t * dynamic reconfigurations when the cost of GPA-direct buffers\n+\t * decreases.\n+\t */\n+\tu32 section_size;\n+} __packed;\n+\n+/*\n+ * This message is sent by the VSC to revoke the send buffer.  After the VSP\n+ * completes this transaction, the vsp should never use the send buffer again.\n+ */\n+struct nvsp_1_message_revoke_send_buffer {\n+\tu16 id;\n+};\n+\n+/*\n+ * This message is used by both the VSP and the VSC to send a RNDIS message to\n+ * the opposite channel endpoint.\n+ */\n+struct nvsp_1_message_send_rndis_packet {\n+\t/*\n+\t * This field is specified by RNIDS. They assume there's two different\n+\t * channels of communication. However, the Network VSP only has one.\n+\t * Therefore, the channel travels with the RNDIS packet.\n+\t */\n+\tu32 channel_type;\n+\n+\t/*\n+\t * This field is used to send part or all of the data through a send\n+\t * buffer. This values specifies an index into the send buffer. If the\n+\t * index is 0xFFFFFFFF, then the send buffer is not being used and all\n+\t * of the data was sent through other VMBus mechanisms.\n+\t */\n+\tu32 send_buf_section_index;\n+\tu32 send_buf_section_size;\n+} __packed;\n+\n+/*\n+ * This message is used by both the VSP and the VSC to complete a RNDIS message\n+ * to the opposite channel endpoint. At this point, the initiator of this\n+ * message cannot use any resources associated with the original RNDIS packet.\n+ */\n+struct nvsp_1_message_send_rndis_packet_complete {\n+\tu32 status;\n+};\n+\n+union nvsp_1_message_uber {\n+\tstruct nvsp_1_message_send_ndis_version send_ndis_ver;\n+\n+\tstruct nvsp_1_message_send_receive_buffer send_recv_buf;\n+\tstruct nvsp_1_message_send_receive_buffer_complete\n+\t\t\t\t\t\tsend_recv_buf_complete;\n+\tstruct nvsp_1_message_revoke_receive_buffer revoke_recv_buf;\n+\n+\tstruct nvsp_1_message_send_send_buffer send_send_buf;\n+\tstruct nvsp_1_message_send_send_buffer_complete send_send_buf_complete;\n+\tstruct nvsp_1_message_revoke_send_buffer revoke_send_buf;\n+\n+\tstruct nvsp_1_message_send_rndis_packet send_rndis_pkt;\n+\tstruct nvsp_1_message_send_rndis_packet_complete\n+\t\t\t\t\t\tsend_rndis_pkt_complete;\n+} __packed;\n+\n+\n+/*\n+ * Network VSP protocol version 2 messages:\n+ */\n+struct nvsp_2_vsc_capability {\n+\tunion {\n+\t\tu64 data;\n+\t\tstruct {\n+\t\t\tu64 vmq:1;\n+\t\t\tu64 chimney:1;\n+\t\t\tu64 sriov:1;\n+\t\t\tu64 ieee8021q:1;\n+\t\t\tu64 correlation_id:1;\n+\t\t};\n+\t};\n+} __packed;\n+\n+struct nvsp_2_send_ndis_config {\n+\tu32 mtu;\n+\tu32 reserved;\n+\tstruct nvsp_2_vsc_capability capability;\n+} __packed;\n+\n+/* Allocate receive buffer */\n+struct nvsp_2_alloc_rxbuf {\n+\t/* Allocation ID to match the allocation request and response */\n+\tu32 alloc_id;\n+\n+\t/* Length of the VM shared memory receive buffer that needs to\n+\t * be allocated\n+\t */\n+\tu32 len;\n+} __packed;\n+\n+/* Allocate receive buffer complete */\n+struct nvsp_2_alloc_rxbuf_comp {\n+\t/* The NDIS_STATUS code for buffer allocation */\n+\tu32 status;\n+\n+\tu32 alloc_id;\n+\n+\t/* GPADL handle for the allocated receive buffer */\n+\tu32 gpadl_handle;\n+\n+\t/* Receive buffer ID */\n+\tu64 recv_buf_id;\n+} __packed;\n+\n+struct nvsp_2_free_rxbuf {\n+\tu64 recv_buf_id;\n+} __packed;\n+\n+union nvsp_2_message_uber {\n+\tstruct nvsp_2_send_ndis_config send_ndis_config;\n+\tstruct nvsp_2_alloc_rxbuf alloc_rxbuf;\n+\tstruct nvsp_2_alloc_rxbuf_comp alloc_rxbuf_comp;\n+\tstruct nvsp_2_free_rxbuf free_rxbuf;\n+} __packed;\n+\n+union nvsp_all_messages {\n+\tunion nvsp_message_init_uber init_msg;\n+\tunion nvsp_1_message_uber v1_msg;\n+\tunion nvsp_2_message_uber v2_msg;\n+} __packed;\n+\n+/* ALL Messages */\n+struct nvsp_message {\n+\tstruct nvsp_message_header hdr;\n+\tunion nvsp_all_messages msg;\n+} __packed;\n+\n+\n+#define NETVSC_MTU 65536\n+\n+#define NETVSC_RECEIVE_BUFFER_SIZE (MAX_ORDER_NR_PAGES * PAGE_SIZE)\n+\n+#define NETVSC_RECEIVE_BUFFER_ID\t\t0xcafe\n+\n+/* Per netvsc channel-specific */\n+struct netvsc_device {\n+\tstruct hv_device *dev;\n+\n+\tu32 nvsp_version;\n+\n+\tatomic_t num_outstanding_sends;\n+\twait_queue_head_t wait_drain;\n+\tbool start_remove;\n+\tbool destroy;\n+\t/*\n+\t * List of free preallocated hv_netvsc_packet to represent receive\n+\t * packet\n+\t */\n+\tstruct list_head recv_pkt_list;\n+\tspinlock_t recv_pkt_list_lock;\n+\n+\t/* Receive buffer allocated by us but manages by NetVSP */\n+\tvoid *recv_buf;\n+\tu32 recv_buf_size;\n+\tu32 recv_buf_gpadl_handle;\n+\tu32 recv_section_cnt;\n+\tstruct nvsp_1_receive_buffer_section *recv_section;\n+\n+\t/* Used for NetVSP initialization protocol */\n+\tstruct completion channel_init_wait;\n+\tstruct nvsp_message channel_init_pkt;\n+\n+\tstruct nvsp_message revoke_packet;\n+\t/* unsigned char HwMacAddr[HW_MACADDR_LEN]; */\n+\n+\tstruct net_device *ndev;\n+\n+\t/* Holds rndis device info */\n+\tvoid *extension;\n+};\n+\n+/* NdisInitialize message */\n+struct rndis_initialize_request {\n+\tu32 req_id;\n+\tu32 major_ver;\n+\tu32 minor_ver;\n+\tu32 max_xfer_size;\n+};\n+\n+/* Response to NdisInitialize */\n+struct rndis_initialize_complete {\n+\tu32 req_id;\n+\tu32 status;\n+\tu32 major_ver;\n+\tu32 minor_ver;\n+\tu32 dev_flags;\n+\tu32 medium;\n+\tu32 max_pkt_per_msg;\n+\tu32 max_xfer_size;\n+\tu32 pkt_alignment_factor;\n+\tu32 af_list_offset;\n+\tu32 af_list_size;\n+};\n+\n+/* Call manager devices only: Information about an address family */\n+/* supported by the device is appended to the response to NdisInitialize. */\n+struct rndis_co_address_family {\n+\tu32 address_family;\n+\tu32 major_ver;\n+\tu32 minor_ver;\n+};\n+\n+/* NdisHalt message */\n+struct rndis_halt_request {\n+\tu32 req_id;\n+};\n+\n+/* NdisQueryRequest message */\n+struct rndis_query_request {\n+\tu32 req_id;\n+\tu32 oid;\n+\tu32 info_buflen;\n+\tu32 info_buf_offset;\n+\tu32 dev_vc_handle;\n+};\n+\n+/* Response to NdisQueryRequest */\n+struct rndis_query_complete {\n+\tu32 req_id;\n+\tu32 status;\n+\tu32 info_buflen;\n+\tu32 info_buf_offset;\n+};\n+\n+/* NdisSetRequest message */\n+struct rndis_set_request {\n+\tu32 req_id;\n+\tu32 oid;\n+\tu32 info_buflen;\n+\tu32 info_buf_offset;\n+\tu32 dev_vc_handle;\n+};\n+\n+/* Response to NdisSetRequest */\n+struct rndis_set_complete {\n+\tu32 req_id;\n+\tu32 status;\n+};\n+\n+/* NdisReset message */\n+struct rndis_reset_request {\n+\tu32 reserved;\n+};\n+\n+/* Response to NdisReset */\n+struct rndis_reset_complete {\n+\tu32 status;\n+\tu32 addressing_reset;\n+};\n+\n+/* NdisMIndicateStatus message */\n+struct rndis_indicate_status {\n+\tu32 status;\n+\tu32 status_buflen;\n+\tu32 status_buf_offset;\n+};\n+\n+/* Diagnostic information passed as the status buffer in */\n+/* struct rndis_indicate_status messages signifying error conditions. */\n+struct rndis_diagnostic_info {\n+\tu32 diag_status;\n+\tu32 error_offset;\n+};\n+\n+/* NdisKeepAlive message */\n+struct rndis_keepalive_request {\n+\tu32 req_id;\n+};\n+\n+/* Response to NdisKeepAlive */\n+struct rndis_keepalive_complete {\n+\tu32 req_id;\n+\tu32 status;\n+};\n+\n+/*\n+ * Data message. All Offset fields contain byte offsets from the beginning of\n+ * struct rndis_packet. All Length fields are in bytes.  VcHandle is set\n+ * to 0 for connectionless data, otherwise it contains the VC handle.\n+ */\n+struct rndis_packet {\n+\tu32 data_offset;\n+\tu32 data_len;\n+\tu32 oob_data_offset;\n+\tu32 oob_data_len;\n+\tu32 num_oob_data_elements;\n+\tu32 per_pkt_info_offset;\n+\tu32 per_pkt_info_len;\n+\tu32 vc_handle;\n+\tu32 reserved;\n+};\n+\n+/* Optional Out of Band data associated with a Data message. */\n+struct rndis_oobd {\n+\tu32 size;\n+\tu32 type;\n+\tu32 class_info_offset;\n+};\n+\n+/* Packet extension field contents associated with a Data message. */\n+struct rndis_per_packet_info {\n+\tu32 size;\n+\tu32 type;\n+\tu32 ppi_offset;\n+};\n+\n+enum ndis_per_pkt_info_type {\n+\tTCPIP_CHKSUM_PKTINFO,\n+\tIPSEC_PKTINFO,\n+\tTCP_LARGESEND_PKTINFO,\n+\tCLASSIFICATION_HANDLE_PKTINFO,\n+\tNDIS_RESERVED,\n+\tSG_LIST_PKTINFO,\n+\tIEEE_8021Q_INFO,\n+\tORIGINAL_PKTINFO,\n+\tPACKET_CANCEL_ID,\n+\tORIGINAL_NET_BUFLIST,\n+\tCACHED_NET_BUFLIST,\n+\tSHORT_PKT_PADINFO,\n+\tMAX_PER_PKT_INFO\n+};\n+\n+struct ndis_pkt_8021q_info {\n+\tunion {\n+\t\tstruct {\n+\t\t\tu32 pri:3; /* User Priority */\n+\t\t\tu32 cfi:1; /* Canonical Format ID */\n+\t\t\tu32 vlanid:12; /* VLAN ID */\n+\t\t\tu32 reserved:16;\n+\t\t};\n+\t\tu32 value;\n+\t};\n+};\n+\n+#define NDIS_VLAN_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \\\n+\t\tsizeof(struct ndis_pkt_8021q_info))\n+\n+/* Format of Information buffer passed in a SetRequest for the OID */\n+/* OID_GEN_RNDIS_CONFIG_PARAMETER. */\n+struct rndis_config_parameter_info {\n+\tu32 parameter_name_offset;\n+\tu32 parameter_name_length;\n+\tu32 parameter_type;\n+\tu32 parameter_value_offset;\n+\tu32 parameter_value_length;\n+};\n+\n+/* Values for ParameterType in struct rndis_config_parameter_info */\n+#define RNDIS_CONFIG_PARAM_TYPE_INTEGER     0\n+#define RNDIS_CONFIG_PARAM_TYPE_STRING      2\n+\n+/* CONDIS Miniport messages for connection oriented devices */\n+/* that do not implement a call manager. */\n+\n+/* CoNdisMiniportCreateVc message */\n+struct rcondis_mp_create_vc {\n+\tu32 req_id;\n+\tu32 ndis_vc_handle;\n+};\n+\n+/* Response to CoNdisMiniportCreateVc */\n+struct rcondis_mp_create_vc_complete {\n+\tu32 req_id;\n+\tu32 dev_vc_handle;\n+\tu32 status;\n+};\n+\n+/* CoNdisMiniportDeleteVc message */\n+struct rcondis_mp_delete_vc {\n+\tu32 req_id;\n+\tu32 dev_vc_handle;\n+};\n+\n+/* Response to CoNdisMiniportDeleteVc */\n+struct rcondis_mp_delete_vc_complete {\n+\tu32 req_id;\n+\tu32 status;\n+};\n+\n+/* CoNdisMiniportQueryRequest message */\n+struct rcondis_mp_query_request {\n+\tu32 req_id;\n+\tu32 request_type;\n+\tu32 oid;\n+\tu32 dev_vc_handle;\n+\tu32 info_buflen;\n+\tu32 info_buf_offset;\n+};\n+\n+/* CoNdisMiniportSetRequest message */\n+struct rcondis_mp_set_request {\n+\tu32 req_id;\n+\tu32 request_type;\n+\tu32 oid;\n+\tu32 dev_vc_handle;\n+\tu32 info_buflen;\n+\tu32 info_buf_offset;\n+};\n+\n+/* CoNdisIndicateStatus message */\n+struct rcondis_indicate_status {\n+\tu32 ndis_vc_handle;\n+\tu32 status;\n+\tu32 status_buflen;\n+\tu32 status_buf_offset;\n+};\n+\n+/* CONDIS Call/VC parameters */\n+struct rcondis_specific_parameters {\n+\tu32 parameter_type;\n+\tu32 parameter_length;\n+\tu32 parameter_lffset;\n+};\n+\n+struct rcondis_media_parameters {\n+\tu32 flags;\n+\tu32 reserved1;\n+\tu32 reserved2;\n+\tstruct rcondis_specific_parameters media_specific;\n+};\n+\n+struct rndis_flowspec {\n+\tu32 token_rate;\n+\tu32 token_bucket_size;\n+\tu32 peak_bandwidth;\n+\tu32 latency;\n+\tu32 delay_variation;\n+\tu32 service_type;\n+\tu32 max_sdu_size;\n+\tu32 minimum_policed_size;\n+};\n+\n+struct rcondis_call_manager_parameters {\n+\tstruct rndis_flowspec transmit;\n+\tstruct rndis_flowspec receive;\n+\tstruct rcondis_specific_parameters call_mgr_specific;\n+};\n+\n+/* CoNdisMiniportActivateVc message */\n+struct rcondis_mp_activate_vc_request {\n+\tu32 req_id;\n+\tu32 flags;\n+\tu32 dev_vc_handle;\n+\tu32 media_params_offset;\n+\tu32 media_params_length;\n+\tu32 call_mgr_params_offset;\n+\tu32 call_mgr_params_length;\n+};\n+\n+/* Response to CoNdisMiniportActivateVc */\n+struct rcondis_mp_activate_vc_complete {\n+\tu32 req_id;\n+\tu32 status;\n+};\n+\n+/* CoNdisMiniportDeactivateVc message */\n+struct rcondis_mp_deactivate_vc_request {\n+\tu32 req_id;\n+\tu32 flags;\n+\tu32 dev_vc_handle;\n+};\n+\n+/* Response to CoNdisMiniportDeactivateVc */\n+struct rcondis_mp_deactivate_vc_complete {\n+\tu32 req_id;\n+\tu32 status;\n+};\n+\n+\n+/* union with all of the RNDIS messages */\n+union rndis_message_container {\n+\tstruct rndis_packet pkt;\n+\tstruct rndis_initialize_request init_req;\n+\tstruct rndis_halt_request halt_req;\n+\tstruct rndis_query_request query_req;\n+\tstruct rndis_set_request set_req;\n+\tstruct rndis_reset_request reset_req;\n+\tstruct rndis_keepalive_request keep_alive_req;\n+\tstruct rndis_indicate_status indicate_status;\n+\tstruct rndis_initialize_complete init_complete;\n+\tstruct rndis_query_complete query_complete;\n+\tstruct rndis_set_complete set_complete;\n+\tstruct rndis_reset_complete reset_complete;\n+\tstruct rndis_keepalive_complete keep_alive_complete;\n+\tstruct rcondis_mp_create_vc co_miniport_create_vc;\n+\tstruct rcondis_mp_delete_vc co_miniport_delete_vc;\n+\tstruct rcondis_indicate_status co_indicate_status;\n+\tstruct rcondis_mp_activate_vc_request co_miniport_activate_vc;\n+\tstruct rcondis_mp_deactivate_vc_request co_miniport_deactivate_vc;\n+\tstruct rcondis_mp_create_vc_complete co_miniport_create_vc_complete;\n+\tstruct rcondis_mp_delete_vc_complete co_miniport_delete_vc_complete;\n+\tstruct rcondis_mp_activate_vc_complete co_miniport_activate_vc_complete;\n+\tstruct rcondis_mp_deactivate_vc_complete\n+\t\tco_miniport_deactivate_vc_complete;\n+};\n+\n+/* Remote NDIS message format */\n+struct rndis_message {\n+\tu32 ndis_msg_type;\n+\n+\t/* Total length of this message, from the beginning */\n+\t/* of the sruct rndis_message, in bytes. */\n+\tu32 msg_len;\n+\n+\t/* Actual message */\n+\tunion rndis_message_container msg;\n+};\n+\n+\n+struct rndis_filter_packet {\n+\tvoid *completion_ctx;\n+\tvoid (*completion)(void *context);\n+\tstruct rndis_message msg;\n+};\n+\n+/* Handy macros */\n+\n+/* get the size of an RNDIS message. Pass in the message type, */\n+/* struct rndis_set_request, struct rndis_packet for example */\n+#define RNDIS_MESSAGE_SIZE(msg)\t\t\t\t\\\n+\t(sizeof(msg) + (sizeof(struct rndis_message) -\t\\\n+\t sizeof(union rndis_message_container)))\n+\n+/* get pointer to info buffer with message pointer */\n+#define MESSAGE_TO_INFO_BUFFER(msg)\t\t\t\t\\\n+\t(((unsigned char *)(msg)) + msg->info_buf_offset)\n+\n+/* get pointer to status buffer with message pointer */\n+#define MESSAGE_TO_STATUS_BUFFER(msg)\t\t\t\\\n+\t(((unsigned char *)(msg)) + msg->status_buf_offset)\n+\n+/* get pointer to OOBD buffer with message pointer */\n+#define MESSAGE_TO_OOBD_BUFFER(msg)\t\t\t\t\\\n+\t(((unsigned char *)(msg)) + msg->oob_data_offset)\n+\n+/* get pointer to data buffer with message pointer */\n+#define MESSAGE_TO_DATA_BUFFER(msg)\t\t\t\t\\\n+\t(((unsigned char *)(msg)) + msg->per_pkt_info_offset)\n+\n+/* get pointer to contained message from NDIS_MESSAGE pointer */\n+#define RNDIS_MESSAGE_PTR_TO_MESSAGE_PTR(rndis_msg)\t\t\\\n+\t((void *) &rndis_msg->msg)\n+\n+/* get pointer to contained message from NDIS_MESSAGE pointer */\n+#define RNDIS_MESSAGE_RAW_PTR_TO_MESSAGE_PTR(rndis_msg)\t\\\n+\t((void *) rndis_msg)\n+\n+\n+#define __struct_bcount(x)\n+\n+\n+\n+#define RNDIS_HEADER_SIZE\t(sizeof(struct rndis_message) - \\\n+\t\t\t\t sizeof(union rndis_message_container))\n+\n+#define NDIS_PACKET_TYPE_DIRECTED\t0x00000001\n+#define NDIS_PACKET_TYPE_MULTICAST\t0x00000002\n+#define NDIS_PACKET_TYPE_ALL_MULTICAST\t0x00000004\n+#define NDIS_PACKET_TYPE_BROADCAST\t0x00000008\n+#define NDIS_PACKET_TYPE_SOURCE_ROUTING\t0x00000010\n+#define NDIS_PACKET_TYPE_PROMISCUOUS\t0x00000020\n+#define NDIS_PACKET_TYPE_SMT\t\t0x00000040\n+#define NDIS_PACKET_TYPE_ALL_LOCAL\t0x00000080\n+#define NDIS_PACKET_TYPE_GROUP\t\t0x00000100\n+#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL\t0x00000200\n+#define NDIS_PACKET_TYPE_FUNCTIONAL\t0x00000400\n+#define NDIS_PACKET_TYPE_MAC_FRAME\t0x00000800\n+\n+\n+\n+#endif /* _HYPERV_NET_H */\n",
    "prefixes": [
        "dpdk-dev",
        "4/7"
    ]
}