get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 102713,
    "url": "https://patches.dpdk.org/api/patches/102713/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20211024200449.12024-5-david.marchand@redhat.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": "<20211024200449.12024-5-david.marchand@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20211024200449.12024-5-david.marchand@redhat.com",
    "date": "2021-10-24T20:04:44",
    "name": "[v6,4/9] alarm: remove direct access to interrupt handle",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "4e1f6b01b5a63e2f036cc475ba4a62127eb5d8dc",
    "submitter": {
        "id": 1173,
        "url": "https://patches.dpdk.org/api/people/1173/?format=api",
        "name": "David Marchand",
        "email": "david.marchand@redhat.com"
    },
    "delegate": {
        "id": 24651,
        "url": "https://patches.dpdk.org/api/users/24651/?format=api",
        "username": "dmarchand",
        "first_name": "David",
        "last_name": "Marchand",
        "email": "david.marchand@redhat.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20211024200449.12024-5-david.marchand@redhat.com/mbox/",
    "series": [
        {
            "id": 19934,
            "url": "https://patches.dpdk.org/api/series/19934/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=19934",
            "date": "2021-10-24T20:04:40",
            "name": "make rte_intr_handle internal",
            "version": 6,
            "mbox": "https://patches.dpdk.org/series/19934/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/102713/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/102713/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 mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 27272A0C41;\n\tSun, 24 Oct 2021 22:06:02 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 15DDE410F1;\n\tSun, 24 Oct 2021 22:06:02 +0200 (CEST)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by mails.dpdk.org (Postfix) with ESMTP id 6EB71410F1\n for <dev@dpdk.org>; Sun, 24 Oct 2021 22:06:00 +0200 (CEST)",
            "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-542-vSMJN-vzOAKEDiAUs-QhaA-1; Sun, 24 Oct 2021 16:05:58 -0400",
            "from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com\n [10.5.11.14])\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 4A5B880668A;\n Sun, 24 Oct 2021 20:05:57 +0000 (UTC)",
            "from dmarchan.remote.csb (unknown [10.40.192.64])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 6D4095D9D5;\n Sun, 24 Oct 2021 20:05:54 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1635105960;\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=Caql2ciRay6rNOwb8in4EdkgCiMLP71ZcB2PMzAgk4I=;\n b=XkGPFCaGUdk27qiuBLHJz8MI/j6q2kjLN69q7OTKyfHu1sW4zJeGPQKLreOtZ8/LuxzPt7\n MzVqksJRe8rmwR8ySc4Krzd3wZ1X4Y4QYUaqSaPja/RzX9s3kJPMJ7GeG7sykVzhtcj0xi\n HRnZHRAGpESKdW7JebG7RsCK09hTdj8=",
        "X-MC-Unique": "vSMJN-vzOAKEDiAUs-QhaA-1",
        "From": "David Marchand <david.marchand@redhat.com>",
        "To": "hkalra@marvell.com,\n\tdev@dpdk.org",
        "Cc": "dmitry.kozliuk@gmail.com,\n\tBruce Richardson <bruce.richardson@intel.com>",
        "Date": "Sun, 24 Oct 2021 22:04:44 +0200",
        "Message-Id": "<20211024200449.12024-5-david.marchand@redhat.com>",
        "In-Reply-To": "<20211024200449.12024-1-david.marchand@redhat.com>",
        "References": "<20211022204934.132186-1-hkalra@marvell.com>\n <20211024200449.12024-1-david.marchand@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.14",
        "Authentication-Results": "relay.mimecast.com;\n auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"",
        "Subject": "[dpdk-dev] [PATCH v6 4/9] alarm: remove direct access to interrupt\n handle",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "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": "From: Harman Kalra <hkalra@marvell.com>\n\nRemoving direct access to interrupt handle structure fields,\nrather use respective get set APIs for the same.\nMaking changes to all the libraries access the interrupt handle fields.\n\nImplementing alarm cleanup routine, where the memory allocated\nfor interrupt instance can be freed.\n\nSigned-off-by: Harman Kalra <hkalra@marvell.com>\nSigned-off-by: David Marchand <david.marchand@redhat.com>\n---\nChanges since v5:\n- split from patch4,\n- merged patch6,\n- renamed rte_eal_alarm_fini as rte_eal_alarm_cleanup,\n\n---\n lib/eal/common/eal_private.h | 10 ++++++++\n lib/eal/freebsd/eal.c        |  1 +\n lib/eal/freebsd/eal_alarm.c  | 44 +++++++++++++++++++++++++++++++-----\n lib/eal/linux/eal.c          |  1 +\n lib/eal/linux/eal_alarm.c    | 32 ++++++++++++++++++++------\n 5 files changed, 75 insertions(+), 13 deletions(-)",
    "diff": "diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h\nindex 86dab1f057..36bcc0b5a4 100644\n--- a/lib/eal/common/eal_private.h\n+++ b/lib/eal/common/eal_private.h\n@@ -163,6 +163,16 @@ int rte_eal_intr_init(void);\n  */\n int rte_eal_alarm_init(void);\n \n+/**\n+ * Alarm mechanism cleanup.\n+ *\n+ * This function is private to EAL.\n+ *\n+ * @return\n+ *  0 on success, negative on error\n+ */\n+void rte_eal_alarm_cleanup(void);\n+\n /**\n  * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,\n  * etc.) loaded.\ndiff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c\nindex 56a60f13e9..9935356ed4 100644\n--- a/lib/eal/freebsd/eal.c\n+++ b/lib/eal/freebsd/eal.c\n@@ -975,6 +975,7 @@ rte_eal_cleanup(void)\n \trte_mp_channel_cleanup();\n \t/* after this point, any DPDK pointers will become dangling */\n \trte_eal_memory_detach();\n+\trte_eal_alarm_cleanup();\n \trte_trace_save();\n \teal_trace_fini();\n \teal_cleanup_config(internal_conf);\ndiff --git a/lib/eal/freebsd/eal_alarm.c b/lib/eal/freebsd/eal_alarm.c\nindex c38b2e04f8..1a8fcf24c5 100644\n--- a/lib/eal/freebsd/eal_alarm.c\n+++ b/lib/eal/freebsd/eal_alarm.c\n@@ -32,7 +32,7 @@\n \n struct alarm_entry {\n \tLIST_ENTRY(alarm_entry) next;\n-\tstruct rte_intr_handle handle;\n+\tstruct rte_intr_handle *handle;\n \tstruct timespec time;\n \trte_eal_alarm_callback cb_fn;\n \tvoid *cb_arg;\n@@ -43,22 +43,46 @@ struct alarm_entry {\n static LIST_HEAD(alarm_list, alarm_entry) alarm_list = LIST_HEAD_INITIALIZER();\n static rte_spinlock_t alarm_list_lk = RTE_SPINLOCK_INITIALIZER;\n \n-static struct rte_intr_handle intr_handle = {.fd = -1 };\n+static struct rte_intr_handle *intr_handle;\n static void eal_alarm_callback(void *arg);\n \n+void\n+rte_eal_alarm_cleanup(void)\n+{\n+\trte_intr_instance_free(intr_handle);\n+}\n+\n int\n rte_eal_alarm_init(void)\n {\n-\tintr_handle.type = RTE_INTR_HANDLE_ALARM;\n+\tint fd;\n+\n+\tintr_handle = rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE);\n+\tif (intr_handle == NULL) {\n+\t\tRTE_LOG(ERR, EAL, \"Fail to allocate intr_handle\\n\");\n+\t\tgoto error;\n+\t}\n+\n+\tif (rte_intr_type_set(intr_handle, RTE_INTR_HANDLE_ALARM))\n+\t\tgoto error;\n+\n+\tif (rte_intr_fd_set(intr_handle, -1))\n+\t\tgoto error;\n \n \t/* on FreeBSD, timers don't use fd's, and their identifiers are stored\n \t * in separate namespace from fd's, so using any value is OK. however,\n \t * EAL interrupts handler expects fd's to be unique, so use an actual fd\n \t * to guarantee unique timer identifier.\n \t */\n-\tintr_handle.fd = open(\"/dev/zero\", O_RDONLY);\n+\tfd = open(\"/dev/zero\", O_RDONLY);\n+\n+\tif (rte_intr_fd_set(intr_handle, fd))\n+\t\tgoto error;\n \n \treturn 0;\n+error:\n+\trte_intr_instance_free(intr_handle);\n+\treturn -1;\n }\n \n static inline int\n@@ -118,7 +142,7 @@ unregister_current_callback(void)\n \t\tap = LIST_FIRST(&alarm_list);\n \n \t\tdo {\n-\t\t\tret = rte_intr_callback_unregister(&intr_handle,\n+\t\t\tret = rte_intr_callback_unregister(intr_handle,\n \t\t\t\teal_alarm_callback, &ap->time);\n \t\t} while (ret == -EAGAIN);\n \t}\n@@ -136,7 +160,7 @@ register_first_callback(void)\n \t\tap = LIST_FIRST(&alarm_list);\n \n \t\t/* register a new callback */\n-\t\tret = rte_intr_callback_register(&intr_handle,\n+\t\tret = rte_intr_callback_register(intr_handle,\n \t\t\t\teal_alarm_callback, &ap->time);\n \t}\n \treturn ret;\n@@ -164,6 +188,7 @@ eal_alarm_callback(void *arg __rte_unused)\n \t\trte_spinlock_lock(&alarm_list_lk);\n \n \t\tLIST_REMOVE(ap, next);\n+\t\trte_intr_instance_free(ap->handle);\n \t\tfree(ap);\n \n \t\tap = LIST_FIRST(&alarm_list);\n@@ -202,6 +227,11 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg)\n \tnew_alarm->time.tv_nsec = (now.tv_nsec + ns) % NS_PER_S;\n \tnew_alarm->time.tv_sec = now.tv_sec + ((now.tv_nsec + ns) / NS_PER_S);\n \n+\tnew_alarm->handle =\n+\t\trte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE);\n+\tif (new_alarm->handle == NULL)\n+\t\treturn -ENOMEM;\n+\n \trte_spinlock_lock(&alarm_list_lk);\n \n \tif (LIST_EMPTY(&alarm_list))\n@@ -255,6 +285,7 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)\n \t\t\t\tbreak;\n \t\t\tif (ap->executing == 0) {\n \t\t\t\tLIST_REMOVE(ap, next);\n+\t\t\t\trte_intr_instance_free(ap->handle);\n \t\t\t\tfree(ap);\n \t\t\t\tcount++;\n \t\t\t} else {\n@@ -282,6 +313,7 @@ rte_eal_alarm_cancel(rte_eal_alarm_callback cb_fn, void *cb_arg)\n \t\t\t\t\t cb_arg == ap->cb_arg)) {\n \t\t\t\tif (ap->executing == 0) {\n \t\t\t\t\tLIST_REMOVE(ap, next);\n+\t\t\t\t\trte_intr_instance_free(ap->handle);\n \t\t\t\t\tfree(ap);\n \t\t\t\t\tcount++;\n \t\t\t\t\tap = ap_prev;\ndiff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c\nindex 0d0fc66668..81fdebc6a0 100644\n--- a/lib/eal/linux/eal.c\n+++ b/lib/eal/linux/eal.c\n@@ -1368,6 +1368,7 @@ rte_eal_cleanup(void)\n \trte_mp_channel_cleanup();\n \t/* after this point, any DPDK pointers will become dangling */\n \trte_eal_memory_detach();\n+\trte_eal_alarm_cleanup();\n \trte_trace_save();\n \teal_trace_fini();\n \teal_cleanup_config(internal_conf);\ndiff --git a/lib/eal/linux/eal_alarm.c b/lib/eal/linux/eal_alarm.c\nindex 3252c6fa59..3b5e894595 100644\n--- a/lib/eal/linux/eal_alarm.c\n+++ b/lib/eal/linux/eal_alarm.c\n@@ -54,22 +54,40 @@ struct alarm_entry {\n static LIST_HEAD(alarm_list, alarm_entry) alarm_list = LIST_HEAD_INITIALIZER();\n static rte_spinlock_t alarm_list_lk = RTE_SPINLOCK_INITIALIZER;\n \n-static struct rte_intr_handle intr_handle = {.fd = -1 };\n+static struct rte_intr_handle *intr_handle;\n static int handler_registered = 0;\n static void eal_alarm_callback(void *arg);\n \n+void\n+rte_eal_alarm_cleanup(void)\n+{\n+\trte_intr_instance_free(intr_handle);\n+}\n+\n int\n rte_eal_alarm_init(void)\n {\n-\tintr_handle.type = RTE_INTR_HANDLE_ALARM;\n+\n+\tintr_handle = rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE);\n+\tif (intr_handle == NULL) {\n+\t\tRTE_LOG(ERR, EAL, \"Fail to allocate intr_handle\\n\");\n+\t\tgoto error;\n+\t}\n+\n+\tif (rte_intr_type_set(intr_handle, RTE_INTR_HANDLE_ALARM))\n+\t\tgoto error;\n+\n \t/* create a timerfd file descriptor */\n-\tintr_handle.fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);\n-\tif (intr_handle.fd == -1)\n+\tif (rte_intr_fd_set(intr_handle,\n+\t\t\ttimerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK)))\n \t\tgoto error;\n \n+\tif (rte_intr_fd_get(intr_handle) == -1)\n+\t\tgoto error;\n \treturn 0;\n \n error:\n+\trte_intr_instance_free(intr_handle);\n \trte_errno = errno;\n \treturn -1;\n }\n@@ -109,7 +127,7 @@ eal_alarm_callback(void *arg __rte_unused)\n \n \t\tatime.it_value.tv_sec -= now.tv_sec;\n \t\tatime.it_value.tv_nsec -= now.tv_nsec;\n-\t\ttimerfd_settime(intr_handle.fd, 0, &atime, NULL);\n+\t\ttimerfd_settime(rte_intr_fd_get(intr_handle), 0, &atime, NULL);\n \t}\n \trte_spinlock_unlock(&alarm_list_lk);\n }\n@@ -140,7 +158,7 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg)\n \trte_spinlock_lock(&alarm_list_lk);\n \tif (!handler_registered) {\n \t\t/* registration can fail, callback can be registered later */\n-\t\tif (rte_intr_callback_register(&intr_handle,\n+\t\tif (rte_intr_callback_register(intr_handle,\n \t\t\t\teal_alarm_callback, NULL) == 0)\n \t\t\thandler_registered = 1;\n \t}\n@@ -170,7 +188,7 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg)\n \t\t\t\t.tv_nsec = (us % US_PER_S) * NS_PER_US,\n \t\t\t},\n \t\t};\n-\t\tret |= timerfd_settime(intr_handle.fd, 0, &alarm_time, NULL);\n+\t\tret |= timerfd_settime(rte_intr_fd_get(intr_handle), 0, &alarm_time, NULL);\n \t}\n \trte_spinlock_unlock(&alarm_list_lk);\n \n",
    "prefixes": [
        "v6",
        "4/9"
    ]
}