get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 63845,
    "url": "http://patches.dpdk.org/api/patches/63845/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20191213141322.32730-2-maxime.coquelin@redhat.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": "<20191213141322.32730-2-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20191213141322.32730-2-maxime.coquelin@redhat.com",
    "date": "2019-12-13T14:13:19",
    "name": "[1/4] eal: add new API to register contiguous external memory",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "df2c0f89fed7aa65e3895012ef5233ea1e6e675f",
    "submitter": {
        "id": 512,
        "url": "http://patches.dpdk.org/api/people/512/?format=api",
        "name": "Maxime Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "delegate": {
        "id": 24651,
        "url": "http://patches.dpdk.org/api/users/24651/?format=api",
        "username": "dmarchand",
        "first_name": "David",
        "last_name": "Marchand",
        "email": "david.marchand@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20191213141322.32730-2-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 7824,
            "url": "http://patches.dpdk.org/api/series/7824/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=7824",
            "date": "2019-12-13T14:13:18",
            "name": "Add external contiguous memory support to Virtio-user",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/7824/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/63845/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/63845/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id A9A08A04F1;\n\tFri, 13 Dec 2019 15:13:44 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 7CC8E1BF94;\n\tFri, 13 Dec 2019 15:13:39 +0100 (CET)",
            "from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com\n [207.211.31.81]) by dpdk.org (Postfix) with ESMTP id 3E5D21BF8D\n for <dev@dpdk.org>; Fri, 13 Dec 2019 15:13:37 +0100 (CET)",
            "from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com\n [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id\n us-mta-209-km5tr3IuOF6bxrHw-lUOxw-1; Fri, 13 Dec 2019 09:13:33 -0500",
            "from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com\n [10.5.11.12])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 22849CF98F;\n Fri, 13 Dec 2019 14:13:32 +0000 (UTC)",
            "from localhost.localdomain (ovpn-112-19.ams2.redhat.com\n [10.36.112.19])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 450BE60C05;\n Fri, 13 Dec 2019 14:13:29 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1576246416;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=eChFg4knKKoLw7SWxulKYvQhlvXP+awAtpzYacZCbQs=;\n b=HY8QI8k5grcS0q4KUUWIXcuuO+W7LaF5NYBDbBp3FZsP5EQBOzHPNc12zLbtEj7ZKZX0fK\n HmMx659pJX5AjPObne0vK55m5Mc9v7vbrseR5e3OcYw/CC+E7wIRmZISwrv678Pru4CAaG\n lfoVPreseMZZnmzwgg2Q5aiSW/GFetw=",
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "dev@dpdk.org, tiwei.bie@intel.com, zhihong.wang@intel.com,\n anatoly.burakov@intel.com",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "Date": "Fri, 13 Dec 2019 15:13:19 +0100",
        "Message-Id": "<20191213141322.32730-2-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20191213141322.32730-1-maxime.coquelin@redhat.com>",
        "References": "<20191213141322.32730-1-maxime.coquelin@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.12",
        "X-MC-Unique": "km5tr3IuOF6bxrHw-lUOxw-1",
        "X-Mimecast-Spam-Score": "0",
        "Content-Type": "text/plain; charset=US-ASCII",
        "Content-Transfer-Encoding": "quoted-printable",
        "Subject": "[dpdk-dev] [PATCH 1/4] eal: add new API to register contiguous\n\texternal memory",
        "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 <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 <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This new API allows to pass a file descriptor while\nregistering external and contiguous memory in the IOVA space.\n\nThis is required for using Virtio-user PMD with application\nusing external memory for the mbuf's buffers, like Seastar\nor VPP.\n\nFD is only attached to the segments if single_file_segment\noption is enabled.\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n lib/librte_eal/common/eal_common_memory.c  | 75 +++++++++++++++++++++-\n lib/librte_eal/common/include/rte_memory.h | 46 +++++++++++++\n lib/librte_eal/common/malloc_heap.c        | 17 ++++-\n lib/librte_eal/common/malloc_heap.h        |  2 +-\n lib/librte_eal/common/rte_malloc.c         |  2 +-\n lib/librte_eal/rte_eal_version.map         |  3 +\n 6 files changed, 141 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c\nindex 4a9cc1f19a..7a4b371828 100644\n--- a/lib/librte_eal/common/eal_common_memory.c\n+++ b/lib/librte_eal/common/eal_common_memory.c\n@@ -772,6 +772,79 @@ rte_memseg_get_fd_offset(const struct rte_memseg *ms, size_t *offset)\n \treturn ret;\n }\n \n+int\n+rte_extmem_register_contig(void *va_addr, size_t len, rte_iova_t iova_addr,\n+\t\tsize_t page_sz, int fd)\n+{\n+\tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n+\trte_iova_t *iova_addrs = NULL;\n+\tunsigned int socket_id, n, i;\n+\tint ret = 0;\n+\n+\tif (va_addr == NULL || page_sz == 0 || len == 0 ||\n+\t\t\t!rte_is_power_of_2(page_sz) ||\n+\t\t\tRTE_ALIGN(len, page_sz) != len ||\n+\t\t\t((len % page_sz) != 0  ||\n+\t\t\t!rte_is_aligned(va_addr, page_sz))) {\n+\t\trte_errno = EINVAL;\n+\t\treturn -1;\n+\t}\n+\n+\tn = len / page_sz;\n+\tif (iova_addr != 0) {\n+\t\tiova_addrs = malloc(n * sizeof(*iova_addrs));\n+\t\tif (iova_addrs == NULL) {\n+\t\t\trte_errno = -ENOMEM;\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\tfor (i = 0; i < n; i++)\n+\t\t\tiova_addrs[i] = iova_addr + n * page_sz;\n+\n+\t}\n+\n+\n+\tif (fd >= 0 && !internal_config.single_file_segments) {\n+\t\tRTE_LOG(INFO, EAL, \"FD won't be attached to the external memory,\" \\\n+\t\t\t\t\" requires single file segments\\n\");\n+\t\tfd = -1;\n+\t}\n+\trte_mcfg_mem_write_lock();\n+\n+\t/* make sure the segment doesn't already exist */\n+\tif (malloc_heap_find_external_seg(va_addr, len) != NULL) {\n+\t\trte_errno = EEXIST;\n+\t\tret = -1;\n+\t\tgoto unlock;\n+\t}\n+\n+\t/* get next available socket ID */\n+\tsocket_id = mcfg->next_socket_id;\n+\tif (socket_id > INT32_MAX) {\n+\t\tRTE_LOG(ERR, EAL, \"Cannot assign new socket ID's\\n\");\n+\t\trte_errno = ENOSPC;\n+\t\tret = -1;\n+\t\tgoto unlock;\n+\t}\n+\n+\t/* we can create a new memseg */\n+\tif (malloc_heap_create_external_seg(va_addr, iova_addrs, n,\n+\t\t\tpage_sz, \"extmem_contig\", socket_id, fd) == NULL) {\n+\t\tret = -1;\n+\t\tgoto unlock;\n+\t}\n+\n+\t/* memseg list successfully created - increment next socket ID */\n+\tmcfg->next_socket_id++;\n+unlock:\n+\trte_mcfg_mem_write_unlock();\n+\n+\tif (iova_addrs != NULL)\n+\t\tfree(iova_addrs);\n+\n+\treturn ret;\n+}\n+\n int\n rte_extmem_register(void *va_addr, size_t len, rte_iova_t iova_addrs[],\n \t\tunsigned int n_pages, size_t page_sz)\n@@ -809,7 +882,7 @@ rte_extmem_register(void *va_addr, size_t len, rte_iova_t iova_addrs[],\n \t/* we can create a new memseg */\n \tn = len / page_sz;\n \tif (malloc_heap_create_external_seg(va_addr, iova_addrs, n,\n-\t\t\tpage_sz, \"extmem\", socket_id) == NULL) {\n+\t\t\tpage_sz, \"extmem\", socket_id, -1) == NULL) {\n \t\tret = -1;\n \t\tgoto unlock;\n \t}\ndiff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h\nindex 3d8d0bd697..e274e47e5e 100644\n--- a/lib/librte_eal/common/include/rte_memory.h\n+++ b/lib/librte_eal/common/include/rte_memory.h\n@@ -451,6 +451,10 @@ rte_memseg_get_fd_offset_thread_unsafe(const struct rte_memseg *ms,\n  *   is NULL.\n  * @param page_sz\n  *   Page size of the underlying memory\n+ * @param fd\n+ *   File descriptor for the external memory region registered. Must be set to\n+ *   -1 if no FD, and ignored if single-segment isn't not used or if iova\n+ *   aren't contiguous (iova_addrs != NULL).\n  *\n  * @return\n  *   - 0 on success\n@@ -461,6 +465,48 @@ rte_memseg_get_fd_offset_thread_unsafe(const struct rte_memseg *ms,\n  */\n __rte_experimental\n int\n+rte_extmem_register_contig(void *va_addr, size_t len, rte_iova_t iova_addr,\n+\t\tsize_t page_sz, int fd);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice\n+ *\n+ * Register external contiguous memory chunk with DPDK.\n+ *\n+ * @note Using this API is mutually exclusive with ``rte_malloc`` family of\n+ *   API's.\n+ *\n+ * @note This API will not perform any DMA mapping. It is expected that user\n+ *   will do that themselves.\n+ *\n+ * @note Before accessing this memory in other processes, it needs to be\n+ *   attached in each of those processes by calling ``rte_extmem_attach`` in\n+ *   each other process.\n+ *\n+ * @param va_addr\n+ *   Start of virtual area to register. Must be aligned by ``page_sz``.\n+ * @param len\n+ *   Length of virtual area to register. Must be aligned by ``page_sz``.\n+ * @param iova_addr\n+ *   IOVA address for the contiguous memory chunck. Can be 0, in which case\n+ *   page IOVA addresses will be set to RTE_BAD_IOVA.\n+ * @param page_sz\n+ *   Page size of the underlying memory\n+ * @param fd\n+ *   File descriptor for the external memory region registered. Must be set to\n+ *   -1 if no FD, and ignored if single-segment isn't not used.\n+ *\n+ * @return\n+ *   - 0 on success\n+ *   - -1 in case of error, with rte_errno set to one of the following:\n+ *     EINVAL - one of the parameters was invalid\n+ *     EEXIST - memory chunk is already registered\n+ *     ENOSPC - no more space in internal config to store a new memory chunk\n+ *     ENOMEM - failed to allocate pages IOVA addresses\n+ */\n+__rte_experimental\n+int\n rte_extmem_register(void *va_addr, size_t len, rte_iova_t iova_addrs[],\n \t\tunsigned int n_pages, size_t page_sz);\n \ndiff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c\nindex 842eb9de75..229ab6563c 100644\n--- a/lib/librte_eal/common/malloc_heap.c\n+++ b/lib/librte_eal/common/malloc_heap.c\n@@ -1096,7 +1096,7 @@ destroy_elem(struct malloc_elem *elem, size_t len)\n struct rte_memseg_list *\n malloc_heap_create_external_seg(void *va_addr, rte_iova_t iova_addrs[],\n \t\tunsigned int n_pages, size_t page_sz, const char *seg_name,\n-\t\tunsigned int socket_id)\n+\t\tunsigned int socket_id, int fd)\n {\n \tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n \tchar fbarray_name[RTE_FBARRAY_NAME_LEN];\n@@ -1153,6 +1153,13 @@ malloc_heap_create_external_seg(void *va_addr, rte_iova_t iova_addrs[],\n \tmsl->version = 0;\n \tmsl->external = 1;\n \n+\tif (fd >= 0) {\n+\t\tint list_idx = msl - mcfg->memsegs;\n+\n+\t\tif (eal_memalloc_set_seg_list_fd(list_idx, fd))\n+\t\t\tRTE_LOG(ERR, EAL, \"Failed to set segment list FD\\n\");\n+\t}\n+\n \treturn msl;\n }\n \n@@ -1202,10 +1209,18 @@ malloc_heap_find_external_seg(void *va_addr, size_t len)\n int\n malloc_heap_destroy_external_seg(struct rte_memseg_list *msl)\n {\n+\tstruct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;\n+\tint list_idx;\n+\n \t/* destroy the fbarray backing this memory */\n \tif (rte_fbarray_destroy(&msl->memseg_arr) < 0)\n \t\treturn -1;\n \n+\tlist_idx = msl - mcfg->memsegs;\n+\tif (eal_memalloc_set_seg_list_fd(list_idx, -1))\n+\t\tRTE_LOG(ERR, EAL, \"Failed to reset segment list FD\\n\");\n+\n+\n \t/* reset the memseg list */\n \tmemset(msl, 0, sizeof(*msl));\n \ndiff --git a/lib/librte_eal/common/malloc_heap.h b/lib/librte_eal/common/malloc_heap.h\nindex 772736b53f..438ce908de 100644\n--- a/lib/librte_eal/common/malloc_heap.h\n+++ b/lib/librte_eal/common/malloc_heap.h\n@@ -65,7 +65,7 @@ malloc_heap_destroy(struct malloc_heap *heap);\n struct rte_memseg_list *\n malloc_heap_create_external_seg(void *va_addr, rte_iova_t iova_addrs[],\n \t\tunsigned int n_pages, size_t page_sz, const char *seg_name,\n-\t\tunsigned int socket_id);\n+\t\tunsigned int socket_id, int fd);\n \n struct rte_memseg_list *\n malloc_heap_find_external_seg(void *va_addr, size_t len);\ndiff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c\nindex d6026a2b17..aa19b0517f 100644\n--- a/lib/librte_eal/common/rte_malloc.c\n+++ b/lib/librte_eal/common/rte_malloc.c\n@@ -389,7 +389,7 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len,\n \tn = len / page_sz;\n \n \tmsl = malloc_heap_create_external_seg(va_addr, iova_addrs, n, page_sz,\n-\t\t\theap_name, heap->socket_id);\n+\t\t\theap_name, heap->socket_id, -1);\n \tif (msl == NULL) {\n \t\tret = -1;\n \t\tgoto unlock;\ndiff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map\nindex e38d02530c..ddcb4b0512 100644\n--- a/lib/librte_eal/rte_eal_version.map\n+++ b/lib/librte_eal/rte_eal_version.map\n@@ -332,4 +332,7 @@ EXPERIMENTAL {\n \t# added in 19.11\n \trte_log_get_stream;\n \trte_mcfg_get_single_file_segments;\n+\n+\t# added in 20.02\n+\trte_extmem_register_contig;\n };\n",
    "prefixes": [
        "1/4"
    ]
}