get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 56944,
    "url": "http://patches.dpdk.org/api/patches/56944/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20190723053821.30227-5-vattunuru@marvell.com/",
    "project": {
        "id": 1,
        "url": "http://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": "<20190723053821.30227-5-vattunuru@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20190723053821.30227-5-vattunuru@marvell.com",
    "date": "2019-07-23T05:38:20",
    "name": "[v8,4/5] kni: add IOVA=VA support in KNI module",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "7f1a9d3fdfd51217fd64d4106ca2aff08e69371e",
    "submitter": {
        "id": 1277,
        "url": "http://patches.dpdk.org/api/people/1277/?format=api",
        "name": "Vamsi Krishna Attunuru",
        "email": "vattunuru@marvell.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20190723053821.30227-5-vattunuru@marvell.com/mbox/",
    "series": [
        {
            "id": 5662,
            "url": "http://patches.dpdk.org/api/series/5662/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=5662",
            "date": "2019-07-23T05:38:16",
            "name": "kni: add IOVA=VA support",
            "version": 8,
            "mbox": "http://patches.dpdk.org/series/5662/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/56944/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/56944/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 357D61BFA5;\n\tTue, 23 Jul 2019 07:38:57 +0200 (CEST)",
            "from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com\n\t[67.231.156.173]) by dpdk.org (Postfix) with ESMTP id EA14A1BFA5\n\tfor <dev@dpdk.org>; Tue, 23 Jul 2019 07:38:54 +0200 (CEST)",
            "from pps.filterd (m0045851.ppops.net [127.0.0.1])\n\tby mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id\n\tx6N5ZGsx011520; Mon, 22 Jul 2019 22:38:54 -0700",
            "from sc-exch04.marvell.com ([199.233.58.184])\n\tby mx0b-0016f401.pphosted.com with ESMTP id 2tv2fj9gvq-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); \n\tMon, 22 Jul 2019 22:38:54 -0700",
            "from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH04.marvell.com\n\t(10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3;\n\tMon, 22 Jul 2019 22:38:52 -0700",
            "from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com\n\t(10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend\n\tTransport; Mon, 22 Jul 2019 22:38:52 -0700",
            "from hyd1vattunuru-dt.caveonetworks.com (unknown [10.29.52.72])\n\tby maili.marvell.com (Postfix) with ESMTP id 0A7673F703F;\n\tMon, 22 Jul 2019 22:38:48 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n\th=from : to : cc :\n\tsubject : date : message-id : in-reply-to : references : mime-version\n\t: content-type; s=pfpt0818;\n\tbh=wrJ7dmEvfYWq0F0wL+W2XOIDPUfHjFpoi3HHcMqwKjg=; \n\tb=U5XGX5gPtpHRbFqAxp7sojAVOafz+mSMBSlAuwcIS131wCBjcVU/lvWiIP6Ly+zjA3ps\n\ts+L+CxyoafFE5VHpTl/6xTpoHvfv4Fi2CAoNNR+FbLGeHOW6zJ7JMsazIJnf9HLZr0X1\n\thxq20HkzFI30U3Yeq5LkNblUo+73P/AiE9pods91vKBV8PONUbVQv9pES9RrRFcL/wCP\n\tYrC41JJTNrv5QmVmgIBwNdwq32EBtPjgC+bR5O+22uBs3PnGY16g9iGZUXpKfYir19Xa\n\tqyAMtbK6/2pOViKcYt9GNSyfiaSTLcmcFyEKAU9L2+kjpVMTxVV7Go4k8szd+jd1/lfP\n\t8w== ",
        "From": "<vattunuru@marvell.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<thomas@monjalon.net>, <jerinj@marvell.com>, <olivier.matz@6wind.com>,\n\t<ferruh.yigit@intel.com>, <anatoly.burakov@intel.com>,\n\t<arybchenko@solarflare.com>, <kirankumark@marvell.com>, Vamsi Attunuru\n\t<vattunuru@marvell.com>",
        "Date": "Tue, 23 Jul 2019 11:08:20 +0530",
        "Message-ID": "<20190723053821.30227-5-vattunuru@marvell.com>",
        "X-Mailer": "git-send-email 2.8.4",
        "In-Reply-To": "<20190723053821.30227-1-vattunuru@marvell.com>",
        "References": "<20190717090408.13717-1-vattunuru@marvell.com>\n\t<20190723053821.30227-1-vattunuru@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Proofpoint-Virus-Version": "vendor=fsecure engine=2.50.10434:5.22.84,1.0.8\n\tdefinitions=2019-07-23_03:2019-07-23,2019-07-23 signatures=0",
        "Subject": "[dpdk-dev]  [PATCH v8 4/5] kni: add IOVA=VA support in KNI module",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Kiran Kumar K <kirankumark@marvell.com>\n\nPatch adds support for kernel module to work in IOVA = VA mode,\nthe idea is to get physical address from IOVA address using\niommu_iova_to_phys API and later use phys_to_virt API to\nconvert the physical address to kernel virtual address.\n\nWhen compared with IOVA = PA mode, there is no performance\ndrop with this approach.\n\nThis approach does not work with the kernel versions less\nthan 4.4.0 because of API compatibility issues.\n\nPatch also updates these support details in KNI documentation.\n\nSigned-off-by: Kiran Kumar K <kirankumark@marvell.com>\nSigned-off-by: Vamsi Attunuru <vattunuru@marvell.com>\n---\n kernel/linux/kni/compat.h   |  4 +++\n kernel/linux/kni/kni_dev.h  |  4 +++\n kernel/linux/kni/kni_misc.c | 71 +++++++++++++++++++++++++++++++++++++++------\n kernel/linux/kni/kni_net.c  | 59 ++++++++++++++++++++++++++++---------\n 4 files changed, 116 insertions(+), 22 deletions(-)",
    "diff": "diff --git a/kernel/linux/kni/compat.h b/kernel/linux/kni/compat.h\nindex 562d8bf..ee997a6 100644\n--- a/kernel/linux/kni/compat.h\n+++ b/kernel/linux/kni/compat.h\n@@ -121,3 +121,7 @@\n #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)\n #define HAVE_SIGNAL_FUNCTIONS_OWN_HEADER\n #endif\n+\n+#if KERNEL_VERSION(4, 4, 0) <= LINUX_VERSION_CODE\n+#define HAVE_IOVA_AS_VA_SUPPORT\n+#endif\ndiff --git a/kernel/linux/kni/kni_dev.h b/kernel/linux/kni/kni_dev.h\nindex c1ca678..d5898f3 100644\n--- a/kernel/linux/kni/kni_dev.h\n+++ b/kernel/linux/kni/kni_dev.h\n@@ -25,6 +25,7 @@\n #include <linux/netdevice.h>\n #include <linux/spinlock.h>\n #include <linux/list.h>\n+#include <linux/iommu.h>\n \n #include <rte_kni_common.h>\n #define KNI_KTHREAD_RESCHEDULE_INTERVAL 5 /* us */\n@@ -41,6 +42,9 @@ struct kni_dev {\n \t/* kni list */\n \tstruct list_head list;\n \n+\tuint8_t iova_mode;\n+\tstruct iommu_domain *domain;\n+\n \tuint32_t core_id;            /* Core ID to bind */\n \tchar name[RTE_KNI_NAMESIZE]; /* Network device name */\n \tstruct task_struct *pthread;\ndiff --git a/kernel/linux/kni/kni_misc.c b/kernel/linux/kni/kni_misc.c\nindex 2b75502..8660205 100644\n--- a/kernel/linux/kni/kni_misc.c\n+++ b/kernel/linux/kni/kni_misc.c\n@@ -295,6 +295,9 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num,\n \tstruct rte_kni_device_info dev_info;\n \tstruct net_device *net_dev = NULL;\n \tstruct kni_dev *kni, *dev, *n;\n+\tstruct pci_dev *pci = NULL;\n+\tstruct iommu_domain *domain = NULL;\n+\tphys_addr_t phys_addr;\n \n \tpr_info(\"Creating kni...\\n\");\n \t/* Check the buffer size, to avoid warning */\n@@ -348,15 +351,65 @@ kni_ioctl_create(struct net *net, uint32_t ioctl_num,\n \tstrncpy(kni->name, dev_info.name, RTE_KNI_NAMESIZE);\n \n \t/* Translate user space info into kernel space info */\n-\tkni->tx_q = phys_to_virt(dev_info.tx_phys);\n-\tkni->rx_q = phys_to_virt(dev_info.rx_phys);\n-\tkni->alloc_q = phys_to_virt(dev_info.alloc_phys);\n-\tkni->free_q = phys_to_virt(dev_info.free_phys);\n-\n-\tkni->req_q = phys_to_virt(dev_info.req_phys);\n-\tkni->resp_q = phys_to_virt(dev_info.resp_phys);\n-\tkni->sync_va = dev_info.sync_va;\n-\tkni->sync_kva = phys_to_virt(dev_info.sync_phys);\n+\tif (dev_info.iova_mode) {\n+#ifdef HAVE_IOVA_AS_VA_SUPPORT\n+\t\tpci = pci_get_device(dev_info.vendor_id,\n+\t\t\t\t     dev_info.device_id, NULL);\n+\t\tif (pci == NULL) {\n+\t\t\tpr_err(\"pci dev does not exist\\n\");\n+\t\t\treturn -ENODEV;\n+\t\t}\n+\n+\t\twhile (pci) {\n+\t\t\tif ((pci->bus->number == dev_info.bus) &&\n+\t\t\t    (PCI_SLOT(pci->devfn) == dev_info.devid) &&\n+\t\t\t    (PCI_FUNC(pci->devfn) == dev_info.function)) {\n+\t\t\t\tdomain = iommu_get_domain_for_dev(&pci->dev);\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tpci = pci_get_device(dev_info.vendor_id,\n+\t\t\t\t\t     dev_info.device_id, pci);\n+\t\t}\n+\n+\t\tif (domain == NULL) {\n+\t\t\tpr_err(\"Failed to get pci dev domain info\\n\");\n+\t\t\treturn -ENODEV;\n+\t\t}\n+#else\n+\t\tpr_err(\"Kernel version does not support IOVA as VA\\n\");\n+\t\treturn -EINVAL;\n+#endif\n+\t\tkni->domain = domain;\n+\t\tphys_addr = iommu_iova_to_phys(domain, dev_info.tx_phys);\n+\t\tkni->tx_q = phys_to_virt(phys_addr);\n+\t\tphys_addr = iommu_iova_to_phys(domain, dev_info.rx_phys);\n+\t\tkni->rx_q = phys_to_virt(phys_addr);\n+\t\tphys_addr = iommu_iova_to_phys(domain, dev_info.alloc_phys);\n+\t\tkni->alloc_q = phys_to_virt(phys_addr);\n+\t\tphys_addr = iommu_iova_to_phys(domain, dev_info.free_phys);\n+\t\tkni->free_q = phys_to_virt(phys_addr);\n+\t\tphys_addr = iommu_iova_to_phys(domain, dev_info.req_phys);\n+\t\tkni->req_q = phys_to_virt(phys_addr);\n+\t\tphys_addr = iommu_iova_to_phys(domain, dev_info.resp_phys);\n+\t\tkni->resp_q = phys_to_virt(phys_addr);\n+\t\tkni->sync_va = dev_info.sync_va;\n+\t\tphys_addr = iommu_iova_to_phys(domain, dev_info.sync_phys);\n+\t\tkni->sync_kva = phys_to_virt(phys_addr);\n+\t\tkni->iova_mode = 1;\n+\n+\t} else {\n+\n+\t\tkni->tx_q = phys_to_virt(dev_info.tx_phys);\n+\t\tkni->rx_q = phys_to_virt(dev_info.rx_phys);\n+\t\tkni->alloc_q = phys_to_virt(dev_info.alloc_phys);\n+\t\tkni->free_q = phys_to_virt(dev_info.free_phys);\n+\n+\t\tkni->req_q = phys_to_virt(dev_info.req_phys);\n+\t\tkni->resp_q = phys_to_virt(dev_info.resp_phys);\n+\t\tkni->sync_va = dev_info.sync_va;\n+\t\tkni->sync_kva = phys_to_virt(dev_info.sync_phys);\n+\t\tkni->iova_mode = 0;\n+\t}\n \n \tkni->mbuf_size = dev_info.mbuf_size;\n \ndiff --git a/kernel/linux/kni/kni_net.c b/kernel/linux/kni/kni_net.c\nindex 7bd3a9f..8382859 100644\n--- a/kernel/linux/kni/kni_net.c\n+++ b/kernel/linux/kni/kni_net.c\n@@ -36,6 +36,21 @@ static void kni_net_rx_normal(struct kni_dev *kni);\n /* kni rx function pointer, with default to normal rx */\n static kni_net_rx_t kni_net_rx_func = kni_net_rx_normal;\n \n+/* iova to kernel virtual address */\n+static inline void *\n+iova2kva(struct kni_dev *kni, void *pa)\n+{\n+\treturn phys_to_virt(iommu_iova_to_phys(kni->domain,\n+\t\t\t\t(uintptr_t)pa));\n+}\n+\n+static inline void *\n+iova2data_kva(struct kni_dev *kni, struct rte_kni_mbuf *m)\n+{\n+\treturn phys_to_virt(iommu_iova_to_phys(kni->domain,\n+\t\t\t   (uintptr_t)m->buf_physaddr) + m->data_off);\n+}\n+\n /* physical address to kernel virtual address */\n static void *\n pa2kva(void *pa)\n@@ -62,6 +77,24 @@ kva2data_kva(struct rte_kni_mbuf *m)\n \treturn phys_to_virt(m->buf_physaddr + m->data_off);\n }\n \n+static inline void *\n+get_kva(struct kni_dev *kni, void *pa)\n+{\n+\tif (kni->iova_mode == 1)\n+\t\treturn iova2kva(kni, pa);\n+\n+\treturn pa2kva(pa);\n+}\n+\n+static inline void *\n+get_data_kva(struct kni_dev *kni, void *pkt_kva)\n+{\n+\tif (kni->iova_mode == 1)\n+\t\treturn iova2data_kva(kni, pkt_kva);\n+\n+\treturn kva2data_kva(pkt_kva);\n+}\n+\n /*\n  * It can be called to process the request.\n  */\n@@ -178,7 +211,7 @@ kni_fifo_trans_pa2va(struct kni_dev *kni,\n \t\t\treturn;\n \n \t\tfor (i = 0; i < num_rx; i++) {\n-\t\t\tkva = pa2kva(kni->pa[i]);\n+\t\t\tkva = get_kva(kni, kni->pa[i]);\n \t\t\tkni->va[i] = pa2va(kni->pa[i], kva);\n \n \t\t\tkva_nb_segs = kva->nb_segs;\n@@ -266,8 +299,8 @@ kni_net_tx(struct sk_buff *skb, struct net_device *dev)\n \tif (likely(ret == 1)) {\n \t\tvoid *data_kva;\n \n-\t\tpkt_kva = pa2kva(pkt_pa);\n-\t\tdata_kva = kva2data_kva(pkt_kva);\n+\t\tpkt_kva = get_kva(kni, pkt_pa);\n+\t\tdata_kva = get_data_kva(kni, pkt_kva);\n \t\tpkt_va = pa2va(pkt_pa, pkt_kva);\n \n \t\tlen = skb->len;\n@@ -338,9 +371,9 @@ kni_net_rx_normal(struct kni_dev *kni)\n \n \t/* Transfer received packets to netif */\n \tfor (i = 0; i < num_rx; i++) {\n-\t\tkva = pa2kva(kni->pa[i]);\n+\t\tkva = get_kva(kni, kni->pa[i]);\n \t\tlen = kva->pkt_len;\n-\t\tdata_kva = kva2data_kva(kva);\n+\t\tdata_kva = get_data_kva(kni, kva);\n \t\tkni->va[i] = pa2va(kni->pa[i], kva);\n \n \t\tskb = netdev_alloc_skb(dev, len);\n@@ -437,9 +470,9 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)\n \t\tnum = ret;\n \t\t/* Copy mbufs */\n \t\tfor (i = 0; i < num; i++) {\n-\t\t\tkva = pa2kva(kni->pa[i]);\n+\t\t\tkva = get_kva(kni, kni->pa[i]);\n \t\t\tlen = kva->data_len;\n-\t\t\tdata_kva = kva2data_kva(kva);\n+\t\t\tdata_kva = get_data_kva(kni, kva);\n \t\t\tkni->va[i] = pa2va(kni->pa[i], kva);\n \n \t\t\twhile (kva->next) {\n@@ -449,8 +482,8 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)\n \t\t\t\tkva = next_kva;\n \t\t\t}\n \n-\t\t\talloc_kva = pa2kva(kni->alloc_pa[i]);\n-\t\t\talloc_data_kva = kva2data_kva(alloc_kva);\n+\t\t\talloc_kva = get_kva(kni, kni->alloc_pa[i]);\n+\t\t\talloc_data_kva = get_data_kva(kni, alloc_kva);\n \t\t\tkni->alloc_va[i] = pa2va(kni->alloc_pa[i], alloc_kva);\n \n \t\t\tmemcpy(alloc_data_kva, data_kva, len);\n@@ -517,9 +550,9 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)\n \n \t/* Copy mbufs to sk buffer and then call tx interface */\n \tfor (i = 0; i < num; i++) {\n-\t\tkva = pa2kva(kni->pa[i]);\n+\t\tkva = get_kva(kni, kni->pa[i]);\n \t\tlen = kva->pkt_len;\n-\t\tdata_kva = kva2data_kva(kva);\n+\t\tdata_kva = get_data_kva(kni, kva);\n \t\tkni->va[i] = pa2va(kni->pa[i], kva);\n \n \t\tskb = netdev_alloc_skb(dev, len);\n@@ -550,8 +583,8 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)\n \t\t\t\t\tbreak;\n \n \t\t\t\tprev_kva = kva;\n-\t\t\t\tkva = pa2kva(kva->next);\n-\t\t\t\tdata_kva = kva2data_kva(kva);\n+\t\t\t\tkva = get_kva(kni, kva->next);\n+\t\t\t\tdata_kva = get_data_kva(kni, kva);\n \t\t\t\t/* Convert physical address to virtual address */\n \t\t\t\tprev_kva->next = pa2va(prev_kva->next, kva);\n \t\t\t}\n",
    "prefixes": [
        "v8",
        "4/5"
    ]
}