Show a patch.

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

{
    "id": 212,
    "url": "https://patches.dpdk.org/api/patches/212/?format=api",
    "web_url": "https://patches.dpdk.org/patch/212/",
    "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"
    },
    "msgid": "<20140826020843.806847742@networkplumber.org>",
    "date": "2014-08-26T02:07:50",
    "name": "[dpdk-dev,RFC,04/10] virtio: add support for Link State interrupt",
    "commit_ref": null,
    "pull_url": null,
    "state": "rfc",
    "archived": true,
    "hash": "e0ab492b1c2e45f39b8eaeede846d820a6786775",
    "submitter": {
        "id": 27,
        "url": "https://patches.dpdk.org/api/people/27/?format=api",
        "name": "Stephen Hemminger",
        "email": "stephen@networkplumber.org"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/patch/212/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/212/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/212/checks/",
    "tags": {},
    "headers": {
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "Return-Path": "<stephen@networkplumber.org>",
        "To": "Ouyang Changchun <changchun.ouyang@intel.com>",
        "Message-Id": "<20140826020843.806847742@networkplumber.org>",
        "X-Gm-Message-State": "ALoCoQmD3fKEV3FGdfA5L/bCzUqtFIQcpc8TlFCrcnoy+/jCz1HLMT+6jKr8I2+SILh/6dTUSROe",
        "User-Agent": "quilt/0.63-1",
        "Cc": "dev@dpdk.org, Stephen Hemminger <shemming@brocade.com>",
        "X-BeenThere": "dev@dpdk.org",
        "Received": [
            "from mail-pa0-f47.google.com (mail-pa0-f47.google.com\n\t[209.85.220.47]) by dpdk.org (Postfix) with ESMTP id 981853975\n\tfor <dev@dpdk.org>; Tue, 26 Aug 2014 04:04:48 +0200 (CEST)",
            "by mail-pa0-f47.google.com with SMTP id kx10so22407930pab.20\n\tfor <dev@dpdk.org>; Mon, 25 Aug 2014 19:08:45 -0700 (PDT)",
            "from localhost (static-50-53-65-80.bvtn.or.frontiernet.net.\n\t[50.53.65.80]) by mx.google.com with ESMTPSA id\n\tyw4sm1143156pbc.69.2014.08.25.19.08.44 for <multiple recipients>\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tMon, 25 Aug 2014 19:08:45 -0700 (PDT)"
        ],
        "Subject": "[dpdk-dev] [RFC 04/10] virtio: add support for Link State interrupt",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Date": "Mon, 25 Aug 2014 19:07:50 -0700",
        "Precedence": "list",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "X-Received": "by 10.68.195.228 with SMTP id ih4mr663471pbc.167.1409018925755; \n\tMon, 25 Aug 2014 19:08:45 -0700 (PDT)",
        "MIME-Version": "1.0",
        "References": "<20140826020746.062748014@networkplumber.org>",
        "Content-Disposition": "inline; filename=virtio-lsc.patch",
        "X-List-Received-Date": "Tue, 26 Aug 2014 02:04:49 -0000",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "Content-Type": "text/plain; charset=UTF-8",
        "X-Mailman-Version": "2.1.15",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20130820;\n\th=x-gm-message-state:message-id:user-agent:date:from:to:cc:subject\n\t:references:mime-version:content-type:content-disposition;\n\tbh=e/50CcV3ZU5cPvdXefh19EBPhPuvMIDx+u0RldTLSmQ=;\n\tb=ZBgRlA+D6JiZmTaYWULollw5V7ndczfq1iWxGIZQ+/dYRXiRVdguY7BQ1lI3RsVfS0\n\tQKdi4QcY/kikh3MoueygpiE21bTQzk0XgGCjyrMaI1eKEGgi6uyT4388Qi5pQEGd8buQ\n\touoQ+G4kajlt3Brot5EH36z+uzWx0RXBrX2C9gusXgnaNFYiA65WiAmPTiyw63MNHJtG\n\tyIeVfK8D20nclBcnimJM2IrInkn8bLcOHhlbGc7UeeTUfwgQbkUj7khF5koWhT81nfPj\n\t3Z97ukvSXZeqsJkkHrhvwDJYdH/nRSJS2+SPcrLLYJRjWwLvWAHOdwC3y0bX0dsvaw8P\n\tK1xg==",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>"
    },
    "content": "Virtio has link state interrupt which can be used.\n\nSigned-off-by: Stephen Hemminger <shemming@brocade.com>\n\n\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": "--- a/lib/librte_pmd_virtio/virtio_ethdev.c\t2014-08-25 19:00:06.342530488 -0700\n+++ b/lib/librte_pmd_virtio/virtio_ethdev.c\t2014-08-25 19:00:06.342530488 -0700\n@@ -757,6 +757,34 @@ static int virtio_resource_init(struct r\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@@ -886,6 +914,10 @@ eth_virtio_dev_init(__rte_unused struct\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@@ -893,7 +925,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@@ -933,6 +965,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@@ -941,7 +976,11 @@ virtio_dev_configure(struct rte_eth_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@@ -949,7 +988,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@@ -964,18 +1002,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@@ -1057,6 +1099,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@@ -1073,6 +1116,7 @@ virtio_dev_link_update(struct rte_eth_de\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@@ -1091,10 +1135,8 @@ virtio_dev_link_update(struct rte_eth_de\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\n--- a/lib/librte_pmd_virtio/virtio_pci.c\t2014-08-25 19:00:06.342530488 -0700\n+++ b/lib/librte_pmd_virtio/virtio_pci.c\t2014-08-25 19:00:06.342530488 -0700\n@@ -127,3 +127,25 @@ vtpci_set_status(struct virtio_hw *hw, u\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+}\n--- a/lib/librte_pmd_virtio/virtio_pci.h\t2014-08-25 19:00:06.342530488 -0700\n+++ b/lib/librte_pmd_virtio/virtio_pci.h\t2014-08-25 19:00:06.342530488 -0700\n@@ -263,4 +263,8 @@ void vtpci_write_dev_config(struct virti\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",
        "RFC",
        "04/10"
    ]
}