get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2522,
    "url": "https://patches.dpdk.org/api/patches/2522/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1422326164-13697-5-git-send-email-changchun.ouyang@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": "<1422326164-13697-5-git-send-email-changchun.ouyang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1422326164-13697-5-git-send-email-changchun.ouyang@intel.com",
    "date": "2015-01-27T02:35:44",
    "name": "[dpdk-dev,v2,04/24] virtio: Add support for Link State interrupt",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "e0ab492b1c2e45f39b8eaeede846d820a6786775",
    "submitter": {
        "id": 31,
        "url": "https://patches.dpdk.org/api/people/31/?format=api",
        "name": "Ouyang Changchun",
        "email": "changchun.ouyang@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1422326164-13697-5-git-send-email-changchun.ouyang@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/2522/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/2522/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 06EB35AB3;\n\tTue, 27 Jan 2015 03:37:40 +0100 (CET)",
            "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby dpdk.org (Postfix) with ESMTP id 66CC45A9C\n\tfor <dev@dpdk.org>; Tue, 27 Jan 2015 03:36:23 +0100 (CET)",
            "from orsmga001.jf.intel.com ([10.7.209.18])\n\tby fmsmga103.fm.intel.com with ESMTP; 26 Jan 2015 18:30:17 -0800",
            "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby orsmga001.jf.intel.com with ESMTP; 26 Jan 2015 18:36:21 -0800",
            "from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com\n\t[10.239.29.89])\n\tby shvmail01.sh.intel.com with ESMTP id t0R2aIE1014830;\n\tTue, 27 Jan 2015 10:36:18 +0800",
            "from shecgisg004.sh.intel.com (localhost [127.0.0.1])\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP\n\tid t0R2aGZS013758; Tue, 27 Jan 2015 10:36:18 +0800",
            "(from couyang@localhost)\n\tby shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t0R2aFZL013754; \n\tTue, 27 Jan 2015 10:36:15 +0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.09,471,1418112000\"; d=\"scan'208\";a=\"642963530\"",
        "From": "Ouyang Changchun <changchun.ouyang@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Tue, 27 Jan 2015 10:35:44 +0800",
        "Message-Id": "<1422326164-13697-5-git-send-email-changchun.ouyang@intel.com>",
        "X-Mailer": "git-send-email 1.7.12.2",
        "In-Reply-To": "<1422326164-13697-1-git-send-email-changchun.ouyang@intel.com>",
        "References": "<1421298930-15210-1-git-send-email-changchun.ouyang@intel.com>\n\t<1422326164-13697-1-git-send-email-changchun.ouyang@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v2 04/24] virtio: Add support for Link State\n\tinterrupt",
        "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": "Virtio has link state interrupt which can be used.\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\nSigned-off-by: Changchun Ouyang <changchun.ouyang@intel.com>\n---\n lib/librte_pmd_virtio/virtio_ethdev.c | 78 +++++++++++++++++++++++++++--------\n lib/librte_pmd_virtio/virtio_pci.c    | 22 ++++++++++\n lib/librte_pmd_virtio/virtio_pci.h    |  4 ++\n 3 files changed, 86 insertions(+), 18 deletions(-)",
    "diff": "diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c b/lib/librte_pmd_virtio/virtio_ethdev.c\nindex 5df3b54..ef87ff8 100644\n--- a/lib/librte_pmd_virtio/virtio_ethdev.c\n+++ b/lib/librte_pmd_virtio/virtio_ethdev.c\n@@ -845,6 +845,34 @@ static int virtio_resource_init(struct rte_pci_device *pci_dev __rte_unused)\n #endif\n \n /*\n+ * Process Virtio Config changed interrupt and call the callback\n+ * if link state changed.\n+ */\n+static void\n+virtio_interrupt_handler(__rte_unused struct rte_intr_handle *handle,\n+\t\t\t void *param)\n+{\n+\tstruct rte_eth_dev *dev = param;\n+\tstruct virtio_hw *hw =\n+\t\tVIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n+\tuint8_t isr;\n+\n+\t/* Read interrupt status which clears interrupt */\n+\tisr = vtpci_isr(hw);\n+\tPMD_DRV_LOG(INFO, \"interrupt status = %#x\", isr);\n+\n+\tif (rte_intr_enable(&dev->pci_dev->intr_handle) < 0)\n+\t\tPMD_DRV_LOG(ERR, \"interrupt enable failed\");\n+\n+\tif (isr & VIRTIO_PCI_ISR_CONFIG) {\n+\t\tif (virtio_dev_link_update(dev, 0) == 0)\n+\t\t\t_rte_eth_dev_callback_process(dev,\n+\t\t\t\t\t\t      RTE_ETH_EVENT_INTR_LSC);\n+\t}\n+\n+}\n+\n+/*\n  * This function is based on probe() function in virtio_pci.c\n  * It returns 0 on success.\n  */\n@@ -968,6 +996,10 @@ eth_virtio_dev_init(__rte_unused struct eth_driver *eth_drv,\n \tPMD_INIT_LOG(DEBUG, \"port %d vendorID=0x%x deviceID=0x%x\",\n \t\t\teth_dev->data->port_id, pci_dev->id.vendor_id,\n \t\t\tpci_dev->id.device_id);\n+\n+\t/* Setup interrupt callback  */\n+\trte_intr_callback_register(&pci_dev->intr_handle,\n+\t\t\t\t   virtio_interrupt_handler, eth_dev);\n \treturn 0;\n }\n \n@@ -975,7 +1007,7 @@ static struct eth_driver rte_virtio_pmd = {\n \t{\n \t\t.name = \"rte_virtio_pmd\",\n \t\t.id_table = pci_id_virtio_map,\n-\t\t.drv_flags = RTE_PCI_DRV_NEED_MAPPING,\n+\t\t.drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,\n \t},\n \t.eth_dev_init = eth_virtio_dev_init,\n \t.dev_private_size = sizeof(struct virtio_adapter),\n@@ -1021,6 +1053,9 @@ static int\n 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 =\n+\t\tVIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n+\tint ret;\n \n \tPMD_INIT_LOG(DEBUG, \"configure\");\n \n@@ -1029,7 +1064,11 @@ virtio_dev_configure(struct rte_eth_dev *dev)\n \t\treturn (-EINVAL);\n \t}\n \n-\treturn 0;\n+\tret = vtpci_irq_config(hw, 0);\n+\tif (ret != 0)\n+\t\tPMD_DRV_LOG(ERR, \"failed to set config vector\");\n+\n+\treturn ret;\n }\n \n \n@@ -1037,7 +1076,6 @@ static int\n virtio_dev_start(struct rte_eth_dev *dev)\n {\n \tuint16_t nb_queues, i;\n-\tuint16_t status;\n \tstruct virtio_hw *hw =\n \t\tVIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n \n@@ -1052,18 +1090,22 @@ virtio_dev_start(struct rte_eth_dev *dev)\n \t/* Do final configuration before rx/tx engine starts */\n \tvirtio_dev_rxtx_start(dev);\n \n-\t/* Check VIRTIO_NET_F_STATUS for link status*/\n-\tif (vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) {\n-\t\tvtpci_read_dev_config(hw,\n-\t\t\t\toffsetof(struct virtio_net_config, status),\n-\t\t\t\t&status, sizeof(status));\n-\t\tif ((status & VIRTIO_NET_S_LINK_UP) == 0)\n-\t\t\tPMD_INIT_LOG(ERR, \"Port: %d Link is DOWN\",\n-\t\t\t\t     dev->data->port_id);\n-\t\telse\n-\t\t\tPMD_INIT_LOG(DEBUG, \"Port: %d Link is UP\",\n-\t\t\t\t     dev->data->port_id);\n+\t/* check if lsc interrupt feature is enabled */\n+\tif (dev->data->dev_conf.intr_conf.lsc) {\n+\t\tif (!vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) {\n+\t\t\tPMD_DRV_LOG(ERR, \"link status not supported by host\");\n+\t\t\treturn -ENOTSUP;\n+\t\t}\n+\n+\t\tif (rte_intr_enable(&dev->pci_dev->intr_handle) < 0) {\n+\t\t\tPMD_DRV_LOG(ERR, \"interrupt enable failed\");\n+\t\t\treturn -EIO;\n+\t\t}\n \t}\n+\n+\t/* Initialize Link state */\n+\tvirtio_dev_link_update(dev, 0);\n+\n \tvtpci_reinit_complete(hw);\n \n \t/*Notify the backend\n@@ -1145,6 +1187,7 @@ virtio_dev_stop(struct rte_eth_dev *dev)\n \t\tVIRTIO_DEV_PRIVATE_TO_HW(dev->data->dev_private);\n \n \t/* reset the NIC */\n+\tvtpci_irq_config(hw, 0);\n \tvtpci_reset(hw);\n \tvirtio_dev_free_mbufs(dev);\n }\n@@ -1161,6 +1204,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet\n \told = link;\n \tlink.link_duplex = FULL_DUPLEX;\n \tlink.link_speed  = SPEED_10G;\n+\n \tif (vtpci_with_feature(hw, VIRTIO_NET_F_STATUS)) {\n \t\tPMD_INIT_LOG(DEBUG, \"Get link status from hw\");\n \t\tvtpci_read_dev_config(hw,\n@@ -1179,10 +1223,8 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet\n \t\tlink.link_status = 1;   /* Link up */\n \t}\n \tvirtio_dev_atomic_write_link_status(dev, &link);\n-\tif (old.link_status == link.link_status)\n-\t\treturn -1;\n-\t/*changed*/\n-\treturn 0;\n+\n+\treturn (old.link_status == link.link_status) ? -1 : 0;\n }\n \n static void\ndiff --git a/lib/librte_pmd_virtio/virtio_pci.c b/lib/librte_pmd_virtio/virtio_pci.c\nindex ca9c748..6d51032 100644\n--- a/lib/librte_pmd_virtio/virtio_pci.c\n+++ b/lib/librte_pmd_virtio/virtio_pci.c\n@@ -127,3 +127,25 @@ vtpci_set_status(struct virtio_hw *hw, uint8_t status)\n \n \tVIRTIO_WRITE_REG_1(hw, VIRTIO_PCI_STATUS, status);\n }\n+\n+uint8_t\n+vtpci_isr(struct virtio_hw *hw)\n+{\n+\n+\treturn VIRTIO_READ_REG_1(hw, VIRTIO_PCI_ISR);\n+}\n+\n+\n+/* Enable one vector (0) for Link State Intrerrupt */\n+int\n+vtpci_irq_config(struct virtio_hw *hw, uint16_t vec)\n+{\n+\tVIRTIO_WRITE_REG_2(hw, VIRTIO_MSI_CONFIG_VECTOR, vec);\n+\tvec = VIRTIO_READ_REG_2(hw, VIRTIO_MSI_CONFIG_VECTOR);\n+\tif (vec == VIRTIO_MSI_NO_VECTOR) {\n+\t\tPMD_DRV_LOG(ERR, \"failed to set config vector\");\n+\t\treturn -EBUSY;\n+\t}\n+\n+\treturn 0;\n+}\ndiff --git a/lib/librte_pmd_virtio/virtio_pci.h b/lib/librte_pmd_virtio/virtio_pci.h\nindex 373f9dc..6998737 100644\n--- a/lib/librte_pmd_virtio/virtio_pci.h\n+++ b/lib/librte_pmd_virtio/virtio_pci.h\n@@ -263,4 +263,8 @@ void vtpci_write_dev_config(struct virtio_hw *, uint64_t, void *, int);\n \n void vtpci_read_dev_config(struct virtio_hw *, uint64_t, void *, int);\n \n+uint8_t vtpci_isr(struct virtio_hw *);\n+\n+int vtpci_irq_config(struct virtio_hw *, uint16_t);\n+\n #endif /* _VIRTIO_PCI_H_ */\n",
    "prefixes": [
        "dpdk-dev",
        "v2",
        "04/24"
    ]
}