get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 102293,
    "url": "https://patches.dpdk.org/api/patches/102293/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20211019183543.132084-4-hkalra@marvell.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": "<20211019183543.132084-4-hkalra@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20211019183543.132084-4-hkalra@marvell.com",
    "date": "2021-10-19T18:35:38",
    "name": "[v4,3/7] eal/interrupts: avoid direct access to interrupt handle",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "eb206afb1b9d1bbdc59866f72e919189f2419168",
    "submitter": {
        "id": 1182,
        "url": "https://patches.dpdk.org/api/people/1182/?format=api",
        "name": "Harman Kalra",
        "email": "hkalra@marvell.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/20211019183543.132084-4-hkalra@marvell.com/mbox/",
    "series": [
        {
            "id": 19805,
            "url": "https://patches.dpdk.org/api/series/19805/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=19805",
            "date": "2021-10-19T18:35:35",
            "name": "make rte_intr_handle internal",
            "version": 4,
            "mbox": "https://patches.dpdk.org/series/19805/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/102293/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/102293/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 CAA60A0547;\n\tTue, 19 Oct 2021 20:36:20 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 38BDB410E9;\n\tTue, 19 Oct 2021 20:36:18 +0200 (CEST)",
            "from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com\n [67.231.148.174])\n by mails.dpdk.org (Postfix) with ESMTP id B36D04003E\n for <dev@dpdk.org>; Tue, 19 Oct 2021 20:36:16 +0200 (CEST)",
            "from pps.filterd (m0045849.ppops.net [127.0.0.1])\n by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id\n 19JGSbGb025417;\n Tue, 19 Oct 2021 11:36:13 -0700",
            "from dc5-exch01.marvell.com ([199.233.59.181])\n by mx0a-0016f401.pphosted.com with ESMTP id 3bt1jtrka8-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);\n Tue, 19 Oct 2021 11:36:13 -0700",
            "from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com\n (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18;\n Tue, 19 Oct 2021 11:36:12 -0700",
            "from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com\n (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.18 via Frontend\n Transport; Tue, 19 Oct 2021 11:36:12 -0700",
            "from localhost.localdomain (unknown [10.29.52.211])\n by maili.marvell.com (Postfix) with ESMTP id 985543F7084;\n Tue, 19 Oct 2021 11:36:08 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n h=from : to : cc :\n subject : date : message-id : in-reply-to : references : mime-version :\n content-type; s=pfpt0220; bh=0QIo9ejWYBvahIJDVz6ioRegLyrU6bD76zKMpHCpyXQ=;\n b=Ra0NkuGhFlBC1V9PjXhe2Bt6piQlvVXQdsdbACXeLE9mtEEB8bpoF7vIDaKSX3sdDTN9\n X9e5Xav5vwm6B1MnrKrGhBFVb0DGLeXrDcqb0nWmuLe2plyHBfsZAitIK6dQNWTZRBYH\n lwykMEgl/7v/Okc10oxGq/9OJM0IdMX5r8pNP11jcGItAtSmQ1KPJPRF99aLHbzhlHwB\n gBPZWvm5tK2GtI47kr9qT2mJullUv0oAKnW/yVIJ5QA/p78flowltU8lVZH5SsAGLEHS\n Kofc3s3i1ZtgNlVXDykRZxiwk+Fc88XD9ODqjp87VjyDtNzpR55CSR3eIp50Nl6yLzzZ gQ==",
        "From": "Harman Kalra <hkalra@marvell.com>",
        "To": "<dev@dpdk.org>, Harman Kalra <hkalra@marvell.com>, Bruce Richardson\n <bruce.richardson@intel.com>",
        "CC": "<david.marchand@redhat.com>, <dmitry.kozliuk@gmail.com>, <mdr@ashroe.eu>,\n <thomas@monjalon.net>",
        "Date": "Wed, 20 Oct 2021 00:05:38 +0530",
        "Message-ID": "<20211019183543.132084-4-hkalra@marvell.com>",
        "X-Mailer": "git-send-email 2.18.0",
        "In-Reply-To": "<20211019183543.132084-1-hkalra@marvell.com>",
        "References": "<20210826145726.102081-1-hkalra@marvell.com>\n <20211019183543.132084-1-hkalra@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Proofpoint-GUID": "ynraeNSoWthUgKpybaQ0z9ZsiIGZ0ZzV",
        "X-Proofpoint-ORIG-GUID": "ynraeNSoWthUgKpybaQ0z9ZsiIGZ0ZzV",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475\n definitions=2021-10-19_02,2021-10-19_01,2020-04-07_01",
        "Subject": "[dpdk-dev] [PATCH v4 3/7] eal/interrupts: avoid direct access to\n interrupt 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": "Making changes to the interrupt framework to use interrupt handle\nAPIs to get/set any field. Direct access to any of the fields\nshould be avoided to avoid any ABI breakage in future.\n\nSigned-off-by: Harman Kalra <hkalra@marvell.com>\n---\n lib/eal/freebsd/eal_interrupts.c |  92 ++++++----\n lib/eal/linux/eal_interrupts.c   | 287 +++++++++++++++++++------------\n 2 files changed, 234 insertions(+), 145 deletions(-)",
    "diff": "diff --git a/lib/eal/freebsd/eal_interrupts.c b/lib/eal/freebsd/eal_interrupts.c\nindex 86810845fe..846ca4aa89 100644\n--- a/lib/eal/freebsd/eal_interrupts.c\n+++ b/lib/eal/freebsd/eal_interrupts.c\n@@ -40,7 +40,7 @@ struct rte_intr_callback {\n \n struct rte_intr_source {\n \tTAILQ_ENTRY(rte_intr_source) next;\n-\tstruct rte_intr_handle intr_handle; /**< interrupt handle */\n+\tstruct rte_intr_handle *intr_handle; /**< interrupt handle */\n \tstruct rte_intr_cb_list callbacks;  /**< user callbacks */\n \tuint32_t active;\n };\n@@ -60,7 +60,7 @@ static int\n intr_source_to_kevent(const struct rte_intr_handle *ih, struct kevent *ke)\n {\n \t/* alarm callbacks are special case */\n-\tif (ih->type == RTE_INTR_HANDLE_ALARM) {\n+\tif (rte_intr_type_get(ih) == RTE_INTR_HANDLE_ALARM) {\n \t\tuint64_t timeout_ns;\n \n \t\t/* get soonest alarm timeout */\n@@ -75,7 +75,7 @@ intr_source_to_kevent(const struct rte_intr_handle *ih, struct kevent *ke)\n \t} else {\n \t\tke->filter = EVFILT_READ;\n \t}\n-\tke->ident = ih->fd;\n+\tke->ident = rte_intr_fd_get(ih);\n \n \treturn 0;\n }\n@@ -89,7 +89,8 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,\n \tint ret = 0, add_event = 0;\n \n \t/* first do parameter checking */\n-\tif (intr_handle == NULL || intr_handle->fd < 0 || cb == NULL) {\n+\tif (intr_handle == NULL || rte_intr_fd_get(intr_handle) < 0 ||\n+\t    cb == NULL) {\n \t\tRTE_LOG(ERR, EAL,\n \t\t\t\"Registering with invalid input parameter\\n\");\n \t\treturn -EINVAL;\n@@ -103,7 +104,8 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,\n \n \t/* find the source for this intr_handle */\n \tTAILQ_FOREACH(src, &intr_sources, next) {\n-\t\tif (src->intr_handle.fd == intr_handle->fd)\n+\t\tif (rte_intr_fd_get(src->intr_handle) ==\n+\t\t    rte_intr_fd_get(intr_handle))\n \t\t\tbreak;\n \t}\n \n@@ -112,8 +114,8 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,\n \t * thing on the list should be eal_alarm_callback() and we may\n \t * be called just to reset the timer.\n \t */\n-\tif (src != NULL && src->intr_handle.type == RTE_INTR_HANDLE_ALARM &&\n-\t\t !TAILQ_EMPTY(&src->callbacks)) {\n+\tif (src != NULL && rte_intr_type_get(src->intr_handle) ==\n+\t\tRTE_INTR_HANDLE_ALARM && !TAILQ_EMPTY(&src->callbacks)) {\n \t\tcallback = NULL;\n \t} else {\n \t\t/* allocate a new interrupt callback entity */\n@@ -135,9 +137,18 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,\n \t\t\t\tret = -ENOMEM;\n \t\t\t\tgoto fail;\n \t\t\t} else {\n-\t\t\t\tsrc->intr_handle = *intr_handle;\n-\t\t\t\tTAILQ_INIT(&src->callbacks);\n-\t\t\t\tTAILQ_INSERT_TAIL(&intr_sources, src, next);\n+\t\t\t\tsrc->intr_handle = rte_intr_instance_alloc();\n+\t\t\t\tif (src->intr_handle == NULL) {\n+\t\t\t\t\tRTE_LOG(ERR, EAL, \"Can not create intr instance\\n\");\n+\t\t\t\t\tfree(callback);\n+\t\t\t\t\tret = -ENOMEM;\n+\t\t\t\t} else {\n+\t\t\t\t\trte_intr_instance_copy(src->intr_handle,\n+\t\t\t\t\t\t\t       intr_handle);\n+\t\t\t\t\tTAILQ_INIT(&src->callbacks);\n+\t\t\t\t\tTAILQ_INSERT_TAIL(&intr_sources, src,\n+\t\t\t\t\t\t\t  next);\n+\t\t\t\t}\n \t\t\t}\n \t\t}\n \n@@ -151,7 +162,8 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,\n \t/* add events to the queue. timer events are special as we need to\n \t * re-set the timer.\n \t */\n-\tif (add_event || src->intr_handle.type == RTE_INTR_HANDLE_ALARM) {\n+\tif (add_event || rte_intr_type_get(src->intr_handle) ==\n+\t\t\t\t\t\t\tRTE_INTR_HANDLE_ALARM) {\n \t\tstruct kevent ke;\n \n \t\tmemset(&ke, 0, sizeof(ke));\n@@ -173,12 +185,13 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,\n \t\t\t */\n \t\t\tif (errno == ENODEV)\n \t\t\t\tRTE_LOG(DEBUG, EAL, \"Interrupt handle %d not supported\\n\",\n-\t\t\t\t\tsrc->intr_handle.fd);\n+\t\t\t\trte_intr_fd_get(src->intr_handle));\n \t\t\telse\n \t\t\t\tRTE_LOG(ERR, EAL, \"Error adding fd %d \"\n-\t\t\t\t\t\t\"kevent, %s\\n\",\n-\t\t\t\t\t\tsrc->intr_handle.fd,\n-\t\t\t\t\t\tstrerror(errno));\n+\t\t\t\t\t\"kevent, %s\\n\",\n+\t\t\t\t\trte_intr_fd_get(\n+\t\t\t\t\t\t\tsrc->intr_handle),\n+\t\t\t\t\tstrerror(errno));\n \t\t\tret = -errno;\n \t\t\tgoto fail;\n \t\t}\n@@ -213,7 +226,7 @@ rte_intr_callback_unregister_pending(const struct rte_intr_handle *intr_handle,\n \tstruct rte_intr_callback *cb, *next;\n \n \t/* do parameter checking first */\n-\tif (intr_handle == NULL || intr_handle->fd < 0) {\n+\tif (intr_handle == NULL || rte_intr_fd_get(intr_handle) < 0) {\n \t\tRTE_LOG(ERR, EAL,\n \t\t\"Unregistering with invalid input parameter\\n\");\n \t\treturn -EINVAL;\n@@ -228,7 +241,8 @@ rte_intr_callback_unregister_pending(const struct rte_intr_handle *intr_handle,\n \n \t/* check if the insterrupt source for the fd is existent */\n \tTAILQ_FOREACH(src, &intr_sources, next)\n-\t\tif (src->intr_handle.fd == intr_handle->fd)\n+\t\tif (rte_intr_fd_get(src->intr_handle) ==\n+\t\t\t\t\trte_intr_fd_get(intr_handle))\n \t\t\tbreak;\n \n \t/* No interrupt source registered for the fd */\n@@ -268,7 +282,7 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,\n \tstruct rte_intr_callback *cb, *next;\n \n \t/* do parameter checking first */\n-\tif (intr_handle == NULL || intr_handle->fd < 0) {\n+\tif (intr_handle == NULL || rte_intr_fd_get(intr_handle) < 0) {\n \t\tRTE_LOG(ERR, EAL,\n \t\t\"Unregistering with invalid input parameter\\n\");\n \t\treturn -EINVAL;\n@@ -282,7 +296,8 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,\n \n \t/* check if the insterrupt source for the fd is existent */\n \tTAILQ_FOREACH(src, &intr_sources, next)\n-\t\tif (src->intr_handle.fd == intr_handle->fd)\n+\t\tif (rte_intr_fd_get(src->intr_handle) ==\n+\t\t\t\t\trte_intr_fd_get(intr_handle))\n \t\t\tbreak;\n \n \t/* No interrupt source registered for the fd */\n@@ -314,7 +329,8 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,\n \t\t */\n \t\tif (kevent(kq, &ke, 1, NULL, 0, NULL) < 0) {\n \t\t\tRTE_LOG(ERR, EAL, \"Error removing fd %d kevent, %s\\n\",\n-\t\t\t\tsrc->intr_handle.fd, strerror(errno));\n+\t\t\t\trte_intr_fd_get(src->intr_handle),\n+\t\t\t\tstrerror(errno));\n \t\t\t/* removing non-existent even is an expected condition\n \t\t\t * in some circumstances (e.g. oneshot events).\n \t\t\t */\n@@ -365,17 +381,18 @@ rte_intr_enable(const struct rte_intr_handle *intr_handle)\n \tif (intr_handle == NULL)\n \t\treturn -1;\n \n-\tif (intr_handle->type == RTE_INTR_HANDLE_VDEV) {\n+\tif (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_VDEV) {\n \t\trc = 0;\n \t\tgoto out;\n \t}\n \n-\tif (intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0) {\n+\tif (rte_intr_fd_get(intr_handle) < 0 ||\n+\t\t\t\trte_intr_dev_fd_get(intr_handle) < 0) {\n \t\trc = -1;\n \t\tgoto out;\n \t}\n \n-\tswitch (intr_handle->type) {\n+\tswitch (rte_intr_type_get(intr_handle)) {\n \t/* not used at this moment */\n \tcase RTE_INTR_HANDLE_ALARM:\n \t\trc = -1;\n@@ -388,7 +405,7 @@ rte_intr_enable(const struct rte_intr_handle *intr_handle)\n \tdefault:\n \t\tRTE_LOG(ERR, EAL,\n \t\t\t\"Unknown handle type of fd %d\\n\",\n-\t\t\t\t\tintr_handle->fd);\n+\t\t\t\t\trte_intr_fd_get(intr_handle));\n \t\trc = -1;\n \t\tbreak;\n \t}\n@@ -406,17 +423,18 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle)\n \tif (intr_handle == NULL)\n \t\treturn -1;\n \n-\tif (intr_handle->type == RTE_INTR_HANDLE_VDEV) {\n+\tif (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_VDEV) {\n \t\trc = 0;\n \t\tgoto out;\n \t}\n \n-\tif (intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0) {\n+\tif (rte_intr_fd_get(intr_handle) < 0 ||\n+\t\t\t\trte_intr_dev_fd_get(intr_handle) < 0) {\n \t\trc = -1;\n \t\tgoto out;\n \t}\n \n-\tswitch (intr_handle->type) {\n+\tswitch (rte_intr_type_get(intr_handle)) {\n \t/* not used at this moment */\n \tcase RTE_INTR_HANDLE_ALARM:\n \t\trc = -1;\n@@ -429,7 +447,7 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle)\n \tdefault:\n \t\tRTE_LOG(ERR, EAL,\n \t\t\t\"Unknown handle type of fd %d\\n\",\n-\t\t\t\t\tintr_handle->fd);\n+\t\t\t\t\trte_intr_fd_get(intr_handle));\n \t\trc = -1;\n \t\tbreak;\n \t}\n@@ -441,7 +459,8 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle)\n int\n rte_intr_ack(const struct rte_intr_handle *intr_handle)\n {\n-\tif (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV)\n+\tif (intr_handle &&\n+\t    rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_VDEV)\n \t\treturn 0;\n \n \treturn -1;\n@@ -463,7 +482,8 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)\n \n \t\trte_spinlock_lock(&intr_lock);\n \t\tTAILQ_FOREACH(src, &intr_sources, next)\n-\t\t\tif (src->intr_handle.fd == event_fd)\n+\t\t\tif (rte_intr_fd_get(src->intr_handle) ==\n+\t\t\t\t\t\t\t\tevent_fd)\n \t\t\t\tbreak;\n \t\tif (src == NULL) {\n \t\t\trte_spinlock_unlock(&intr_lock);\n@@ -475,7 +495,7 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)\n \t\trte_spinlock_unlock(&intr_lock);\n \n \t\t/* set the length to be read dor different handle type */\n-\t\tswitch (src->intr_handle.type) {\n+\t\tswitch (rte_intr_type_get(src->intr_handle)) {\n \t\tcase RTE_INTR_HANDLE_ALARM:\n \t\t\tbytes_read = 0;\n \t\t\tcall = true;\n@@ -546,7 +566,8 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)\n \t\t\t\t/* mark for deletion from the queue */\n \t\t\t\tke.flags = EV_DELETE;\n \n-\t\t\t\tif (intr_source_to_kevent(&src->intr_handle, &ke) < 0) {\n+\t\t\t\tif (intr_source_to_kevent(src->intr_handle,\n+\t\t\t\t\t\t\t  &ke) < 0) {\n \t\t\t\t\tRTE_LOG(ERR, EAL, \"Cannot convert to kevent\\n\");\n \t\t\t\t\trte_spinlock_unlock(&intr_lock);\n \t\t\t\t\treturn;\n@@ -557,7 +578,9 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)\n \t\t\t\t */\n \t\t\t\tif (kevent(kq, &ke, 1, NULL, 0, NULL) < 0) {\n \t\t\t\t\tRTE_LOG(ERR, EAL, \"Error removing fd %d kevent, \"\n-\t\t\t\t\t\t\"%s\\n\", src->intr_handle.fd,\n+\t\t\t\t\t\t\"%s\\n\",\n+\t\t\t\t\t\trte_intr_fd_get(\n+\t\t\t\t\t\t\tsrc->intr_handle),\n \t\t\t\t\t\tstrerror(errno));\n \t\t\t\t\t/* removing non-existent even is an expected\n \t\t\t\t\t * condition in some circumstances\n@@ -567,7 +590,8 @@ eal_intr_process_interrupts(struct kevent *events, int nfds)\n \n \t\t\t\tTAILQ_REMOVE(&src->callbacks, cb, next);\n \t\t\t\tif (cb->ucb_fn)\n-\t\t\t\t\tcb->ucb_fn(&src->intr_handle, cb->cb_arg);\n+\t\t\t\t\tcb->ucb_fn(src->intr_handle,\n+\t\t\t\t\t\t   cb->cb_arg);\n \t\t\t\tfree(cb);\n \t\t\t}\n \t\t}\ndiff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c\nindex 22b3b7bcd9..a250a9df66 100644\n--- a/lib/eal/linux/eal_interrupts.c\n+++ b/lib/eal/linux/eal_interrupts.c\n@@ -20,6 +20,7 @@\n #include <stdbool.h>\n \n #include <rte_common.h>\n+#include <rte_epoll.h>\n #include <rte_interrupts.h>\n #include <rte_memory.h>\n #include <rte_launch.h>\n@@ -82,7 +83,7 @@ struct rte_intr_callback {\n \n struct rte_intr_source {\n \tTAILQ_ENTRY(rte_intr_source) next;\n-\tstruct rte_intr_handle intr_handle; /**< interrupt handle */\n+\tstruct rte_intr_handle *intr_handle; /**< interrupt handle */\n \tstruct rte_intr_cb_list callbacks;  /**< user callbacks */\n \tuint32_t active;\n };\n@@ -112,7 +113,7 @@ static int\n vfio_enable_intx(const struct rte_intr_handle *intr_handle) {\n \tstruct vfio_irq_set *irq_set;\n \tchar irq_set_buf[IRQ_SET_BUF_LEN];\n-\tint len, ret;\n+\tint len, ret, vfio_dev_fd;\n \tint *fd_ptr;\n \n \tlen = sizeof(irq_set_buf);\n@@ -125,13 +126,14 @@ vfio_enable_intx(const struct rte_intr_handle *intr_handle) {\n \tirq_set->index = VFIO_PCI_INTX_IRQ_INDEX;\n \tirq_set->start = 0;\n \tfd_ptr = (int *) &irq_set->data;\n-\t*fd_ptr = intr_handle->fd;\n+\t*fd_ptr = rte_intr_fd_get(intr_handle);\n \n-\tret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n+\tvfio_dev_fd = rte_intr_dev_fd_get(intr_handle);\n+\tret = ioctl(vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n \n \tif (ret) {\n \t\tRTE_LOG(ERR, EAL, \"Error enabling INTx interrupts for fd %d\\n\",\n-\t\t\t\t\t\tintr_handle->fd);\n+\t\t\t\t\trte_intr_fd_get(intr_handle));\n \t\treturn -1;\n \t}\n \n@@ -144,11 +146,11 @@ vfio_enable_intx(const struct rte_intr_handle *intr_handle) {\n \tirq_set->index = VFIO_PCI_INTX_IRQ_INDEX;\n \tirq_set->start = 0;\n \n-\tret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n+\tret = ioctl(vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n \n \tif (ret) {\n \t\tRTE_LOG(ERR, EAL, \"Error unmasking INTx interrupts for fd %d\\n\",\n-\t\t\t\t\t\tintr_handle->fd);\n+\t\t\t\t\trte_intr_fd_get(intr_handle));\n \t\treturn -1;\n \t}\n \treturn 0;\n@@ -159,7 +161,7 @@ static int\n vfio_disable_intx(const struct rte_intr_handle *intr_handle) {\n \tstruct vfio_irq_set *irq_set;\n \tchar irq_set_buf[IRQ_SET_BUF_LEN];\n-\tint len, ret;\n+\tint len, ret, vfio_dev_fd;\n \n \tlen = sizeof(struct vfio_irq_set);\n \n@@ -171,11 +173,12 @@ vfio_disable_intx(const struct rte_intr_handle *intr_handle) {\n \tirq_set->index = VFIO_PCI_INTX_IRQ_INDEX;\n \tirq_set->start = 0;\n \n-\tret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n+\tvfio_dev_fd = rte_intr_dev_fd_get(intr_handle);\n+\tret = ioctl(vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n \n \tif (ret) {\n \t\tRTE_LOG(ERR, EAL, \"Error masking INTx interrupts for fd %d\\n\",\n-\t\t\t\t\t\tintr_handle->fd);\n+\t\t\t\t\trte_intr_fd_get(intr_handle));\n \t\treturn -1;\n \t}\n \n@@ -187,11 +190,12 @@ vfio_disable_intx(const struct rte_intr_handle *intr_handle) {\n \tirq_set->index = VFIO_PCI_INTX_IRQ_INDEX;\n \tirq_set->start = 0;\n \n-\tret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n+\tret = ioctl(vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n \n \tif (ret) {\n \t\tRTE_LOG(ERR, EAL,\n-\t\t\t\"Error disabling INTx interrupts for fd %d\\n\", intr_handle->fd);\n+\t\t\t\"Error disabling INTx interrupts for fd %d\\n\",\n+\t\t\trte_intr_fd_get(intr_handle));\n \t\treturn -1;\n \t}\n \treturn 0;\n@@ -202,6 +206,7 @@ static int\n vfio_ack_intx(const struct rte_intr_handle *intr_handle)\n {\n \tstruct vfio_irq_set irq_set;\n+\tint vfio_dev_fd;\n \n \t/* unmask INTx */\n \tmemset(&irq_set, 0, sizeof(irq_set));\n@@ -211,9 +216,10 @@ vfio_ack_intx(const struct rte_intr_handle *intr_handle)\n \tirq_set.index = VFIO_PCI_INTX_IRQ_INDEX;\n \tirq_set.start = 0;\n \n-\tif (ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, &irq_set)) {\n+\tvfio_dev_fd = rte_intr_dev_fd_get(intr_handle);\n+\tif (ioctl(vfio_dev_fd, VFIO_DEVICE_SET_IRQS, &irq_set)) {\n \t\tRTE_LOG(ERR, EAL, \"Error unmasking INTx interrupts for fd %d\\n\",\n-\t\t\tintr_handle->fd);\n+\t\t\trte_intr_fd_get(intr_handle));\n \t\treturn -1;\n \t}\n \treturn 0;\n@@ -225,7 +231,7 @@ vfio_enable_msi(const struct rte_intr_handle *intr_handle) {\n \tint len, ret;\n \tchar irq_set_buf[IRQ_SET_BUF_LEN];\n \tstruct vfio_irq_set *irq_set;\n-\tint *fd_ptr;\n+\tint *fd_ptr, vfio_dev_fd;\n \n \tlen = sizeof(irq_set_buf);\n \n@@ -236,13 +242,14 @@ vfio_enable_msi(const struct rte_intr_handle *intr_handle) {\n \tirq_set->index = VFIO_PCI_MSI_IRQ_INDEX;\n \tirq_set->start = 0;\n \tfd_ptr = (int *) &irq_set->data;\n-\t*fd_ptr = intr_handle->fd;\n+\t*fd_ptr = rte_intr_fd_get(intr_handle);\n \n-\tret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n+\tvfio_dev_fd = rte_intr_dev_fd_get(intr_handle);\n+\tret = ioctl(vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n \n \tif (ret) {\n \t\tRTE_LOG(ERR, EAL, \"Error enabling MSI interrupts for fd %d\\n\",\n-\t\t\t\t\t\tintr_handle->fd);\n+\t\t\t\t\trte_intr_fd_get(intr_handle));\n \t\treturn -1;\n \t}\n \treturn 0;\n@@ -253,7 +260,7 @@ static int\n vfio_disable_msi(const struct rte_intr_handle *intr_handle) {\n \tstruct vfio_irq_set *irq_set;\n \tchar irq_set_buf[IRQ_SET_BUF_LEN];\n-\tint len, ret;\n+\tint len, ret, vfio_dev_fd;\n \n \tlen = sizeof(struct vfio_irq_set);\n \n@@ -264,11 +271,13 @@ vfio_disable_msi(const struct rte_intr_handle *intr_handle) {\n \tirq_set->index = VFIO_PCI_MSI_IRQ_INDEX;\n \tirq_set->start = 0;\n \n-\tret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n+\tvfio_dev_fd = rte_intr_dev_fd_get(intr_handle);\n+\tret = ioctl(vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n \n \tif (ret)\n \t\tRTE_LOG(ERR, EAL,\n-\t\t\t\"Error disabling MSI interrupts for fd %d\\n\", intr_handle->fd);\n+\t\t\t\"Error disabling MSI interrupts for fd %d\\n\",\n+\t\t\trte_intr_fd_get(intr_handle));\n \n \treturn ret;\n }\n@@ -279,30 +288,34 @@ vfio_enable_msix(const struct rte_intr_handle *intr_handle) {\n \tint len, ret;\n \tchar irq_set_buf[MSIX_IRQ_SET_BUF_LEN];\n \tstruct vfio_irq_set *irq_set;\n-\tint *fd_ptr;\n+\tint *fd_ptr, vfio_dev_fd, i;\n \n \tlen = sizeof(irq_set_buf);\n \n \tirq_set = (struct vfio_irq_set *) irq_set_buf;\n \tirq_set->argsz = len;\n \t/* 0 < irq_set->count < RTE_MAX_RXTX_INTR_VEC_ID + 1 */\n-\tirq_set->count = intr_handle->max_intr ?\n-\t\t(intr_handle->max_intr > RTE_MAX_RXTX_INTR_VEC_ID + 1 ?\n-\t\tRTE_MAX_RXTX_INTR_VEC_ID + 1 : intr_handle->max_intr) : 1;\n+\tirq_set->count = rte_intr_max_intr_get(intr_handle) ?\n+\t\t(rte_intr_max_intr_get(intr_handle) >\n+\t\t RTE_MAX_RXTX_INTR_VEC_ID + 1 ?\tRTE_MAX_RXTX_INTR_VEC_ID + 1 :\n+\t\t rte_intr_max_intr_get(intr_handle)) : 1;\n+\n \tirq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER;\n \tirq_set->index = VFIO_PCI_MSIX_IRQ_INDEX;\n \tirq_set->start = 0;\n \tfd_ptr = (int *) &irq_set->data;\n \t/* INTR vector offset 0 reserve for non-efds mapping */\n-\tfd_ptr[RTE_INTR_VEC_ZERO_OFFSET] = intr_handle->fd;\n-\tmemcpy(&fd_ptr[RTE_INTR_VEC_RXTX_OFFSET], intr_handle->efds,\n-\t\tsizeof(*intr_handle->efds) * intr_handle->nb_efd);\n+\tfd_ptr[RTE_INTR_VEC_ZERO_OFFSET] = rte_intr_fd_get(intr_handle);\n+\tfor (i = 0; i < rte_intr_nb_efd_get(intr_handle); i++)\n+\t\tfd_ptr[RTE_INTR_VEC_RXTX_OFFSET + i] =\n+\t\t\trte_intr_efds_index_get(intr_handle, i);\n \n-\tret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n+\tvfio_dev_fd = rte_intr_dev_fd_get(intr_handle);\n+\tret = ioctl(vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n \n \tif (ret) {\n \t\tRTE_LOG(ERR, EAL, \"Error enabling MSI-X interrupts for fd %d\\n\",\n-\t\t\t\t\t\tintr_handle->fd);\n+\t\t\t\t\trte_intr_fd_get(intr_handle));\n \t\treturn -1;\n \t}\n \n@@ -314,7 +327,7 @@ static int\n vfio_disable_msix(const struct rte_intr_handle *intr_handle) {\n \tstruct vfio_irq_set *irq_set;\n \tchar irq_set_buf[MSIX_IRQ_SET_BUF_LEN];\n-\tint len, ret;\n+\tint len, ret, vfio_dev_fd;\n \n \tlen = sizeof(struct vfio_irq_set);\n \n@@ -325,11 +338,13 @@ vfio_disable_msix(const struct rte_intr_handle *intr_handle) {\n \tirq_set->index = VFIO_PCI_MSIX_IRQ_INDEX;\n \tirq_set->start = 0;\n \n-\tret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n+\tvfio_dev_fd = rte_intr_dev_fd_get(intr_handle);\n+\tret = ioctl(vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n \n \tif (ret)\n \t\tRTE_LOG(ERR, EAL,\n-\t\t\t\"Error disabling MSI-X interrupts for fd %d\\n\", intr_handle->fd);\n+\t\t\t\"Error disabling MSI-X interrupts for fd %d\\n\",\n+\t\t\trte_intr_fd_get(intr_handle));\n \n \treturn ret;\n }\n@@ -342,7 +357,7 @@ vfio_enable_req(const struct rte_intr_handle *intr_handle)\n \tint len, ret;\n \tchar irq_set_buf[IRQ_SET_BUF_LEN];\n \tstruct vfio_irq_set *irq_set;\n-\tint *fd_ptr;\n+\tint *fd_ptr, vfio_dev_fd;\n \n \tlen = sizeof(irq_set_buf);\n \n@@ -354,13 +369,14 @@ vfio_enable_req(const struct rte_intr_handle *intr_handle)\n \tirq_set->index = VFIO_PCI_REQ_IRQ_INDEX;\n \tirq_set->start = 0;\n \tfd_ptr = (int *) &irq_set->data;\n-\t*fd_ptr = intr_handle->fd;\n+\t*fd_ptr = rte_intr_fd_get(intr_handle);\n \n-\tret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n+\tvfio_dev_fd = rte_intr_dev_fd_get(intr_handle);\n+\tret = ioctl(vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n \n \tif (ret) {\n \t\tRTE_LOG(ERR, EAL, \"Error enabling req interrupts for fd %d\\n\",\n-\t\t\t\t\t\tintr_handle->fd);\n+\t\t\t\t\trte_intr_fd_get(intr_handle));\n \t\treturn -1;\n \t}\n \n@@ -373,7 +389,7 @@ vfio_disable_req(const struct rte_intr_handle *intr_handle)\n {\n \tstruct vfio_irq_set *irq_set;\n \tchar irq_set_buf[IRQ_SET_BUF_LEN];\n-\tint len, ret;\n+\tint len, ret, vfio_dev_fd;\n \n \tlen = sizeof(struct vfio_irq_set);\n \n@@ -384,11 +400,12 @@ vfio_disable_req(const struct rte_intr_handle *intr_handle)\n \tirq_set->index = VFIO_PCI_REQ_IRQ_INDEX;\n \tirq_set->start = 0;\n \n-\tret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n+\tvfio_dev_fd = rte_intr_dev_fd_get(intr_handle);\n+\tret = ioctl(vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);\n \n \tif (ret)\n \t\tRTE_LOG(ERR, EAL, \"Error disabling req interrupts for fd %d\\n\",\n-\t\t\tintr_handle->fd);\n+\t\t\trte_intr_fd_get(intr_handle));\n \n \treturn ret;\n }\n@@ -399,20 +416,22 @@ static int\n uio_intx_intr_disable(const struct rte_intr_handle *intr_handle)\n {\n \tunsigned char command_high;\n+\tint uio_cfg_fd;\n \n \t/* use UIO config file descriptor for uio_pci_generic */\n-\tif (pread(intr_handle->uio_cfg_fd, &command_high, 1, 5) != 1) {\n+\tuio_cfg_fd = rte_intr_dev_fd_get(intr_handle);\n+\tif (pread(uio_cfg_fd, &command_high, 1, 5) != 1) {\n \t\tRTE_LOG(ERR, EAL,\n \t\t\t\"Error reading interrupts status for fd %d\\n\",\n-\t\t\tintr_handle->uio_cfg_fd);\n+\t\t\tuio_cfg_fd);\n \t\treturn -1;\n \t}\n \t/* disable interrupts */\n \tcommand_high |= 0x4;\n-\tif (pwrite(intr_handle->uio_cfg_fd, &command_high, 1, 5) != 1) {\n+\tif (pwrite(uio_cfg_fd, &command_high, 1, 5) != 1) {\n \t\tRTE_LOG(ERR, EAL,\n \t\t\t\"Error disabling interrupts for fd %d\\n\",\n-\t\t\tintr_handle->uio_cfg_fd);\n+\t\t\tuio_cfg_fd);\n \t\treturn -1;\n \t}\n \n@@ -423,20 +442,22 @@ static int\n uio_intx_intr_enable(const struct rte_intr_handle *intr_handle)\n {\n \tunsigned char command_high;\n+\tint uio_cfg_fd;\n \n \t/* use UIO config file descriptor for uio_pci_generic */\n-\tif (pread(intr_handle->uio_cfg_fd, &command_high, 1, 5) != 1) {\n+\tuio_cfg_fd = rte_intr_dev_fd_get(intr_handle);\n+\tif (pread(uio_cfg_fd, &command_high, 1, 5) != 1) {\n \t\tRTE_LOG(ERR, EAL,\n \t\t\t\"Error reading interrupts status for fd %d\\n\",\n-\t\t\tintr_handle->uio_cfg_fd);\n+\t\t\tuio_cfg_fd);\n \t\treturn -1;\n \t}\n \t/* enable interrupts */\n \tcommand_high &= ~0x4;\n-\tif (pwrite(intr_handle->uio_cfg_fd, &command_high, 1, 5) != 1) {\n+\tif (pwrite(uio_cfg_fd, &command_high, 1, 5) != 1) {\n \t\tRTE_LOG(ERR, EAL,\n \t\t\t\"Error enabling interrupts for fd %d\\n\",\n-\t\t\tintr_handle->uio_cfg_fd);\n+\t\t\tuio_cfg_fd);\n \t\treturn -1;\n \t}\n \n@@ -448,10 +469,11 @@ uio_intr_disable(const struct rte_intr_handle *intr_handle)\n {\n \tconst int value = 0;\n \n-\tif (write(intr_handle->fd, &value, sizeof(value)) < 0) {\n+\tif (write(rte_intr_fd_get(intr_handle), &value,\n+\t\t  sizeof(value)) < 0) {\n \t\tRTE_LOG(ERR, EAL,\n \t\t\t\"Error disabling interrupts for fd %d (%s)\\n\",\n-\t\t\tintr_handle->fd, strerror(errno));\n+\t\t\trte_intr_fd_get(intr_handle), strerror(errno));\n \t\treturn -1;\n \t}\n \treturn 0;\n@@ -462,10 +484,11 @@ uio_intr_enable(const struct rte_intr_handle *intr_handle)\n {\n \tconst int value = 1;\n \n-\tif (write(intr_handle->fd, &value, sizeof(value)) < 0) {\n+\tif (write(rte_intr_fd_get(intr_handle), &value,\n+\t\t  sizeof(value)) < 0) {\n \t\tRTE_LOG(ERR, EAL,\n \t\t\t\"Error enabling interrupts for fd %d (%s)\\n\",\n-\t\t\tintr_handle->fd, strerror(errno));\n+\t\t\trte_intr_fd_get(intr_handle), strerror(errno));\n \t\treturn -1;\n \t}\n \treturn 0;\n@@ -482,7 +505,8 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,\n \twake_thread = 0;\n \n \t/* first do parameter checking */\n-\tif (intr_handle == NULL || intr_handle->fd < 0 || cb == NULL) {\n+\tif (intr_handle == NULL || rte_intr_fd_get(intr_handle) < 0 ||\n+\t    cb == NULL) {\n \t\tRTE_LOG(ERR, EAL,\n \t\t\t\"Registering with invalid input parameter\\n\");\n \t\treturn -EINVAL;\n@@ -503,7 +527,8 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,\n \n \t/* check if there is at least one callback registered for the fd */\n \tTAILQ_FOREACH(src, &intr_sources, next) {\n-\t\tif (src->intr_handle.fd == intr_handle->fd) {\n+\t\tif (rte_intr_fd_get(src->intr_handle) ==\n+\t\t\t\t\trte_intr_fd_get(intr_handle)) {\n \t\t\t/* we had no interrupts for this */\n \t\t\tif (TAILQ_EMPTY(&src->callbacks))\n \t\t\t\twake_thread = 1;\n@@ -522,12 +547,21 @@ rte_intr_callback_register(const struct rte_intr_handle *intr_handle,\n \t\t\tfree(callback);\n \t\t\tret = -ENOMEM;\n \t\t} else {\n-\t\t\tsrc->intr_handle = *intr_handle;\n-\t\t\tTAILQ_INIT(&src->callbacks);\n-\t\t\tTAILQ_INSERT_TAIL(&(src->callbacks), callback, next);\n-\t\t\tTAILQ_INSERT_TAIL(&intr_sources, src, next);\n-\t\t\twake_thread = 1;\n-\t\t\tret = 0;\n+\t\t\tsrc->intr_handle = rte_intr_instance_alloc();\n+\t\t\tif (src->intr_handle == NULL) {\n+\t\t\t\tRTE_LOG(ERR, EAL, \"Can not create intr instance\\n\");\n+\t\t\t\tfree(callback);\n+\t\t\t\tret = -ENOMEM;\n+\t\t\t} else {\n+\t\t\t\trte_intr_instance_copy(src->intr_handle,\n+\t\t\t\t\t\t       intr_handle);\n+\t\t\t\tTAILQ_INIT(&src->callbacks);\n+\t\t\t\tTAILQ_INSERT_TAIL(&(src->callbacks), callback,\n+\t\t\t\t\t\t  next);\n+\t\t\t\tTAILQ_INSERT_TAIL(&intr_sources, src, next);\n+\t\t\t\twake_thread = 1;\n+\t\t\t\tret = 0;\n+\t\t\t}\n \t\t}\n \t}\n \n@@ -555,7 +589,7 @@ rte_intr_callback_unregister_pending(const struct rte_intr_handle *intr_handle,\n \tstruct rte_intr_callback *cb, *next;\n \n \t/* do parameter checking first */\n-\tif (intr_handle == NULL || intr_handle->fd < 0) {\n+\tif (intr_handle == NULL || rte_intr_fd_get(intr_handle) < 0) {\n \t\tRTE_LOG(ERR, EAL,\n \t\t\"Unregistering with invalid input parameter\\n\");\n \t\treturn -EINVAL;\n@@ -565,7 +599,8 @@ rte_intr_callback_unregister_pending(const struct rte_intr_handle *intr_handle,\n \n \t/* check if the insterrupt source for the fd is existent */\n \tTAILQ_FOREACH(src, &intr_sources, next)\n-\t\tif (src->intr_handle.fd == intr_handle->fd)\n+\t\tif (rte_intr_fd_get(src->intr_handle) ==\n+\t\t\t\t\trte_intr_fd_get(intr_handle))\n \t\t\tbreak;\n \n \t/* No interrupt source registered for the fd */\n@@ -605,7 +640,7 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,\n \tstruct rte_intr_callback *cb, *next;\n \n \t/* do parameter checking first */\n-\tif (intr_handle == NULL || intr_handle->fd < 0) {\n+\tif (intr_handle == NULL || rte_intr_fd_get(intr_handle) < 0) {\n \t\tRTE_LOG(ERR, EAL,\n \t\t\"Unregistering with invalid input parameter\\n\");\n \t\treturn -EINVAL;\n@@ -615,7 +650,8 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,\n \n \t/* check if the insterrupt source for the fd is existent */\n \tTAILQ_FOREACH(src, &intr_sources, next)\n-\t\tif (src->intr_handle.fd == intr_handle->fd)\n+\t\tif (rte_intr_fd_get(src->intr_handle) ==\n+\t\t\t\t\trte_intr_fd_get(intr_handle))\n \t\t\tbreak;\n \n \t/* No interrupt source registered for the fd */\n@@ -646,6 +682,7 @@ rte_intr_callback_unregister(const struct rte_intr_handle *intr_handle,\n \t\t/* all callbacks for that source are removed. */\n \t\tif (TAILQ_EMPTY(&src->callbacks)) {\n \t\t\tTAILQ_REMOVE(&intr_sources, src, next);\n+\t\t\trte_intr_instance_free(src->intr_handle);\n \t\t\tfree(src);\n \t\t}\n \t}\n@@ -677,22 +714,23 @@ rte_intr_callback_unregister_sync(const struct rte_intr_handle *intr_handle,\n int\n rte_intr_enable(const struct rte_intr_handle *intr_handle)\n {\n-\tint rc = 0;\n+\tint rc = 0, uio_cfg_fd;\n \n \tif (intr_handle == NULL)\n \t\treturn -1;\n \n-\tif (intr_handle->type == RTE_INTR_HANDLE_VDEV) {\n+\tif (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_VDEV) {\n \t\trc = 0;\n \t\tgoto out;\n \t}\n \n-\tif (intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0) {\n+\tuio_cfg_fd = rte_intr_dev_fd_get(intr_handle);\n+\tif (rte_intr_fd_get(intr_handle) < 0 || uio_cfg_fd < 0) {\n \t\trc = -1;\n \t\tgoto out;\n \t}\n \n-\tswitch (intr_handle->type){\n+\tswitch (rte_intr_type_get(intr_handle)) {\n \t/* write to the uio fd to enable the interrupt */\n \tcase RTE_INTR_HANDLE_UIO:\n \t\tif (uio_intr_enable(intr_handle))\n@@ -734,7 +772,7 @@ rte_intr_enable(const struct rte_intr_handle *intr_handle)\n \tdefault:\n \t\tRTE_LOG(ERR, EAL,\n \t\t\t\"Unknown handle type of fd %d\\n\",\n-\t\t\t\t\tintr_handle->fd);\n+\t\t\t\t\trte_intr_fd_get(intr_handle));\n \t\trc = -1;\n \t\tbreak;\n \t}\n@@ -757,13 +795,17 @@ rte_intr_enable(const struct rte_intr_handle *intr_handle)\n int\n rte_intr_ack(const struct rte_intr_handle *intr_handle)\n {\n-\tif (intr_handle && intr_handle->type == RTE_INTR_HANDLE_VDEV)\n+\tint uio_cfg_fd;\n+\n+\tif (intr_handle && rte_intr_type_get(intr_handle) ==\n+\t\t\t\t\t\t\tRTE_INTR_HANDLE_VDEV)\n \t\treturn 0;\n \n-\tif (!intr_handle || intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0)\n+\tuio_cfg_fd = rte_intr_dev_fd_get(intr_handle);\n+\tif (!intr_handle || rte_intr_fd_get(intr_handle) < 0 || uio_cfg_fd < 0)\n \t\treturn -1;\n \n-\tswitch (intr_handle->type) {\n+\tswitch (rte_intr_type_get(intr_handle)) {\n \t/* Both acking and enabling are same for UIO */\n \tcase RTE_INTR_HANDLE_UIO:\n \t\tif (uio_intr_enable(intr_handle))\n@@ -796,7 +838,7 @@ rte_intr_ack(const struct rte_intr_handle *intr_handle)\n \t/* unknown handle type */\n \tdefault:\n \t\tRTE_LOG(ERR, EAL, \"Unknown handle type of fd %d\\n\",\n-\t\t\tintr_handle->fd);\n+\t\t\trte_intr_fd_get(intr_handle));\n \t\treturn -1;\n \t}\n \n@@ -806,22 +848,23 @@ rte_intr_ack(const struct rte_intr_handle *intr_handle)\n int\n rte_intr_disable(const struct rte_intr_handle *intr_handle)\n {\n-\tint rc = 0;\n+\tint rc = 0, uio_cfg_fd;\n \n \tif (intr_handle == NULL)\n \t\treturn -1;\n \n-\tif (intr_handle->type == RTE_INTR_HANDLE_VDEV) {\n+\tif (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_VDEV) {\n \t\trc = 0;\n \t\tgoto out;\n \t}\n \n-\tif (intr_handle->fd < 0 || intr_handle->uio_cfg_fd < 0) {\n+\tuio_cfg_fd = rte_intr_dev_fd_get(intr_handle);\n+\tif (rte_intr_fd_get(intr_handle) < 0 || uio_cfg_fd < 0) {\n \t\trc = -1;\n \t\tgoto out;\n \t}\n \n-\tswitch (intr_handle->type){\n+\tswitch (rte_intr_type_get(intr_handle)) {\n \t/* write to the uio fd to disable the interrupt */\n \tcase RTE_INTR_HANDLE_UIO:\n \t\tif (uio_intr_disable(intr_handle))\n@@ -863,7 +906,7 @@ rte_intr_disable(const struct rte_intr_handle *intr_handle)\n \tdefault:\n \t\tRTE_LOG(ERR, EAL,\n \t\t\t\"Unknown handle type of fd %d\\n\",\n-\t\t\t\t\tintr_handle->fd);\n+\t\t\trte_intr_fd_get(intr_handle));\n \t\trc = -1;\n \t\tbreak;\n \t}\n@@ -896,7 +939,7 @@ eal_intr_process_interrupts(struct epoll_event *events, int nfds)\n \t\t}\n \t\trte_spinlock_lock(&intr_lock);\n \t\tTAILQ_FOREACH(src, &intr_sources, next)\n-\t\t\tif (src->intr_handle.fd ==\n+\t\t\tif (rte_intr_fd_get(src->intr_handle) ==\n \t\t\t\t\tevents[n].data.fd)\n \t\t\t\tbreak;\n \t\tif (src == NULL){\n@@ -909,7 +952,7 @@ eal_intr_process_interrupts(struct epoll_event *events, int nfds)\n \t\trte_spinlock_unlock(&intr_lock);\n \n \t\t/* set the length to be read dor different handle type */\n-\t\tswitch (src->intr_handle.type) {\n+\t\tswitch (rte_intr_type_get(src->intr_handle)) {\n \t\tcase RTE_INTR_HANDLE_UIO:\n \t\tcase RTE_INTR_HANDLE_UIO_INTX:\n \t\t\tbytes_read = sizeof(buf.uio_intr_count);\n@@ -973,6 +1016,7 @@ eal_intr_process_interrupts(struct epoll_event *events, int nfds)\n \t\t\t\t\tTAILQ_REMOVE(&src->callbacks, cb, next);\n \t\t\t\t\tfree(cb);\n \t\t\t\t}\n+\t\t\t\trte_intr_instance_free(src->intr_handle);\n \t\t\t\tfree(src);\n \t\t\t\treturn -1;\n \t\t\t} else if (bytes_read == 0)\n@@ -1012,7 +1056,8 @@ eal_intr_process_interrupts(struct epoll_event *events, int nfds)\n \t\t\tif (cb->pending_delete) {\n \t\t\t\tTAILQ_REMOVE(&src->callbacks, cb, next);\n \t\t\t\tif (cb->ucb_fn)\n-\t\t\t\t\tcb->ucb_fn(&src->intr_handle, cb->cb_arg);\n+\t\t\t\t\tcb->ucb_fn(src->intr_handle,\n+\t\t\t\t\t\t   cb->cb_arg);\n \t\t\t\tfree(cb);\n \t\t\t\trv++;\n \t\t\t}\n@@ -1021,6 +1066,7 @@ eal_intr_process_interrupts(struct epoll_event *events, int nfds)\n \t\t/* all callbacks for that source are removed. */\n \t\tif (TAILQ_EMPTY(&src->callbacks)) {\n \t\t\tTAILQ_REMOVE(&intr_sources, src, next);\n+\t\t\trte_intr_instance_free(src->intr_handle);\n \t\t\tfree(src);\n \t\t}\n \n@@ -1123,16 +1169,18 @@ eal_intr_thread_main(__rte_unused void *arg)\n \t\t\t\tcontinue; /* skip those with no callbacks */\n \t\t\tmemset(&ev, 0, sizeof(ev));\n \t\t\tev.events = EPOLLIN | EPOLLPRI | EPOLLRDHUP | EPOLLHUP;\n-\t\t\tev.data.fd = src->intr_handle.fd;\n+\t\t\tev.data.fd = rte_intr_fd_get(src->intr_handle);\n \n \t\t\t/**\n \t\t\t * add all the uio device file descriptor\n \t\t\t * into wait list.\n \t\t\t */\n \t\t\tif (epoll_ctl(pfd, EPOLL_CTL_ADD,\n-\t\t\t\t\tsrc->intr_handle.fd, &ev) < 0){\n+\t\t\t\trte_intr_fd_get(src->intr_handle),\n+\t\t\t\t\t\t\t\t&ev) < 0) {\n \t\t\t\trte_panic(\"Error adding fd %d epoll_ctl, %s\\n\",\n-\t\t\t\t\tsrc->intr_handle.fd, strerror(errno));\n+\t\t\t\trte_intr_fd_get(src->intr_handle),\n+\t\t\t\tstrerror(errno));\n \t\t\t}\n \t\t\telse\n \t\t\t\tnumfds++;\n@@ -1185,7 +1233,7 @@ eal_intr_proc_rxtx_intr(int fd, const struct rte_intr_handle *intr_handle)\n \tint bytes_read = 0;\n \tint nbytes;\n \n-\tswitch (intr_handle->type) {\n+\tswitch (rte_intr_type_get(intr_handle)) {\n \tcase RTE_INTR_HANDLE_UIO:\n \tcase RTE_INTR_HANDLE_UIO_INTX:\n \t\tbytes_read = sizeof(buf.uio_intr_count);\n@@ -1198,7 +1246,7 @@ eal_intr_proc_rxtx_intr(int fd, const struct rte_intr_handle *intr_handle)\n \t\tbreak;\n #endif\n \tcase RTE_INTR_HANDLE_VDEV:\n-\t\tbytes_read = intr_handle->efd_counter_size;\n+\t\tbytes_read = rte_intr_efd_counter_size_get(intr_handle);\n \t\t/* For vdev, number of bytes to read is set by driver */\n \t\tbreak;\n \tcase RTE_INTR_HANDLE_EXT:\n@@ -1419,8 +1467,8 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, int epfd,\n \tefd_idx = (vec >= RTE_INTR_VEC_RXTX_OFFSET) ?\n \t\t(vec - RTE_INTR_VEC_RXTX_OFFSET) : vec;\n \n-\tif (!intr_handle || intr_handle->nb_efd == 0 ||\n-\t    efd_idx >= intr_handle->nb_efd) {\n+\tif (!intr_handle || rte_intr_nb_efd_get(intr_handle) == 0 ||\n+\t    efd_idx >= (unsigned int)rte_intr_nb_efd_get(intr_handle)) {\n \t\tRTE_LOG(ERR, EAL, \"Wrong intr vector number.\\n\");\n \t\treturn -EPERM;\n \t}\n@@ -1428,7 +1476,7 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, int epfd,\n \tswitch (op) {\n \tcase RTE_INTR_EVENT_ADD:\n \t\tepfd_op = EPOLL_CTL_ADD;\n-\t\trev = &intr_handle->elist[efd_idx];\n+\t\trev = rte_intr_elist_index_get(intr_handle, efd_idx);\n \t\tif (__atomic_load_n(&rev->status,\n \t\t\t\t__ATOMIC_RELAXED) != RTE_EPOLL_INVALID) {\n \t\t\tRTE_LOG(INFO, EAL, \"Event already been added.\\n\");\n@@ -1442,7 +1490,9 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, int epfd,\n \t\tepdata->cb_fun = (rte_intr_event_cb_t)eal_intr_proc_rxtx_intr;\n \t\tepdata->cb_arg = (void *)intr_handle;\n \t\trc = rte_epoll_ctl(epfd, epfd_op,\n-\t\t\t\t   intr_handle->efds[efd_idx], rev);\n+\t\t\t\t   rte_intr_efds_index_get(intr_handle,\n+\t\t\t\t\t\t\t\t  efd_idx),\n+\t\t\t\t   rev);\n \t\tif (!rc)\n \t\t\tRTE_LOG(DEBUG, EAL,\n \t\t\t\t\"efd %d associated with vec %d added on epfd %d\"\n@@ -1452,7 +1502,7 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, int epfd,\n \t\tbreak;\n \tcase RTE_INTR_EVENT_DEL:\n \t\tepfd_op = EPOLL_CTL_DEL;\n-\t\trev = &intr_handle->elist[efd_idx];\n+\t\trev = rte_intr_elist_index_get(intr_handle, efd_idx);\n \t\tif (__atomic_load_n(&rev->status,\n \t\t\t\t__ATOMIC_RELAXED) == RTE_EPOLL_INVALID) {\n \t\t\tRTE_LOG(INFO, EAL, \"Event does not exist.\\n\");\n@@ -1477,8 +1527,9 @@ rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle)\n \tuint32_t i;\n \tstruct rte_epoll_event *rev;\n \n-\tfor (i = 0; i < intr_handle->nb_efd; i++) {\n-\t\trev = &intr_handle->elist[i];\n+\tfor (i = 0; i < (uint32_t)rte_intr_nb_efd_get(intr_handle);\n+\t\t\t\t\t\t\t\t\ti++) {\n+\t\trev = rte_intr_elist_index_get(intr_handle, i);\n \t\tif (__atomic_load_n(&rev->status,\n \t\t\t\t__ATOMIC_RELAXED) == RTE_EPOLL_INVALID)\n \t\t\tcontinue;\n@@ -1498,7 +1549,7 @@ rte_intr_efd_enable(struct rte_intr_handle *intr_handle, uint32_t nb_efd)\n \n \tassert(nb_efd != 0);\n \n-\tif (intr_handle->type == RTE_INTR_HANDLE_VFIO_MSIX) {\n+\tif (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_VFIO_MSIX) {\n \t\tfor (i = 0; i < n; i++) {\n \t\t\tfd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);\n \t\t\tif (fd < 0) {\n@@ -1507,21 +1558,32 @@ rte_intr_efd_enable(struct rte_intr_handle *intr_handle, uint32_t nb_efd)\n \t\t\t\t\terrno, strerror(errno));\n \t\t\t\treturn -errno;\n \t\t\t}\n-\t\t\tintr_handle->efds[i] = fd;\n+\n+\t\t\tif (rte_intr_efds_index_set(intr_handle, i, fd))\n+\t\t\t\treturn -rte_errno;\n \t\t}\n-\t\tintr_handle->nb_efd   = n;\n-\t\tintr_handle->max_intr = NB_OTHER_INTR + n;\n-\t} else if (intr_handle->type == RTE_INTR_HANDLE_VDEV) {\n+\n+\t\tif (rte_intr_nb_efd_set(intr_handle, n))\n+\t\t\treturn -rte_errno;\n+\n+\t\tif (rte_intr_max_intr_set(intr_handle, NB_OTHER_INTR + n))\n+\t\t\treturn -rte_errno;\n+\t} else if (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_VDEV) {\n \t\t/* only check, initialization would be done in vdev driver.*/\n-\t\tif (intr_handle->efd_counter_size >\n+\t\tif ((uint64_t)rte_intr_efd_counter_size_get(intr_handle) >\n \t\t    sizeof(union rte_intr_read_buffer)) {\n \t\t\tRTE_LOG(ERR, EAL, \"the efd_counter_size is oversized\");\n \t\t\treturn -EINVAL;\n \t\t}\n \t} else {\n-\t\tintr_handle->efds[0]  = intr_handle->fd;\n-\t\tintr_handle->nb_efd   = RTE_MIN(nb_efd, 1U);\n-\t\tintr_handle->max_intr = NB_OTHER_INTR;\n+\t\tif (rte_intr_efds_index_set(intr_handle, 0,\n+\t\t\t\t\t    rte_intr_fd_get(intr_handle)))\n+\t\t\treturn -rte_errno;\n+\t\tif (rte_intr_nb_efd_set(intr_handle,\n+\t\t\t\t\tRTE_MIN(nb_efd, 1U)))\n+\t\t\treturn -rte_errno;\n+\t\tif (rte_intr_max_intr_set(intr_handle, NB_OTHER_INTR))\n+\t\t\treturn -rte_errno;\n \t}\n \n \treturn 0;\n@@ -1533,18 +1595,20 @@ rte_intr_efd_disable(struct rte_intr_handle *intr_handle)\n \tuint32_t i;\n \n \trte_intr_free_epoll_fd(intr_handle);\n-\tif (intr_handle->max_intr > intr_handle->nb_efd) {\n-\t\tfor (i = 0; i < intr_handle->nb_efd; i++)\n-\t\t\tclose(intr_handle->efds[i]);\n+\tif (rte_intr_max_intr_get(intr_handle) >\n+\t\t\t\trte_intr_nb_efd_get(intr_handle)) {\n+\t\tfor (i = 0; i <\n+\t\t\t(uint32_t)rte_intr_nb_efd_get(intr_handle); i++)\n+\t\t\tclose(rte_intr_efds_index_get(intr_handle, i));\n \t}\n-\tintr_handle->nb_efd = 0;\n-\tintr_handle->max_intr = 0;\n+\trte_intr_nb_efd_set(intr_handle, 0);\n+\trte_intr_max_intr_set(intr_handle, 0);\n }\n \n int\n rte_intr_dp_is_en(struct rte_intr_handle *intr_handle)\n {\n-\treturn !(!intr_handle->nb_efd);\n+\treturn !(!rte_intr_nb_efd_get(intr_handle));\n }\n \n int\n@@ -1553,16 +1617,17 @@ rte_intr_allow_others(struct rte_intr_handle *intr_handle)\n \tif (!rte_intr_dp_is_en(intr_handle))\n \t\treturn 1;\n \telse\n-\t\treturn !!(intr_handle->max_intr - intr_handle->nb_efd);\n+\t\treturn !!(rte_intr_max_intr_get(intr_handle) -\n+\t\t\t\trte_intr_nb_efd_get(intr_handle));\n }\n \n int\n rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)\n {\n-\tif (intr_handle->type == RTE_INTR_HANDLE_VFIO_MSIX)\n+\tif (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_VFIO_MSIX)\n \t\treturn 1;\n \n-\tif (intr_handle->type == RTE_INTR_HANDLE_VDEV)\n+\tif (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_VDEV)\n \t\treturn 1;\n \n \treturn 0;\n",
    "prefixes": [
        "v4",
        "3/7"
    ]
}