get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 57045,
    "url": "http://patches.dpdk.org/api/patches/57045/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/5d8f83fb7dd574d83a044c6a01e2613798f256c3.1563986790.git.anatoly.burakov@intel.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": "<5d8f83fb7dd574d83a044c6a01e2613798f256c3.1563986790.git.anatoly.burakov@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/5d8f83fb7dd574d83a044c6a01e2613798f256c3.1563986790.git.anatoly.burakov@intel.com",
    "date": "2019-07-24T16:46:35",
    "name": "eal: pick IOVA as PA if IOMMU is not available",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "dfd572a9bf856e6da72a2b410bd01ff10873a763",
    "submitter": {
        "id": 4,
        "url": "http://patches.dpdk.org/api/people/4/?format=api",
        "name": "Anatoly Burakov",
        "email": "anatoly.burakov@intel.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/5d8f83fb7dd574d83a044c6a01e2613798f256c3.1563986790.git.anatoly.burakov@intel.com/mbox/",
    "series": [
        {
            "id": 5719,
            "url": "http://patches.dpdk.org/api/series/5719/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=5719",
            "date": "2019-07-24T16:46:35",
            "name": "eal: pick IOVA as PA if IOMMU is not available",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/5719/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/57045/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/57045/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 E12761C238;\n\tWed, 24 Jul 2019 18:46:39 +0200 (CEST)",
            "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n\tby dpdk.org (Postfix) with ESMTP id 6A9311C235\n\tfor <dev@dpdk.org>; Wed, 24 Jul 2019 18:46:38 +0200 (CEST)",
            "from orsmga002.jf.intel.com ([10.7.209.21])\n\tby fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t24 Jul 2019 09:46:37 -0700",
            "from silpixa00399498.ir.intel.com (HELO\n\tsilpixa00399498.ger.corp.intel.com) ([10.237.223.125])\n\tby orsmga002.jf.intel.com with ESMTP; 24 Jul 2019 09:46:35 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.64,303,1559545200\"; d=\"scan'208\";a=\"181162571\"",
        "From": "Anatoly Burakov <anatoly.burakov@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "david.marchand@redhat.com,\n\tjerinj@marvell.com,\n\tthomas@monjalon.net",
        "Date": "Wed, 24 Jul 2019 17:46:35 +0100",
        "Message-Id": "<5d8f83fb7dd574d83a044c6a01e2613798f256c3.1563986790.git.anatoly.burakov@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "Subject": "[dpdk-dev] [PATCH] eal: pick IOVA as PA if IOMMU is not available",
        "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": "When IOMMU is not available, /sys/kernel/iommu_groups will not be\npopulated. This is happening since at least 3.6 when VFIO support\nwas added. If the directory is empty, EAL should not pick IOVA as\nVA as the default IOVA mode.\n\nWe also assume that VFIO equals IOMMU, so if VFIO support is not\ncompiled, we always assume IOMMU support is not available.\n\nSigned-off-by: Anatoly Burakov <anatoly.burakov@intel.com>\n---\n lib/librte_eal/linux/eal/eal.c      | 11 ++++++--\n lib/librte_eal/linux/eal/eal_vfio.c | 39 +++++++++++++++++++++++++++++\n lib/librte_eal/linux/eal/eal_vfio.h |  2 ++\n 3 files changed, 50 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c\nindex 34db78753..584f97a96 100644\n--- a/lib/librte_eal/linux/eal/eal.c\n+++ b/lib/librte_eal/linux/eal/eal.c\n@@ -1061,8 +1061,15 @@ rte_eal_init(int argc, char **argv)\n \t\tenum rte_iova_mode iova_mode = rte_bus_get_iommu_class();\n \n \t\tif (iova_mode == RTE_IOVA_DC) {\n-\t\t\tiova_mode = RTE_IOVA_VA;\n-\t\t\tRTE_LOG(DEBUG, EAL, \"Buses did not request a specific IOVA mode, select IOVA as VA mode.\\n\");\n+\t\t\t/* if we have an IOMMU, pick IOVA as VA mode */\n+\t\t\tif (vfio_iommu_enabled()) {\n+\t\t\t\tiova_mode = RTE_IOVA_VA;\n+\t\t\t\tRTE_LOG(DEBUG, EAL, \"Buses did not request a specific IOVA mode, selecting IOVA as VA mode.\\n\");\n+\t\t\t} else {\n+\t\t\t\tiova_mode = RTE_IOVA_PA;\n+\t\t\t\tRTE_LOG(DEBUG, EAL, \"Buses did not request a specific IOVA mode, but IOMMU is not available.\\n\");\n+\t\t\t\tRTE_LOG(DEBUG, EAL, \"Selecting IOVA as PA mode.\\n\");\n+\t\t\t}\n \t\t}\n #ifdef RTE_LIBRTE_KNI\n \t\t/* Workaround for KNI which requires physical address to work */\ndiff --git a/lib/librte_eal/linux/eal/eal_vfio.c b/lib/librte_eal/linux/eal/eal_vfio.c\nindex 501c74f23..6d5ca7903 100644\n--- a/lib/librte_eal/linux/eal/eal_vfio.c\n+++ b/lib/librte_eal/linux/eal/eal_vfio.c\n@@ -2,6 +2,7 @@\n  * Copyright(c) 2010-2018 Intel Corporation\n  */\n \n+#include <dirent.h>\n #include <inttypes.h>\n #include <string.h>\n #include <fcntl.h>\n@@ -23,6 +24,8 @@\n \n #define VFIO_MEM_EVENT_CLB_NAME \"vfio_mem_event_clb\"\n \n+#define VFIO_KERNEL_IOMMU_GROUPS_PATH \"/sys/kernel/iommu_groups\"\n+\n /* hot plug/unplug of VFIO groups may cause all DMA maps to be dropped. we can\n  * recreate the mappings for DPDK segments, but we cannot do so for memory that\n  * was registered by the user themselves, so we need to store the user mappings\n@@ -2026,6 +2029,33 @@ rte_vfio_container_dma_unmap(int container_fd, uint64_t vaddr, uint64_t iova,\n \treturn container_dma_unmap(vfio_cfg, vaddr, iova, len);\n }\n \n+/*\n+ * on Linux 3.6+, even if VFIO is not loaded, whenever IOMMU is enabled in the\n+ * BIOS and in the kernel, /sys/kernel/iommu_groups path will contain kernel\n+ * IOMMU groups. If IOMMU is not enabled, that path would be empty. Therefore,\n+ * checking if the path is empty will tell us if IOMMU is enabled.\n+ */\n+int\n+vfio_iommu_enabled(void)\n+{\n+\tDIR *dir = opendir(VFIO_KERNEL_IOMMU_GROUPS_PATH);\n+\tstruct dirent *d;\n+\tint n = 0;\n+\n+\t/* if directory doesn't exist, assume IOMMU is not enabled */\n+\tif (dir == NULL)\n+\t\treturn 0;\n+\n+\twhile ((d = readdir(dir)) != NULL) {\n+\t\t/* skip dot and dot-dot */\n+\t\tif (++n > 2)\n+\t\t\tbreak;\n+\t}\n+\tclosedir(dir);\n+\n+\treturn n > 2;\n+}\n+\n #else\n \n int\n@@ -2146,4 +2176,13 @@ rte_vfio_container_dma_unmap(__rte_unused int container_fd,\n \treturn -1;\n }\n \n+/*\n+ * VFIO not compiled, so IOMMU unsupported.\n+ */\n+int\n+vfio_iommu_enabled(void)\n+{\n+\treturn 0;\n+}\n+\n #endif /* VFIO_PRESENT */\ndiff --git a/lib/librte_eal/linux/eal/eal_vfio.h b/lib/librte_eal/linux/eal/eal_vfio.h\nindex cb2d35fb1..58c7a7309 100644\n--- a/lib/librte_eal/linux/eal/eal_vfio.h\n+++ b/lib/librte_eal/linux/eal/eal_vfio.h\n@@ -133,6 +133,8 @@ vfio_has_supported_extensions(int vfio_container_fd);\n \n int vfio_mp_sync_setup(void);\n \n+int vfio_iommu_enabled(void);\n+\n #define EAL_VFIO_MP \"eal_vfio_mp_sync\"\n \n #define SOCKET_REQ_CONTAINER 0x100\n",
    "prefixes": []
}