get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 31292,
    "url": "https://patches.dpdk.org/api/patches/31292/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20171109085519.62567-1-zhiyong.yang@intel.com/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20171109085519.62567-1-zhiyong.yang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20171109085519.62567-1-zhiyong.yang@intel.com",
    "date": "2017-11-09T08:55:19",
    "name": "[dpdk-dev,v5] net/virtio: fix rxq intr config fails using vfio-pci",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "5af31689bf0e0501aea81a23906e877b19645a5e",
    "submitter": {
        "id": 540,
        "url": "https://patches.dpdk.org/api/people/540/?format=api",
        "name": "Yang, Zhiyong",
        "email": "zhiyong.yang@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20171109085519.62567-1-zhiyong.yang@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/31292/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/31292/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id EE01F1B608;\n\tThu,  9 Nov 2017 10:06:38 +0100 (CET)",
            "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby dpdk.org (Postfix) with ESMTP id 5F9EF1B259;\n\tThu,  9 Nov 2017 10:06:37 +0100 (CET)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t09 Nov 2017 01:06:36 -0800",
            "from unknown (HELO dpdk5.bj.intel.com) ([172.16.182.182])\n\tby fmsmga002.fm.intel.com with ESMTP; 09 Nov 2017 01:06:34 -0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos; i=\"5.44,368,1505804400\"; d=\"scan'208\";\n\ta=\"1241922990\"",
        "From": "Zhiyong Yang <zhiyong.yang@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "stable@dpdk.org, jianfeng.tan@intel.com, yliu@fridaylinux.org,\n\tmaxime.coquelin@redhat.com, Zhiyong Yang <zhiyong.yang@intel.com>",
        "Date": "Thu,  9 Nov 2017 16:55:19 +0800",
        "Message-Id": "<20171109085519.62567-1-zhiyong.yang@intel.com>",
        "X-Mailer": "git-send-email 2.13.3",
        "In-Reply-To": "<20171109044607.3327-1-zhiyong.yang@intel.com>",
        "References": "<20171109044607.3327-1-zhiyong.yang@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v5] net/virtio: fix rxq intr config fails using\n\tvfio-pci",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <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": "When running l3fwd-power to test virtio rxq interrupt using vfio\npci noiommu mode, startup fails. In the function virtio_read_caps,\nthe code if (flags & PCI_MSIX_ENABLE) intends to double check\nif vfio msix is enabled or not. However, it is not enable at that\ntime. So use_msix is assigned to \"0\", not \"1\", which causes the\nfailure of configuring rxq intr in l3fwd-power.\nThis patch adds the function \"vtpci_msix_detect\" to detect the status\nof msix when interrupt changes happen.\nIn the meanwhile, virtio_intr_enable/disable are introduced to wrap\nrte_intr_enable/disable to enhance the ability to detect msix.\nuse_msix can indicate three different msix status by:\nVIRTIO_MSIX_NONE (0)\nVIRTIO_MSIX_DISABLED (1)\nVIRTIO_MSIX_ENABLED (2)\n\nCC: stable@dpdk.org\nCC: jianfeng.tan@intel.com\nCC: yliu@fridaylinux.org\nCC: maxime.coquelin@redhat.com\n\nFixes: cb482cb3a305 (\"net/virtio: fix MAC address read\")\nSigned-off-by: Zhiyong Yang <zhiyong.yang@intel.com>\nAcked-by: Jianfeng Tan <jianfeng.tan@intel.com>\nAcked-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n\nChanges in v5:\n1. Introduce new enum data type \"VIRTIO_MSIX_STATUS\" instead of macros.\n2. Remove the unnecessary comments.\n\nChanges in v4:\nEnhance the commit log description.\n\nChanges in v3:\nSimply the code according to jianfeng's comments.\n\nChanges in v2:\nAdd the capability to detect msix if virtio intr changes.\n\n drivers/net/virtio/virtio_ethdev.c | 46 ++++++++++++++++++++++++++++++++------\n drivers/net/virtio/virtio_pci.c    | 43 +++++++++++++++++++++++++++++++++--\n drivers/net/virtio/virtio_pci.h    |  8 +++++++\n 3 files changed, 88 insertions(+), 9 deletions(-)",
    "diff": "diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c\nindex d2576d5e0..87ac2bee6 100644\n--- a/drivers/net/virtio/virtio_ethdev.c\n+++ b/drivers/net/virtio/virtio_ethdev.c\n@@ -97,6 +97,9 @@ static void virtio_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);\n static void virtio_mac_addr_set(struct rte_eth_dev *dev,\n \t\t\t\tstruct ether_addr *mac_addr);\n \n+static int virtio_intr_enable(struct rte_eth_dev *dev);\n+static int virtio_intr_disable(struct rte_eth_dev *dev);\n+\n static int virtio_dev_queue_stats_mapping_set(\n \tstruct rte_eth_dev *eth_dev,\n \tuint16_t queue_id,\n@@ -618,7 +621,7 @@ virtio_dev_close(struct rte_eth_dev *dev)\n \t\tvirtio_queues_unbind_intr(dev);\n \n \tif (intr_conf->lsc || intr_conf->rxq) {\n-\t\trte_intr_disable(dev->intr_handle);\n+\t\tvirtio_intr_disable(dev);\n \t\trte_intr_efd_disable(dev->intr_handle);\n \t\trte_free(dev->intr_handle->intr_vec);\n \t\tdev->intr_handle->intr_vec = NULL;\n@@ -1160,6 +1163,34 @@ virtio_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)\n }\n \n static int\n+virtio_intr_enable(struct rte_eth_dev *dev)\n+{\n+\tstruct virtio_hw *hw = dev->data->dev_private;\n+\n+\tif (rte_intr_enable(dev->intr_handle) < 0)\n+\t\treturn -1;\n+\n+\tif (!hw->virtio_user_dev)\n+\t\thw->use_msix = vtpci_msix_detect(RTE_ETH_DEV_TO_PCI(dev));\n+\n+\treturn 0;\n+}\n+\n+static int\n+virtio_intr_disable(struct rte_eth_dev *dev)\n+{\n+\tstruct virtio_hw *hw = dev->data->dev_private;\n+\n+\tif (rte_intr_disable(dev->intr_handle) < 0)\n+\t\treturn -1;\n+\n+\tif (!hw->virtio_user_dev)\n+\t\thw->use_msix = vtpci_msix_detect(RTE_ETH_DEV_TO_PCI(dev));\n+\n+\treturn 0;\n+}\n+\n+static int\n virtio_negotiate_features(struct virtio_hw *hw, uint64_t req_features)\n {\n \tuint64_t host_features;\n@@ -1228,7 +1259,7 @@ virtio_interrupt_handler(void *param)\n \tisr = vtpci_isr(hw);\n \tPMD_DRV_LOG(INFO, \"interrupt status = %#x\", isr);\n \n-\tif (rte_intr_enable(dev->intr_handle) < 0)\n+\tif (virtio_intr_enable(dev) < 0)\n \t\tPMD_DRV_LOG(ERR, \"interrupt enable failed\");\n \n \tif (isr & VIRTIO_PCI_ISR_CONFIG) {\n@@ -1348,7 +1379,7 @@ virtio_configure_intr(struct rte_eth_dev *dev)\n \t * to change the config size from 20 to 24, or VIRTIO_MSI_QUEUE_VECTOR\n \t * (22) will be ignored.\n \t */\n-\tif (rte_intr_enable(dev->intr_handle) < 0) {\n+\tif (virtio_intr_enable(dev) < 0) {\n \t\tPMD_DRV_LOG(ERR, \"interrupt enable failed\");\n \t\treturn -1;\n \t}\n@@ -1388,7 +1419,8 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)\n \t}\n \n \t/* If host does not support both status and MSI-X then disable LSC */\n-\tif (vtpci_with_feature(hw, VIRTIO_NET_F_STATUS) && hw->use_msix)\n+\tif (vtpci_with_feature(hw, VIRTIO_NET_F_STATUS) &&\n+\t    hw->use_msix != VIRTIO_MSIX_NONE)\n \t\teth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;\n \telse\n \t\teth_dev->data->dev_flags &= ~RTE_ETH_DEV_INTR_LSC;\n@@ -1801,9 +1833,9 @@ virtio_dev_start(struct rte_eth_dev *dev)\n \t */\n \tif (dev->data->dev_conf.intr_conf.lsc ||\n \t    dev->data->dev_conf.intr_conf.rxq) {\n-\t\trte_intr_disable(dev->intr_handle);\n+\t\tvirtio_intr_disable(dev);\n \n-\t\tif (rte_intr_enable(dev->intr_handle) < 0) {\n+\t\tif (virtio_intr_enable(dev) < 0) {\n \t\t\tPMD_DRV_LOG(ERR, \"interrupt enable failed\");\n \t\t\treturn -EIO;\n \t\t}\n@@ -1912,7 +1944,7 @@ virtio_dev_stop(struct rte_eth_dev *dev)\n \tPMD_INIT_LOG(DEBUG, \"stop\");\n \n \tif (intr_conf->lsc || intr_conf->rxq)\n-\t\trte_intr_disable(dev->intr_handle);\n+\t\tvirtio_intr_disable(dev);\n \n \thw->started = 0;\n \tmemset(&link, 0, sizeof(link));\ndiff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c\nindex 55b717c03..d6016de22 100644\n--- a/drivers/net/virtio/virtio_pci.c\n+++ b/drivers/net/virtio/virtio_pci.c\n@@ -57,7 +57,8 @@\n  * The remaining space is defined by each driver as the per-driver\n  * configuration space.\n  */\n-#define VIRTIO_PCI_CONFIG(hw) (((hw)->use_msix) ? 24 : 20)\n+#define VIRTIO_PCI_CONFIG(hw) \\\n+\t\t(((hw)->use_msix == VIRTIO_MSIX_ENABLED) ? 24 : 20)\n \n static inline int\n check_vq_phys_addr_ok(struct virtqueue *vq)\n@@ -617,7 +618,9 @@ virtio_read_caps(struct rte_pci_device *dev, struct virtio_hw *hw)\n \t\t\tuint16_t flags = ((uint16_t *)&cap)[1];\n \n \t\t\tif (flags & PCI_MSIX_ENABLE)\n-\t\t\t\thw->use_msix = 1;\n+\t\t\t\thw->use_msix = VIRTIO_MSIX_ENABLED;\n+\t\t\telse\n+\t\t\t\thw->use_msix = VIRTIO_MSIX_DISABLED;\n \t\t}\n \n \t\tif (cap.cap_vndr != PCI_CAP_ID_VNDR) {\n@@ -710,3 +713,39 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *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+\tstruct virtio_pci_cap cap;\n+\tint ret;\n+\n+\tret = rte_pci_read_config(dev, &pos, 1, PCI_CAPABILITY_LIST);\n+\tif (ret < 0) {\n+\t\tPMD_INIT_LOG(DEBUG, \"failed to read pci capability list\");\n+\t\treturn VIRTIO_MSIX_NONE;\n+\t}\n+\n+\twhile (pos) {\n+\t\tret = rte_pci_read_config(dev, &cap, sizeof(cap), pos);\n+\t\tif (ret < 0) {\n+\t\t\tPMD_INIT_LOG(ERR,\n+\t\t\t\t\"failed to read pci cap at pos: %x\", pos);\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tif (cap.cap_vndr == PCI_CAP_ID_MSIX) {\n+\t\t\tuint16_t flags = ((uint16_t *)&cap)[1];\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.cap_next;\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 36d452c06..28e9af6c7 100644\n--- a/drivers/net/virtio/virtio_pci.h\n+++ b/drivers/net/virtio/virtio_pci.h\n@@ -314,6 +314,12 @@ struct virtio_net_config {\n /* The alignment to use between consumer and producer parts of vring. */\n #define VIRTIO_PCI_VRING_ALIGN 4096\n \n+enum VIRTIO_MSIX_STATUS {\n+\tVIRTIO_MSIX_NONE = 0,\n+\tVIRTIO_MSIX_DISABLED = 1,\n+\tVIRTIO_MSIX_ENABLED = 2\n+};\n+\n static inline int\n vtpci_with_feature(struct virtio_hw *hw, uint64_t bit)\n {\n@@ -339,6 +345,8 @@ 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;\n",
    "prefixes": [
        "dpdk-dev",
        "v5"
    ]
}