get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 87297,
    "url": "https://patches.dpdk.org/api/patches/87297/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20210126101639.250481-10-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-10-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210126101639.250481-10-maxime.coquelin@redhat.com",
    "date": "2021-01-26T10:16:04",
    "name": "[v4,09/44] net/virtio: move MSIX detection to PCI ethdev",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "823695d1775945e0ca56e83c6baedcfba3180bbe",
    "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-10-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/87297/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/87297/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 7003BA052A;\n\tTue, 26 Jan 2021 11:18:21 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 1F591141344;\n\tTue, 26 Jan 2021 11:17:24 +0100 (CET)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [63.128.21.124])\n by mails.dpdk.org (Postfix) with ESMTP id C6016141344\n for <dev@dpdk.org>; Tue, 26 Jan 2021 11:17:21 +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-34-_qWh69M-O1OpgDs9bxNDZw-1; Tue, 26 Jan 2021 05:17:16 -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 94DA018C8C02;\n Tue, 26 Jan 2021 10:17:15 +0000 (UTC)",
            "from max-t490s.redhat.com (unknown [10.36.110.31])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 2749472163;\n Tue, 26 Jan 2021 10:17:13 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1611656241;\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=nSkNOJ00rCzmET6YShdRdDeDIDfr4yyFpqTm38HWtH4=;\n b=RiCfYuozt3rFWONUMIEoOjwtYXPIFjH9reLbLrd8xvfZATZdO/q+y0b+/6SUw4V3J3ngkl\n RzQlZP82nS3MdZtKqJ17DS8XOy4JuV0Io18xxtODvST0HmWCpAIS9t8RMOHJDz2H6wVA7i\n qEOQlIOc2N0ullL8WDG87354RruRroE=",
        "X-MC-Unique": "_qWh69M-O1OpgDs9bxNDZw-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:04 +0100",
        "Message-Id": "<20210126101639.250481-10-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 09/44] net/virtio: move MSIX detection to PCI\n ethdev",
        "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 introduces a new callback to notify the bus\ndriver some interrupt related operation was done.\n\nThis is used by Virtio PCI driver to check msix status.\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\nReviewed-by: Chenbo Xia <chenbo.xia@intel.com>\n---\n drivers/net/virtio/virtio_ethdev.c     |  12 +--\n drivers/net/virtio/virtio_pci.c        | 120 ++++++++++++++-----------\n drivers/net/virtio/virtio_pci.h        |   6 +-\n drivers/net/virtio/virtio_pci_ethdev.c |   2 +\n 4 files changed, 82 insertions(+), 58 deletions(-)",
    "diff": "diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c\nindex a3e81f336d..52eb878c42 100644\n--- a/drivers/net/virtio/virtio_ethdev.c\n+++ b/drivers/net/virtio/virtio_ethdev.c\n@@ -1287,8 +1287,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 (hw->bus_type == VIRTIO_BUS_PCI_LEGACY || hw->bus_type == VIRTIO_BUS_PCI_MODERN)\n-\t\thw->use_msix = vtpci_msix_detect(RTE_ETH_DEV_TO_PCI(dev));\n+\tif (VTPCI_OPS(hw)->intr_detect)\n+\t\tVTPCI_OPS(hw)->intr_detect(hw);\n \n \treturn 0;\n }\n@@ -1301,8 +1301,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 (hw->bus_type == VIRTIO_BUS_PCI_LEGACY || hw->bus_type == VIRTIO_BUS_PCI_MODERN)\n-\t\thw->use_msix = vtpci_msix_detect(RTE_ETH_DEV_TO_PCI(dev));\n+\tif (VTPCI_OPS(hw)->intr_detect)\n+\t\tVTPCI_OPS(hw)->intr_detect(hw);\n \n \treturn 0;\n }\n@@ -1315,8 +1315,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 (hw->bus_type == VIRTIO_BUS_PCI_LEGACY || hw->bus_type == VIRTIO_BUS_PCI_MODERN)\n-\t\thw->use_msix = vtpci_msix_detect(RTE_ETH_DEV_TO_PCI(dev));\n+\tif (VTPCI_OPS(hw)->intr_detect)\n+\t\tVTPCI_OPS(hw)->intr_detect(hw);\n \n \treturn 0;\n }\ndiff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c\nindex 345d73f868..556be1e3da 100644\n--- a/drivers/net/virtio/virtio_pci.c\n+++ b/drivers/net/virtio/virtio_pci.c\n@@ -47,6 +47,56 @@ check_vq_phys_addr_ok(struct virtqueue *vq)\n \treturn 1;\n }\n \n+#define PCI_MSIX_ENABLE 0x8000\n+\n+static enum virtio_msix_status\n+vtpci_msix_detect(struct rte_pci_device *dev)\n+{\n+\tuint8_t pos;\n+\tint ret;\n+\n+\tret = rte_pci_read_config(dev, &pos, 1, PCI_CAPABILITY_LIST);\n+\tif (ret != 1) {\n+\t\tPMD_INIT_LOG(DEBUG,\n+\t\t\t     \"failed to read pci capability list, ret %d\", ret);\n+\t\treturn VIRTIO_MSIX_NONE;\n+\t}\n+\n+\twhile (pos) {\n+\t\tuint8_t cap[2];\n+\n+\t\tret = rte_pci_read_config(dev, cap, sizeof(cap), pos);\n+\t\tif (ret != sizeof(cap)) {\n+\t\t\tPMD_INIT_LOG(DEBUG,\n+\t\t\t\t     \"failed to read pci cap at pos: %x ret %d\",\n+\t\t\t\t     pos, ret);\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tif (cap[0] == PCI_CAP_ID_MSIX) {\n+\t\t\tuint16_t flags;\n+\n+\t\t\tret = rte_pci_read_config(dev, &flags, sizeof(flags),\n+\t\t\t\t\tpos + sizeof(cap));\n+\t\t\tif (ret != sizeof(flags)) {\n+\t\t\t\tPMD_INIT_LOG(DEBUG,\n+\t\t\t\t\t     \"failed to read pci cap at pos:\"\n+\t\t\t\t\t     \" %x ret %d\", pos + 2, ret);\n+\t\t\t\tbreak;\n+\t\t\t}\n+\n+\t\t\tif (flags & PCI_MSIX_ENABLE)\n+\t\t\t\treturn VIRTIO_MSIX_ENABLED;\n+\t\t\telse\n+\t\t\t\treturn VIRTIO_MSIX_DISABLED;\n+\t\t}\n+\n+\t\tpos = cap[1];\n+\t}\n+\n+\treturn VIRTIO_MSIX_NONE;\n+}\n+\n /*\n  * Since we are in legacy mode:\n  * http://ozlabs.org/~rusty/virtio-spec/virtio-0.9.5.pdf\n@@ -241,6 +291,12 @@ legacy_notify_queue(struct virtio_hw *hw, struct virtqueue *vq)\n \t\tVIRTIO_PCI_QUEUE_NOTIFY);\n }\n \n+static void\n+legacy_intr_detect(struct virtio_hw *hw)\n+{\n+\thw->use_msix = vtpci_msix_detect(VTPCI_DEV(hw));\n+}\n+\n const struct virtio_pci_ops legacy_ops = {\n \t.read_dev_cfg\t= legacy_read_dev_config,\n \t.write_dev_cfg\t= legacy_write_dev_config,\n@@ -255,6 +311,7 @@ const struct virtio_pci_ops legacy_ops = {\n \t.setup_queue\t= legacy_setup_queue,\n \t.del_queue\t= legacy_del_queue,\n \t.notify_queue\t= legacy_notify_queue,\n+\t.intr_detect\t= legacy_intr_detect,\n };\n \n static inline void\n@@ -446,6 +503,14 @@ modern_notify_queue(struct virtio_hw *hw, struct virtqueue *vq)\n \trte_write32(notify_data, vq->notify_addr);\n }\n \n+\n+\n+static void\n+modern_intr_detect(struct virtio_hw *hw)\n+{\n+\thw->use_msix = vtpci_msix_detect(VTPCI_DEV(hw));\n+}\n+\n const struct virtio_pci_ops modern_ops = {\n \t.read_dev_cfg\t= modern_read_dev_config,\n \t.write_dev_cfg\t= modern_write_dev_config,\n@@ -460,6 +525,7 @@ const struct virtio_pci_ops modern_ops = {\n \t.setup_queue\t= modern_setup_queue,\n \t.del_queue\t= modern_del_queue,\n \t.notify_queue\t= modern_notify_queue,\n+\t.intr_detect\t= modern_intr_detect,\n };\n \n \n@@ -562,8 +628,6 @@ get_cfg_addr(struct rte_pci_device *dev, struct virtio_pci_cap *cap)\n \treturn base + offset;\n }\n \n-#define PCI_MSIX_ENABLE 0x8000\n-\n static int\n virtio_read_caps(struct rte_pci_device *dev, struct virtio_hw *hw)\n {\n@@ -700,7 +764,7 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)\n \t\tPMD_INIT_LOG(INFO, \"modern virtio pci detected.\");\n \t\tvirtio_hw_internal[hw->port_id].vtpci_ops = &modern_ops;\n \t\thw->bus_type = VIRTIO_BUS_PCI_MODERN;\n-\t\treturn 0;\n+\t\tgoto msix_detect;\n \t}\n \n \tPMD_INIT_LOG(INFO, \"trying with legacy virtio pci.\");\n@@ -720,53 +784,9 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)\n \tvirtio_hw_internal[hw->port_id].vtpci_ops = &legacy_ops;\n \thw->bus_type = VIRTIO_BUS_PCI_LEGACY;\n \n+msix_detect:\n+\tVTPCI_OPS(hw)->intr_detect(hw);\n+\n \treturn 0;\n }\n \n-enum virtio_msix_status\n-vtpci_msix_detect(struct rte_pci_device *dev)\n-{\n-\tuint8_t pos;\n-\tint ret;\n-\n-\tret = rte_pci_read_config(dev, &pos, 1, PCI_CAPABILITY_LIST);\n-\tif (ret != 1) {\n-\t\tPMD_INIT_LOG(DEBUG,\n-\t\t\t     \"failed to read pci capability list, ret %d\", ret);\n-\t\treturn VIRTIO_MSIX_NONE;\n-\t}\n-\n-\twhile (pos) {\n-\t\tuint8_t cap[2];\n-\n-\t\tret = rte_pci_read_config(dev, cap, sizeof(cap), pos);\n-\t\tif (ret != sizeof(cap)) {\n-\t\t\tPMD_INIT_LOG(DEBUG,\n-\t\t\t\t     \"failed to read pci cap at pos: %x ret %d\",\n-\t\t\t\t     pos, ret);\n-\t\t\tbreak;\n-\t\t}\n-\n-\t\tif (cap[0] == PCI_CAP_ID_MSIX) {\n-\t\t\tuint16_t flags;\n-\n-\t\t\tret = rte_pci_read_config(dev, &flags, sizeof(flags),\n-\t\t\t\t\tpos + sizeof(cap));\n-\t\t\tif (ret != sizeof(flags)) {\n-\t\t\t\tPMD_INIT_LOG(DEBUG,\n-\t\t\t\t\t     \"failed to read pci cap at pos:\"\n-\t\t\t\t\t     \" %x ret %d\", pos + 2, ret);\n-\t\t\t\tbreak;\n-\t\t\t}\n-\n-\t\t\tif (flags & PCI_MSIX_ENABLE)\n-\t\t\t\treturn VIRTIO_MSIX_ENABLED;\n-\t\t\telse\n-\t\t\t\treturn VIRTIO_MSIX_DISABLED;\n-\t\t}\n-\n-\t\tpos = cap[1];\n-\t}\n-\n-\treturn VIRTIO_MSIX_NONE;\n-}\ndiff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h\nindex 59f6688218..b29bbb8074 100644\n--- a/drivers/net/virtio/virtio_pci.h\n+++ b/drivers/net/virtio/virtio_pci.h\n@@ -239,6 +239,7 @@ struct virtio_pci_ops {\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 };\n \n struct virtio_net_config;\n@@ -303,10 +304,13 @@ struct virtio_pci_dev {\n struct virtio_hw_internal {\n \tconst struct virtio_pci_ops *vtpci_ops;\n \tstruct rte_pci_ioport io;\n+\tstruct rte_pci_device *dev;\n };\n \n #define VTPCI_OPS(hw)\t(virtio_hw_internal[(hw)->port_id].vtpci_ops)\n #define VTPCI_IO(hw)\t(&virtio_hw_internal[(hw)->port_id].io)\n+#define VTPCI_DEV(hw)\t(virtio_hw_internal[(hw)->port_id].dev)\n+\n \n extern struct virtio_hw_internal virtio_hw_internal[RTE_MAX_ETHPORTS];\n \n@@ -383,8 +387,6 @@ void vtpci_read_dev_config(struct virtio_hw *, size_t, void *, int);\n \n uint8_t vtpci_isr(struct virtio_hw *);\n \n-enum virtio_msix_status vtpci_msix_detect(struct rte_pci_device *dev);\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;\ndiff --git a/drivers/net/virtio/virtio_pci_ethdev.c b/drivers/net/virtio/virtio_pci_ethdev.c\nindex 6a0ef6edc3..045b134ef2 100644\n--- a/drivers/net/virtio/virtio_pci_ethdev.c\n+++ b/drivers/net/virtio/virtio_pci_ethdev.c\n@@ -73,6 +73,8 @@ eth_virtio_pci_init(struct rte_eth_dev *eth_dev)\n \tstruct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);\n \tint ret;\n \n+\tVTPCI_DEV(hw) = pci_dev;\n+\n \tif (rte_eal_process_type() == RTE_PROC_PRIMARY) {\n \t\tret = vtpci_init(RTE_ETH_DEV_TO_PCI(eth_dev), hw);\n \t\tif (ret) {\n",
    "prefixes": [
        "v4",
        "09/44"
    ]
}