get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 12225,
    "url": "https://patches.dpdk.org/api/patches/12225/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1461637474-110602-1-git-send-email-jianfeng.tan@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": "<1461637474-110602-1-git-send-email-jianfeng.tan@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1461637474-110602-1-git-send-email-jianfeng.tan@intel.com",
    "date": "2016-04-26T02:24:34",
    "name": "[dpdk-dev] virtio: fix modify drv_flags for specific device",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "008827d8416103e57b8434448bc111a5ab49bc33",
    "submitter": {
        "id": 313,
        "url": "https://patches.dpdk.org/api/people/313/?format=api",
        "name": "Jianfeng Tan",
        "email": "jianfeng.tan@intel.com"
    },
    "delegate": {
        "id": 355,
        "url": "https://patches.dpdk.org/api/users/355/?format=api",
        "username": "yliu",
        "first_name": "Yuanhan",
        "last_name": "Liu",
        "email": "yuanhan.liu@linux.intel.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1461637474-110602-1-git-send-email-jianfeng.tan@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/12225/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/12225/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 694DD2E81;\n\tTue, 26 Apr 2016 04:24:37 +0200 (CEST)",
            "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby dpdk.org (Postfix) with ESMTP id D67C12BC6\n\tfor <dev@dpdk.org>; Tue, 26 Apr 2016 04:24:35 +0200 (CEST)",
            "from fmsmga004.fm.intel.com ([10.253.24.48])\n\tby fmsmga101.fm.intel.com with ESMTP; 25 Apr 2016 19:24:35 -0700",
            "from dpdk06.sh.intel.com ([10.239.128.225])\n\tby fmsmga004.fm.intel.com with ESMTP; 25 Apr 2016 19:24:33 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.24,535,1455004800\"; d=\"scan'208\";a=\"91865700\"",
        "From": "Jianfeng Tan <jianfeng.tan@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "huawei.xie@intel.com, yuanhan.liu@intel.com, david.marchand@6wind.com,\n\tJianfeng Tan <jianfeng.tan@intel.com>",
        "Date": "Tue, 26 Apr 2016 02:24:34 +0000",
        "Message-Id": "<1461637474-110602-1-git-send-email-jianfeng.tan@intel.com>",
        "X-Mailer": "git-send-email 2.1.4",
        "Subject": "[dpdk-dev] [PATCH] virtio: fix modify drv_flags for specific device",
        "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": "Issue: virtio's drv_flags are decided by devices types (modern vs legacy),\nand which kernel driver is used, and the negotiated features (especially\nVIRTIO_NET_STATUS) with backend, which makes it possible to multiple\nvirtio devices have different versions of drv_flags, but this variable\nis currently shared by each virtio device.\n\nHow to fix: dev_flags is a device-specific variable to store this info.\n\nFixes: da978dfdc43 (\"virtio: use port IO to get PCI resource\")\n\nReported-by: David Marchand <david.marchand@6wind.com>\nSuggested-by: David Marchand <david.marchand@6wind.com>\nSigned-off-by: Jianfeng Tan <jianfeng.tan@intel.com>\n---\n drivers/net/virtio/virtio_ethdev.c | 27 ++++++++++++++++-----------\n drivers/net/virtio/virtio_pci.c    | 13 +++++++------\n drivers/net/virtio/virtio_pci.h    |  3 ++-\n 3 files changed, 25 insertions(+), 18 deletions(-)",
    "diff": "diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c\nindex 63a368a..b144a58 100644\n--- a/drivers/net/virtio/virtio_ethdev.c\n+++ b/drivers/net/virtio/virtio_ethdev.c\n@@ -59,6 +59,7 @@\n #include \"virtqueue.h\"\n #include \"virtio_rxtx.h\"\n \n+#define VIRTIO_DRV_FLAGS\tRTE_PCI_DRV_DETACHABLE\n \n static int eth_virtio_dev_init(struct rte_eth_dev *eth_dev);\n static int eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev);\n@@ -491,7 +492,6 @@ static void\n virtio_dev_close(struct rte_eth_dev *dev)\n {\n \tstruct virtio_hw *hw = dev->data->dev_private;\n-\tstruct rte_pci_device *pci_dev = dev->pci_dev;\n \n \tPMD_INIT_LOG(DEBUG, \"virtio_dev_close\");\n \n@@ -499,7 +499,7 @@ virtio_dev_close(struct rte_eth_dev *dev)\n \t\tvirtio_dev_stop(dev);\n \n \t/* reset the NIC */\n-\tif (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)\n+\tif (dev->data->dev_flags & RTE_PCI_DRV_INTR_LSC)\n \t\tvtpci_irq_config(hw, VIRTIO_MSI_NO_VECTOR);\n \tvtpci_reset(hw);\n \tvirtio_dev_free_mbufs(dev);\n@@ -1034,6 +1034,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)\n \tstruct virtio_net_config *config;\n \tstruct virtio_net_config local_config;\n \tstruct rte_pci_device *pci_dev;\n+\tuint32_t dev_flags = VIRTIO_DRV_FLAGS;\n \tint ret;\n \n \tRTE_BUILD_BUG_ON(RTE_PKTMBUF_HEADROOM < sizeof(struct virtio_net_hdr));\n@@ -1057,7 +1058,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)\n \n \tpci_dev = eth_dev->pci_dev;\n \n-\tret = vtpci_init(pci_dev, hw);\n+\tret = vtpci_init(pci_dev, hw, &dev_flags);\n \tif (ret)\n \t\treturn ret;\n \n@@ -1074,9 +1075,15 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)\n \n \t/* If host does not support status then disable LSC */\n \tif (!vtpci_with_feature(hw, VIRTIO_NET_F_STATUS))\n-\t\tpci_dev->driver->drv_flags &= ~RTE_PCI_DRV_INTR_LSC;\n+\t\tdev_flags &= ~RTE_PCI_DRV_INTR_LSC;\n \n \trte_eth_copy_pci_info(eth_dev, pci_dev);\n+\t/* For virtio devices, dev_flags are decided according to feature\n+\t * negotiation, aka if VIRTIO_NET_F_STATUS is set, and which kernel\n+\t * driver is used, dynamically. And we should keep drv_flags shared\n+\t * and unvaried.\n+\t */\n+\teth_dev->data->dev_flags = dev_flags;\n \n \trx_func_get(eth_dev);\n \n@@ -1155,7 +1162,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)\n \t\t\tpci_dev->id.device_id);\n \n \t/* Setup interrupt callback  */\n-\tif (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)\n+\tif (eth_dev->data->dev_flags & RTE_PCI_DRV_INTR_LSC)\n \t\trte_intr_callback_register(&pci_dev->intr_handle,\n \t\t\t\t   virtio_interrupt_handler, eth_dev);\n \n@@ -1190,7 +1197,7 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)\n \teth_dev->data->mac_addrs = NULL;\n \n \t/* reset interrupt callback  */\n-\tif (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)\n+\tif (eth_dev->data->dev_flags & RTE_PCI_DRV_INTR_LSC)\n \t\trte_intr_callback_unregister(&pci_dev->intr_handle,\n \t\t\t\t\t\tvirtio_interrupt_handler,\n \t\t\t\t\t\teth_dev);\n@@ -1205,7 +1212,7 @@ static struct eth_driver rte_virtio_pmd = {\n \t.pci_drv = {\n \t\t.name = \"rte_virtio_pmd\",\n \t\t.id_table = pci_id_virtio_map,\n-\t\t.drv_flags = RTE_PCI_DRV_DETACHABLE,\n+\t\t.drv_flags = VIRTIO_DRV_FLAGS,\n \t},\n \t.eth_dev_init = eth_virtio_dev_init,\n \t.eth_dev_uninit = eth_virtio_dev_uninit,\n@@ -1240,7 +1247,6 @@ virtio_dev_configure(struct rte_eth_dev *dev)\n {\n \tconst struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;\n \tstruct virtio_hw *hw = dev->data->dev_private;\n-\tstruct rte_pci_device *pci_dev = dev->pci_dev;\n \n \tPMD_INIT_LOG(DEBUG, \"configure\");\n \n@@ -1258,7 +1264,7 @@ virtio_dev_configure(struct rte_eth_dev *dev)\n \t\treturn -ENOTSUP;\n \t}\n \n-\tif (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)\n+\tif (dev->data->dev_flags & RTE_PCI_DRV_INTR_LSC)\n \t\tif (vtpci_irq_config(hw, 0) == VIRTIO_MSI_NO_VECTOR) {\n \t\t\tPMD_DRV_LOG(ERR, \"failed to set config vector\");\n \t\t\treturn -EBUSY;\n@@ -1273,11 +1279,10 @@ virtio_dev_start(struct rte_eth_dev *dev)\n {\n \tuint16_t nb_queues, i;\n \tstruct virtio_hw *hw = dev->data->dev_private;\n-\tstruct rte_pci_device *pci_dev = dev->pci_dev;\n \n \t/* check if lsc interrupt feature is enabled */\n \tif (dev->data->dev_conf.intr_conf.lsc) {\n-\t\tif (!(pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC)) {\n+\t\tif (!(dev->data->dev_flags & RTE_PCI_DRV_INTR_LSC)) {\n \t\t\tPMD_DRV_LOG(ERR, \"link status not supported by host\");\n \t\t\treturn -ENOTSUP;\n \t\t}\ndiff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c\nindex c007959..78afe94 100644\n--- a/drivers/net/virtio/virtio_pci.c\n+++ b/drivers/net/virtio/virtio_pci.c\n@@ -199,15 +199,15 @@ legacy_virtio_has_msix(const struct rte_pci_addr *loc __rte_unused)\n \n static int\n legacy_virtio_resource_init(struct rte_pci_device *pci_dev,\n-\t\t\t    struct virtio_hw *hw)\n+\t\t\t    struct virtio_hw *hw, uint32_t *dev_flags)\n {\n \tif (rte_eal_pci_ioport_map(pci_dev, 0, &hw->io) < 0)\n \t\treturn -1;\n \n \tif (pci_dev->intr_handle.type != RTE_INTR_HANDLE_UNKNOWN)\n-\t\tpci_dev->driver->drv_flags |= RTE_PCI_DRV_INTR_LSC;\n+\t\t*dev_flags |= RTE_PCI_DRV_INTR_LSC;\n \telse\n-\t\tpci_dev->driver->drv_flags &= ~RTE_PCI_DRV_INTR_LSC;\n+\t\t*dev_flags &= ~RTE_PCI_DRV_INTR_LSC;\n \n \treturn 0;\n }\n@@ -630,7 +630,8 @@ next:\n  * Return 0 on success.\n  */\n int\n-vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)\n+vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw,\n+\t   uint32_t *dev_flags)\n {\n \thw->dev = dev;\n \n@@ -643,12 +644,12 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)\n \t\tPMD_INIT_LOG(INFO, \"modern virtio pci detected.\");\n \t\thw->vtpci_ops = &modern_ops;\n \t\thw->modern    = 1;\n-\t\tdev->driver->drv_flags |= RTE_PCI_DRV_INTR_LSC;\n+\t\t*dev_flags |= RTE_PCI_DRV_INTR_LSC;\n \t\treturn 0;\n \t}\n \n \tPMD_INIT_LOG(INFO, \"trying with legacy virtio pci.\");\n-\tif (legacy_virtio_resource_init(dev, hw) < 0) {\n+\tif (legacy_virtio_resource_init(dev, hw, dev_flags) < 0) {\n \t\tif (dev->kdrv == RTE_KDRV_UNKNOWN &&\n \t\t    dev->devargs->type != RTE_DEVTYPE_WHITELISTED_PCI) {\n \t\t\tPMD_INIT_LOG(INFO,\ndiff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h\nindex b69785e..554efea 100644\n--- a/drivers/net/virtio/virtio_pci.h\n+++ b/drivers/net/virtio/virtio_pci.h\n@@ -293,7 +293,8 @@ vtpci_with_feature(struct virtio_hw *hw, uint64_t bit)\n /*\n  * Function declaration from virtio_pci.c\n  */\n-int vtpci_init(struct rte_pci_device *, struct virtio_hw *);\n+int vtpci_init(struct rte_pci_device *, struct virtio_hw *,\n+\t       uint32_t *dev_flags);\n void vtpci_reset(struct virtio_hw *);\n \n void vtpci_reinit_complete(struct virtio_hw *);\n",
    "prefixes": [
        "dpdk-dev"
    ]
}