get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 87306,
    "url": "https://patches.dpdk.org/api/patches/87306/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20210126101639.250481-19-maxime.coquelin@redhat.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": "<20210126101639.250481-19-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210126101639.250481-19-maxime.coquelin@redhat.com",
    "date": "2021-01-26T10:16:13",
    "name": "[v4,18/44] net/virtio: introduce generic virtio header",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "8432084792418ea0d959bccb6aafda94e29f28b8",
    "submitter": {
        "id": 512,
        "url": "https://patches.dpdk.org/api/people/512/?format=api",
        "name": "Maxime Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "delegate": {
        "id": 2642,
        "url": "https://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20210126101639.250481-19-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 14950,
            "url": "https://patches.dpdk.org/api/series/14950/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=14950",
            "date": "2021-01-26T10:15:55",
            "name": "net/virtio: Virtio PMD rework",
            "version": 4,
            "mbox": "https://patches.dpdk.org/series/14950/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/87306/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/87306/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 08A50A052A;\n\tTue, 26 Jan 2021 11:19:51 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 870DE141388;\n\tTue, 26 Jan 2021 11:17:44 +0100 (CET)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [216.205.24.124])\n by mails.dpdk.org (Postfix) with ESMTP id 071D714137F\n for <dev@dpdk.org>; Tue, 26 Jan 2021 11:17:41 +0100 (CET)",
            "from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com\n [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id\n us-mta-325-J-3UOZnQPs-NELHcLNYV_A-1; Tue, 26 Jan 2021 05:17:39 -0500",
            "from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com\n [10.5.11.11])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 12C4F835BA7;\n Tue, 26 Jan 2021 10:17:38 +0000 (UTC)",
            "from max-t490s.redhat.com (unknown [10.36.110.31])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 646666F45C;\n Tue, 26 Jan 2021 10:17:36 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1611656261;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=ghCvdKiNvpn5dYzAlIE8xKufIEkxYpTSUsqh7jF/FJg=;\n b=ZIm/jAO/tdYr6C3ofvD79PPvNTNeUOEIRoI0a/RitWSunMR3HuQ5qLiaAjFXdTw+jhW0Dw\n pb0vireQQXrVEMIOqW6/+i0h1Th/VpA4EkUePS1yaq6+ikGxm4seFrZaL9SOxvunK57vK0\n s+u+kVy/OnPtPDskucFVXDCzcGYv7r0=",
        "X-MC-Unique": "J-3UOZnQPs-NELHcLNYV_A-1",
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "dev@dpdk.org, chenbo.xia@intel.com, olivier.matz@6wind.com,\n amorenoz@redhat.com, david.marchand@redhat.com",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "Date": "Tue, 26 Jan 2021 11:16:13 +0100",
        "Message-Id": "<20210126101639.250481-19-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20210126101639.250481-1-maxime.coquelin@redhat.com>",
        "References": "<20210126101639.250481-1-maxime.coquelin@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.11",
        "Authentication-Results": "relay.mimecast.com;\n auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"",
        "Subject": "[dpdk-dev] [PATCH v4 18/44] net/virtio: introduce generic virtio\n header",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This patch moves virtio_hw and virtio callbacks into\na generic virtio header, now that they have been\ncurated from PCI references.\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\nReviewed-by: Chenbo Xia <chenbo.xia@intel.com>\n---\n drivers/net/virtio/virtio.h             | 74 ++++++++++++++++++++++\n drivers/net/virtio/virtio_ethdev.c      | 32 +++++-----\n drivers/net/virtio/virtio_pci.c         | 28 ++++-----\n drivers/net/virtio/virtio_pci.h         | 84 ++-----------------------\n drivers/net/virtio/virtio_pci_ethdev.c  |  5 +-\n drivers/net/virtio/virtio_user_ethdev.c |  8 +--\n drivers/net/virtio/virtqueue.h          |  2 +-\n 7 files changed, 116 insertions(+), 117 deletions(-)\n create mode 100644 drivers/net/virtio/virtio.h",
    "diff": "diff --git a/drivers/net/virtio/virtio.h b/drivers/net/virtio/virtio.h\nnew file mode 100644\nindex 0000000000..e55e3329f9\n--- /dev/null\n+++ b/drivers/net/virtio/virtio.h\n@@ -0,0 +1,74 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2010-2014 Intel Corporation\n+ * Copyright(c) 2021 Red Hat, Inc.\n+ */\n+\n+#ifndef _VIRTIO_H_\n+#define _VIRTIO_H_\n+\n+#include <rte_ether.h>\n+\n+struct virtio_hw {\n+\tstruct virtqueue **vqs;\n+\tuint64_t guest_features;\n+\tuint16_t vtnet_hdr_size;\n+\tuint8_t started;\n+\tuint8_t weak_barriers;\n+\tuint8_t vlan_strip;\n+\tuint8_t has_tx_offload;\n+\tuint8_t has_rx_offload;\n+\tuint8_t use_vec_rx;\n+\tuint8_t use_vec_tx;\n+\tuint8_t use_inorder_rx;\n+\tuint8_t use_inorder_tx;\n+\tuint8_t opened;\n+\tuint16_t port_id;\n+\tuint8_t mac_addr[RTE_ETHER_ADDR_LEN];\n+\tuint32_t speed;  /* link speed in MB */\n+\tuint8_t duplex;\n+\tuint8_t use_msix;\n+\tuint16_t max_mtu;\n+\t/*\n+\t * App management thread and virtio interrupt handler thread\n+\t * both can change device state, this lock is meant to avoid\n+\t * such a contention.\n+\t */\n+\trte_spinlock_t state_lock;\n+\tstruct rte_mbuf **inject_pkts;\n+\tuint16_t max_queue_pairs;\n+\tuint64_t req_guest_features;\n+\tstruct virtnet_ctl *cvq;\n+};\n+\n+struct virtio_ops {\n+\tvoid (*read_dev_cfg)(struct virtio_hw *hw, size_t offset, void *dst, int len);\n+\tvoid (*write_dev_cfg)(struct virtio_hw *hw, size_t offset, const void *src, int len);\n+\tuint8_t (*get_status)(struct virtio_hw *hw);\n+\tvoid (*set_status)(struct virtio_hw *hw, uint8_t status);\n+\tuint64_t (*get_features)(struct virtio_hw *hw);\n+\tvoid (*set_features)(struct virtio_hw *hw, uint64_t features);\n+\tint (*features_ok)(struct virtio_hw *hw);\n+\tuint8_t (*get_isr)(struct virtio_hw *hw);\n+\tuint16_t (*set_config_irq)(struct virtio_hw *hw, uint16_t vec);\n+\tuint16_t (*set_queue_irq)(struct virtio_hw *hw, struct virtqueue *vq, uint16_t vec);\n+\tuint16_t (*get_queue_num)(struct virtio_hw *hw, uint16_t queue_id);\n+\tint (*setup_queue)(struct virtio_hw *hw, struct virtqueue *vq);\n+\tvoid (*del_queue)(struct virtio_hw *hw, struct virtqueue *vq);\n+\tvoid (*notify_queue)(struct virtio_hw *hw, struct virtqueue *vq);\n+\tvoid (*intr_detect)(struct virtio_hw *hw);\n+\tint (*dev_close)(struct virtio_hw *hw);\n+};\n+\n+/*\n+ * This structure stores per-process data. Only virtio_ops for now.\n+ */\n+struct virtio_hw_internal {\n+\tconst struct virtio_ops *virtio_ops;\n+};\n+\n+#define VIRTIO_OPS(hw)\t(virtio_hw_internal[(hw)->port_id].virtio_ops)\n+\n+extern struct virtio_hw_internal virtio_hw_internal[RTE_MAX_ETHPORTS];\n+\n+\n+#endif /* _VIRTIO_H_ */\ndiff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c\nindex c1d7b14dda..4b22622d2d 100644\n--- a/drivers/net/virtio/virtio_ethdev.c\n+++ b/drivers/net/virtio/virtio_ethdev.c\n@@ -446,7 +446,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx)\n \t * Read the virtqueue size from the Queue Size field\n \t * Always power of 2 and if 0 virtqueue does not exist\n \t */\n-\tvq_size = VTPCI_OPS(hw)->get_queue_num(hw, vtpci_queue_idx);\n+\tvq_size = VIRTIO_OPS(hw)->get_queue_num(hw, vtpci_queue_idx);\n \tPMD_INIT_LOG(DEBUG, \"vq_size: %u\", vq_size);\n \tif (vq_size == 0) {\n \t\tPMD_INIT_LOG(ERR, \"virtqueue does not exist\");\n@@ -608,7 +608,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx)\n \t\t}\n \t}\n \n-\tif (VTPCI_OPS(hw)->setup_queue(hw, vq) < 0) {\n+\tif (VIRTIO_OPS(hw)->setup_queue(hw, vq) < 0) {\n \t\tPMD_INIT_LOG(ERR, \"setup_queue failed\");\n \t\treturn -EINVAL;\n \t}\n@@ -703,7 +703,7 @@ virtio_dev_close(struct rte_eth_dev *dev)\n \n \t/* reset the NIC */\n \tif (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)\n-\t\tVTPCI_OPS(hw)->set_config_irq(hw, VIRTIO_MSI_NO_VECTOR);\n+\t\tVIRTIO_OPS(hw)->set_config_irq(hw, VIRTIO_MSI_NO_VECTOR);\n \tif (intr_conf->rxq)\n \t\tvirtio_queues_unbind_intr(dev);\n \n@@ -718,7 +718,7 @@ virtio_dev_close(struct rte_eth_dev *dev)\n \tvirtio_dev_free_mbufs(dev);\n \tvirtio_free_queues(hw);\n \n-\treturn VTPCI_OPS(hw)->dev_close(hw);\n+\treturn VIRTIO_OPS(hw)->dev_close(hw);\n }\n \n static int\n@@ -1261,8 +1261,8 @@ virtio_intr_unmask(struct rte_eth_dev *dev)\n \tif (rte_intr_ack(dev->intr_handle) < 0)\n \t\treturn -1;\n \n-\tif (VTPCI_OPS(hw)->intr_detect)\n-\t\tVTPCI_OPS(hw)->intr_detect(hw);\n+\tif (VIRTIO_OPS(hw)->intr_detect)\n+\t\tVIRTIO_OPS(hw)->intr_detect(hw);\n \n \treturn 0;\n }\n@@ -1275,8 +1275,8 @@ virtio_intr_enable(struct rte_eth_dev *dev)\n \tif (rte_intr_enable(dev->intr_handle) < 0)\n \t\treturn -1;\n \n-\tif (VTPCI_OPS(hw)->intr_detect)\n-\t\tVTPCI_OPS(hw)->intr_detect(hw);\n+\tif (VIRTIO_OPS(hw)->intr_detect)\n+\t\tVIRTIO_OPS(hw)->intr_detect(hw);\n \n \treturn 0;\n }\n@@ -1289,8 +1289,8 @@ virtio_intr_disable(struct rte_eth_dev *dev)\n \tif (rte_intr_disable(dev->intr_handle) < 0)\n \t\treturn -1;\n \n-\tif (VTPCI_OPS(hw)->intr_detect)\n-\t\tVTPCI_OPS(hw)->intr_detect(hw);\n+\tif (VIRTIO_OPS(hw)->intr_detect)\n+\t\tVIRTIO_OPS(hw)->intr_detect(hw);\n \n \treturn 0;\n }\n@@ -1305,7 +1305,7 @@ virtio_negotiate_features(struct virtio_hw *hw, uint64_t req_features)\n \t\treq_features);\n \n \t/* Read device(host) feature bits */\n-\thost_features = VTPCI_OPS(hw)->get_features(hw);\n+\thost_features = VIRTIO_OPS(hw)->get_features(hw);\n \tPMD_INIT_LOG(DEBUG, \"host_features before negotiate = %\" PRIx64,\n \t\thost_features);\n \n@@ -1330,7 +1330,7 @@ virtio_negotiate_features(struct virtio_hw *hw, uint64_t req_features)\n \tPMD_INIT_LOG(DEBUG, \"features after negotiate = %\" PRIx64,\n \t\thw->guest_features);\n \n-\tif (VTPCI_OPS(hw)->features_ok(hw) < 0)\n+\tif (VIRTIO_OPS(hw)->features_ok(hw) < 0)\n \t\treturn -1;\n \n \tif (vtpci_with_feature(hw, VIRTIO_F_VERSION_1)) {\n@@ -1564,7 +1564,7 @@ virtio_queues_bind_intr(struct rte_eth_dev *dev)\n \tPMD_INIT_LOG(INFO, \"queue/interrupt binding\");\n \tfor (i = 0; i < dev->data->nb_rx_queues; ++i) {\n \t\tdev->intr_handle->intr_vec[i] = i + 1;\n-\t\tif (VTPCI_OPS(hw)->set_queue_irq(hw, hw->vqs[i * 2], i + 1) ==\n+\t\tif (VIRTIO_OPS(hw)->set_queue_irq(hw, hw->vqs[i * 2], i + 1) ==\n \t\t\t\t\t\t VIRTIO_MSI_NO_VECTOR) {\n \t\t\tPMD_DRV_LOG(ERR, \"failed to set queue vector\");\n \t\t\treturn -EBUSY;\n@@ -1582,7 +1582,7 @@ virtio_queues_unbind_intr(struct rte_eth_dev *dev)\n \n \tPMD_INIT_LOG(INFO, \"queue/interrupt unbinding\");\n \tfor (i = 0; i < dev->data->nb_rx_queues; ++i)\n-\t\tVTPCI_OPS(hw)->set_queue_irq(hw,\n+\t\tVIRTIO_OPS(hw)->set_queue_irq(hw,\n \t\t\t\t\t     hw->vqs[i * VTNET_CQ],\n \t\t\t\t\t     VIRTIO_MSI_NO_VECTOR);\n }\n@@ -2092,7 +2092,7 @@ virtio_dev_configure(struct rte_eth_dev *dev)\n \n \tif (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)\n \t\t/* Enable vector (0) for Link State Intrerrupt */\n-\t\tif (VTPCI_OPS(hw)->set_config_irq(hw, 0) ==\n+\t\tif (VIRTIO_OPS(hw)->set_config_irq(hw, 0) ==\n \t\t\t\tVIRTIO_MSI_NO_VECTOR) {\n \t\t\tPMD_DRV_LOG(ERR, \"failed to set config vector\");\n \t\t\treturn -EBUSY;\n@@ -2433,7 +2433,7 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)\n \tdev_info->max_rx_pktlen = VIRTIO_MAX_RX_PKTLEN;\n \tdev_info->max_mac_addrs = VIRTIO_MAX_MAC_ADDRS;\n \n-\thost_features = VTPCI_OPS(hw)->get_features(hw);\n+\thost_features = VIRTIO_OPS(hw)->get_features(hw);\n \tdev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP;\n \tdev_info->rx_offload_capa |= DEV_RX_OFFLOAD_JUMBO_FRAME;\n \tif (host_features & (1ULL << VIRTIO_NET_F_GUEST_CSUM)) {\ndiff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c\nindex 3fe0631a30..e0d8a53ca6 100644\n--- a/drivers/net/virtio/virtio_pci.c\n+++ b/drivers/net/virtio/virtio_pci.c\n@@ -325,7 +325,7 @@ legacy_dev_close(struct virtio_hw *hw)\n \treturn 0;\n }\n \n-const struct virtio_pci_ops legacy_ops = {\n+const struct virtio_ops legacy_ops = {\n \t.read_dev_cfg\t= legacy_read_dev_config,\n \t.write_dev_cfg\t= legacy_write_dev_config,\n \t.get_status\t= legacy_get_status,\n@@ -584,7 +584,7 @@ modern_dev_close(struct virtio_hw *hw)\n \treturn 0;\n }\n \n-const struct virtio_pci_ops modern_ops = {\n+const struct virtio_ops modern_ops = {\n \t.read_dev_cfg\t= modern_read_dev_config,\n \t.write_dev_cfg\t= modern_write_dev_config,\n \t.get_status\t= modern_get_status,\n@@ -608,14 +608,14 @@ void\n vtpci_read_dev_config(struct virtio_hw *hw, size_t offset,\n \t\t      void *dst, int length)\n {\n-\tVTPCI_OPS(hw)->read_dev_cfg(hw, offset, dst, length);\n+\tVIRTIO_OPS(hw)->read_dev_cfg(hw, offset, dst, length);\n }\n \n void\n vtpci_write_dev_config(struct virtio_hw *hw, size_t offset,\n \t\t       const void *src, int length)\n {\n-\tVTPCI_OPS(hw)->write_dev_cfg(hw, offset, src, length);\n+\tVIRTIO_OPS(hw)->write_dev_cfg(hw, offset, src, length);\n }\n \n uint64_t\n@@ -628,7 +628,7 @@ vtpci_negotiate_features(struct virtio_hw *hw, uint64_t host_features)\n \t * host all support.\n \t */\n \tfeatures = host_features & hw->guest_features;\n-\tVTPCI_OPS(hw)->set_features(hw, features);\n+\tVIRTIO_OPS(hw)->set_features(hw, features);\n \n \treturn features;\n }\n@@ -636,9 +636,9 @@ vtpci_negotiate_features(struct virtio_hw *hw, uint64_t host_features)\n void\n vtpci_reset(struct virtio_hw *hw)\n {\n-\tVTPCI_OPS(hw)->set_status(hw, VIRTIO_CONFIG_STATUS_RESET);\n+\tVIRTIO_OPS(hw)->set_status(hw, VIRTIO_CONFIG_STATUS_RESET);\n \t/* flush status write */\n-\tVTPCI_OPS(hw)->get_status(hw);\n+\tVIRTIO_OPS(hw)->get_status(hw);\n }\n \n void\n@@ -651,21 +651,21 @@ void\n vtpci_set_status(struct virtio_hw *hw, uint8_t status)\n {\n \tif (status != VIRTIO_CONFIG_STATUS_RESET)\n-\t\tstatus |= VTPCI_OPS(hw)->get_status(hw);\n+\t\tstatus |= VIRTIO_OPS(hw)->get_status(hw);\n \n-\tVTPCI_OPS(hw)->set_status(hw, status);\n+\tVIRTIO_OPS(hw)->set_status(hw, status);\n }\n \n uint8_t\n vtpci_get_status(struct virtio_hw *hw)\n {\n-\treturn VTPCI_OPS(hw)->get_status(hw);\n+\treturn VIRTIO_OPS(hw)->get_status(hw);\n }\n \n uint8_t\n vtpci_isr(struct virtio_hw *hw)\n {\n-\treturn VTPCI_OPS(hw)->get_isr(hw);\n+\treturn VIRTIO_OPS(hw)->get_isr(hw);\n }\n \n static void *\n@@ -842,7 +842,7 @@ vtpci_init(struct rte_pci_device *pci_dev, struct virtio_pci_dev *dev)\n \t */\n \tif (virtio_read_caps(pci_dev, hw) == 0) {\n \t\tPMD_INIT_LOG(INFO, \"modern virtio pci detected.\");\n-\t\tvirtio_hw_internal[hw->port_id].vtpci_ops = &modern_ops;\n+\t\tVIRTIO_OPS(hw) = &modern_ops;\n \t\tdev->modern = true;\n \t\tgoto msix_detect;\n \t}\n@@ -861,11 +861,11 @@ vtpci_init(struct rte_pci_device *pci_dev, struct virtio_pci_dev *dev)\n \t\treturn -1;\n \t}\n \n-\tvirtio_hw_internal[hw->port_id].vtpci_ops = &legacy_ops;\n+\tVIRTIO_OPS(hw) = &legacy_ops;\n \tdev->modern = false;\n \n msix_detect:\n-\tVTPCI_OPS(hw)->intr_detect(hw);\n+\tVIRTIO_OPS(hw)->intr_detect(hw);\n \n \treturn 0;\n }\ndiff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h\nindex def8faca72..f7f51fba79 100644\n--- a/drivers/net/virtio/virtio_pci.h\n+++ b/drivers/net/virtio/virtio_pci.h\n@@ -12,6 +12,8 @@\n #include <rte_bus_pci.h>\n #include <rte_ethdev_driver.h>\n \n+#include \"virtio.h\"\n+\n struct virtqueue;\n struct virtnet_ctl;\n \n@@ -214,70 +216,6 @@ struct virtio_pci_common_cfg {\n \tuint32_t queue_used_hi;\t\t/* read-write */\n };\n \n-struct virtio_hw;\n-\n-struct virtio_pci_ops {\n-\tvoid (*read_dev_cfg)(struct virtio_hw *hw, size_t offset,\n-\t\t\t     void *dst, int len);\n-\tvoid (*write_dev_cfg)(struct virtio_hw *hw, size_t offset,\n-\t\t\t      const void *src, int len);\n-\n-\tuint8_t (*get_status)(struct virtio_hw *hw);\n-\tvoid    (*set_status)(struct virtio_hw *hw, uint8_t status);\n-\n-\tuint64_t (*get_features)(struct virtio_hw *hw);\n-\tvoid     (*set_features)(struct virtio_hw *hw, uint64_t features);\n-\tint      (*features_ok)(struct virtio_hw *hw);\n-\n-\tuint8_t (*get_isr)(struct virtio_hw *hw);\n-\n-\tuint16_t (*set_config_irq)(struct virtio_hw *hw, uint16_t vec);\n-\n-\tuint16_t (*set_queue_irq)(struct virtio_hw *hw, struct virtqueue *vq,\n-\t\t\tuint16_t vec);\n-\n-\tuint16_t (*get_queue_num)(struct virtio_hw *hw, uint16_t queue_id);\n-\tint (*setup_queue)(struct virtio_hw *hw, struct virtqueue *vq);\n-\tvoid (*del_queue)(struct virtio_hw *hw, struct virtqueue *vq);\n-\tvoid (*notify_queue)(struct virtio_hw *hw, struct virtqueue *vq);\n-\tvoid (*intr_detect)(struct virtio_hw *hw);\n-\tint (*dev_close)(struct virtio_hw *hw);\n-};\n-\n-struct virtio_net_config;\n-\n-struct virtio_hw {\n-\tstruct virtqueue **vqs;\n-\tuint64_t guest_features;\n-\tuint16_t vtnet_hdr_size;\n-\tuint8_t started;\n-\tuint8_t weak_barriers;\n-\tuint8_t vlan_strip;\n-\tuint8_t has_tx_offload;\n-\tuint8_t has_rx_offload;\n-\tuint8_t use_vec_rx;\n-\tuint8_t use_vec_tx;\n-\tuint8_t use_inorder_rx;\n-\tuint8_t use_inorder_tx;\n-\tuint8_t opened;\n-\tuint16_t port_id;\n-\tuint8_t mac_addr[RTE_ETHER_ADDR_LEN];\n-\tuint32_t speed;  /* link speed in MB */\n-\tuint8_t duplex;\n-\tuint8_t use_msix;\n-\tuint16_t max_mtu;\n-\t/*\n-\t * App management thread and virtio interrupt handler thread\n-\t * both can change device state, this lock is meant to avoid\n-\t * such a contention.\n-\t */\n-\trte_spinlock_t state_lock;\n-\tstruct rte_mbuf **inject_pkts;\n-\tuint16_t max_queue_pairs;\n-\tuint64_t req_guest_features;\n-\tstruct virtnet_ctl *cvq;\n-};\n-\n struct virtio_pci_dev {\n \tstruct virtio_hw hw;\n \tstruct rte_pci_device *pci_dev;\n@@ -291,19 +229,6 @@ struct virtio_pci_dev {\n \n #define virtio_pci_get_dev(hwp) container_of(hwp, struct virtio_pci_dev, hw)\n \n-/*\n- * While virtio_hw is stored in shared memory, this structure stores\n- * some infos that may vary in the multiple process model locally.\n- * For example, the vtpci_ops pointer.\n- */\n-struct virtio_hw_internal {\n-\tconst struct virtio_pci_ops *vtpci_ops;\n-};\n-\n-#define VTPCI_OPS(hw)\t(virtio_hw_internal[(hw)->port_id].vtpci_ops)\n-\n-extern struct virtio_hw_internal virtio_hw_internal[RTE_MAX_ETHPORTS];\n-\n /*\n  * This structure is just a reference to read\n  * net device specific config space; it just a chodu structure\n@@ -379,8 +304,7 @@ uint8_t vtpci_isr(struct virtio_hw *);\n void vtpci_legacy_ioport_unmap(struct virtio_hw *hw);\n int vtpci_legacy_ioport_map(struct virtio_hw *hw);\n \n-extern const struct virtio_pci_ops legacy_ops;\n-extern const struct virtio_pci_ops modern_ops;\n-extern const struct virtio_pci_ops virtio_user_ops;\n+extern const struct virtio_ops legacy_ops;\n+extern const struct virtio_ops modern_ops;\n \n #endif /* _VIRTIO_PCI_H_ */\ndiff --git a/drivers/net/virtio/virtio_pci_ethdev.c b/drivers/net/virtio/virtio_pci_ethdev.c\nindex 9fe59feb51..fb462572fb 100644\n--- a/drivers/net/virtio/virtio_pci_ethdev.c\n+++ b/drivers/net/virtio/virtio_pci_ethdev.c\n@@ -19,6 +19,7 @@\n #include <rte_dev.h>\n #include <rte_kvargs.h>\n \n+#include \"virtio.h\"\n #include \"virtio_ethdev.h\"\n #include \"virtio_pci.h\"\n #include \"virtio_logs.h\"\n@@ -83,9 +84,9 @@ eth_virtio_pci_init(struct rte_eth_dev *eth_dev)\n \t\t}\n \t} else {\n \t\tif (dev->modern)\n-\t\t\tVTPCI_OPS(hw) = &modern_ops;\n+\t\t\tVIRTIO_OPS(hw) = &modern_ops;\n \t\telse\n-\t\t\tVTPCI_OPS(hw) = &legacy_ops;\n+\t\t\tVIRTIO_OPS(hw) = &legacy_ops;\n \n \t\tret = virtio_remap_pci(RTE_ETH_DEV_TO_PCI(eth_dev), dev);\n \t\tif (ret < 0) {\ndiff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c\nindex 61880a8e02..6597c16539 100644\n--- a/drivers/net/virtio/virtio_user_ethdev.c\n+++ b/drivers/net/virtio/virtio_user_ethdev.c\n@@ -20,7 +20,7 @@\n \n #include \"virtio_ethdev.h\"\n #include \"virtio_logs.h\"\n-#include \"virtio_pci.h\"\n+#include \"virtio.h\"\n #include \"virtqueue.h\"\n #include \"virtio_rxtx.h\"\n #include \"virtio_user/virtio_user_dev.h\"\n@@ -478,7 +478,7 @@ virtio_user_dev_close(struct virtio_hw *hw)\n \treturn 0;\n }\n \n-const struct virtio_pci_ops virtio_user_ops = {\n+const struct virtio_ops virtio_user_ops = {\n \t.read_dev_cfg\t= virtio_user_read_dev_config,\n \t.write_dev_cfg\t= virtio_user_write_dev_config,\n \t.get_status\t= virtio_user_get_status,\n@@ -635,7 +635,7 @@ virtio_user_eth_dev_alloc(struct rte_vdev_device *vdev)\n \n \thw->port_id = data->port_id;\n \tdev->port_id = data->port_id;\n-\tvirtio_hw_internal[hw->port_id].vtpci_ops = &virtio_user_ops;\n+\tVIRTIO_OPS(hw) = &virtio_user_ops;\n \t/*\n \t * MSIX is required to enable LSC (see virtio_init_device).\n \t * Here just pretend that we support msix.\n@@ -692,7 +692,7 @@ virtio_user_pmd_probe(struct rte_vdev_device *vdev)\n \n \t\tdev = eth_dev->data->dev_private;\n \t\thw = &dev->hw;\n-\t\tVTPCI_OPS(hw) = &virtio_user_ops;\n+\t\tVIRTIO_OPS(hw) = &virtio_user_ops;\n \n \t\tif (eth_virtio_dev_init(eth_dev) < 0) {\n \t\t\tPMD_INIT_LOG(ERR, \"eth_virtio_dev_init fails\");\ndiff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h\nindex 3a9ce29069..6293cd2604 100644\n--- a/drivers/net/virtio/virtqueue.h\n+++ b/drivers/net/virtio/virtqueue.h\n@@ -563,7 +563,7 @@ virtqueue_kick_prepare_packed(struct virtqueue *vq)\n static inline void\n virtqueue_notify(struct virtqueue *vq)\n {\n-\tVTPCI_OPS(vq->hw)->notify_queue(vq->hw, vq);\n+\tVIRTIO_OPS(vq->hw)->notify_queue(vq->hw, vq);\n }\n \n #ifdef RTE_LIBRTE_VIRTIO_DEBUG_DUMP\n",
    "prefixes": [
        "v4",
        "18/44"
    ]
}