get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 54518,
    "url": "http://patches.dpdk.org/api/patches/54518/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20190606182957.56596-2-vipin.varghese@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": "<20190606182957.56596-2-vipin.varghese@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20190606182957.56596-2-vipin.varghese@intel.com",
    "date": "2019-06-06T18:29:56",
    "name": "[v1,1/2] lib/event: add callback handlers for event",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "d4a1bdb8d1ba6aed912ecc23c248ddce4446e065",
    "submitter": {
        "id": 882,
        "url": "http://patches.dpdk.org/api/people/882/?format=api",
        "name": "Varghese, Vipin",
        "email": "vipin.varghese@intel.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20190606182957.56596-2-vipin.varghese@intel.com/mbox/",
    "series": [
        {
            "id": 4941,
            "url": "http://patches.dpdk.org/api/series/4941/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=4941",
            "date": "2019-06-06T18:29:55",
            "name": "event enqueue-dequeue callback handler",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/4941/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/54518/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/54518/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 F23F91B997;\n\tThu,  6 Jun 2019 20:29:29 +0200 (CEST)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby dpdk.org (Postfix) with ESMTP id 921331B96B\n\tfor <dev@dpdk.org>; Thu,  6 Jun 2019 20:29:28 +0200 (CEST)",
            "from orsmga005.jf.intel.com ([10.7.209.41])\n\tby fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t06 Jun 2019 11:29:28 -0700",
            "from unknown (HELO saesrv02-S2600CWR.intel.com) ([10.224.122.203])\n\tby orsmga005.jf.intel.com with ESMTP; 06 Jun 2019 11:29:24 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "From": "Vipin Varghese <vipin.varghese@intel.com>",
        "To": "marko.kovacevic@intel.com, john.mcnamara@intel.com, jerinj@marvell.com, \n\tharry.van.haaren@intel.com, keith.wiles@intel.com, gage.eads@intel.com, \n\tdev@dpdk.org",
        "Cc": "sanjay.padubidri@intel.com, narender.vangati@intel.com,\n\tilia.kurakin@intel.com, Vipin Varghese <vipin.varghese@intel.com>",
        "Date": "Thu,  6 Jun 2019 23:59:56 +0530",
        "Message-Id": "<20190606182957.56596-2-vipin.varghese@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20190606182957.56596-1-vipin.varghese@intel.com>",
        "References": "<20190606182957.56596-1-vipin.varghese@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v1 1/2] lib/event: add callback handlers for event",
        "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": "Add callback event handler for enqueue dequeue operation on event\ndevice. The pre-enqueue and post-dequeue are the selected to invoke\nuser callback handler.\n\nSigned-off-by: Vipin Varghese <vipin.varghese@intel.com>\n---\n config/common_base                           |   1 +\n lib/librte_eventdev/rte_eventdev.c           | 361 +++++++++++++++++++\n lib/librte_eventdev/rte_eventdev.h           | 267 +++++++++++++-\n lib/librte_eventdev/rte_eventdev_version.map |   8 +\n 4 files changed, 633 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/config/common_base b/config/common_base\nindex 6f19ad5d2..ec29455d2 100644\n--- a/config/common_base\n+++ b/config/common_base\n@@ -681,6 +681,7 @@ CONFIG_RTE_EVENT_TIMER_ADAPTER_NUM_MAX=32\n CONFIG_RTE_EVENT_ETH_INTR_RING_SIZE=1024\n CONFIG_RTE_EVENT_CRYPTO_ADAPTER_MAX_INSTANCE=32\n CONFIG_RTE_EVENT_ETH_TX_ADAPTER_MAX_INSTANCE=32\n+CONFIG_RTE_EVENTDEV_ENQDEQ_CALLBACKS=n\n \n #\n # Compile PMD for skeleton event device\ndiff --git a/lib/librte_eventdev/rte_eventdev.c b/lib/librte_eventdev/rte_eventdev.c\nindex cc3199fb6..de9c772ce 100644\n--- a/lib/librte_eventdev/rte_eventdev.c\n+++ b/lib/librte_eventdev/rte_eventdev.c\n@@ -44,6 +44,11 @@ static struct rte_eventdev_global eventdev_globals = {\n \t.nb_devs\t\t= 0\n };\n \n+/* spinlock for pre-enqueue callbacks */\n+rte_spinlock_t rte_eventdev_preenq_cb_lock = RTE_SPINLOCK_INITIALIZER;\n+/* spinlock for post-dequeue callbacks */\n+rte_spinlock_t rte_eventdev_pstdeq_cb_lock = RTE_SPINLOCK_INITIALIZER;\n+\n /* Event dev north bound API implementation */\n \n uint8_t\n@@ -524,6 +529,10 @@ rte_event_dev_configure(uint8_t dev_id,\n \t}\n \n \tdev->data->event_dev_cap = info.event_dev_cap;\n+\n+\tTAILQ_INIT(&(dev->enq_cbs));\n+\tTAILQ_INIT(&(dev->deq_cbs));\n+\n \treturn diag;\n }\n \n@@ -1278,6 +1287,358 @@ rte_event_dev_close(uint8_t dev_id)\n \treturn (*dev->dev_ops->dev_close)(dev);\n }\n \n+int __rte_experimental\n+rte_event_preenq_callback_register(uint8_t eventdev_id,\n+\t\t__rte_unused uint8_t port,\n+\t\trte_eventdev_cb_fn cb_fn, void *cb_arg)\n+{\n+#ifndef RTE_EVENTDEV_ENQDEQ_CALLBACKS\n+\trte_errno = ENOTSUP;\n+\treturn -ENOTSUP;\n+#endif\n+\n+\tstruct rte_eventdev *dev;\n+\trte_spinlock_t *lock = &rte_eventdev_preenq_cb_lock;\n+\tstruct rte_eventdev_callback *user_cb = NULL;\n+\n+\tif (!cb_fn)\n+\t\treturn -EINVAL;\n+\n+\tdev = &rte_eventdevs[eventdev_id];\n+\tRTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_stop, -EINVAL);\n+\n+\trte_spinlock_lock(lock);\n+\n+\tTAILQ_FOREACH(user_cb, &(dev->enq_cbs), next)\n+\t{\n+\t\tif (user_cb->cb_fn == cb_fn &&\n+\t\tuser_cb->cb_arg == cb_arg)\n+\t\t\tbreak;\n+\t}\n+\n+\t/* create a new callback. */\n+\tif (user_cb == NULL) {\n+\t\tuser_cb = rte_zmalloc(\"EVENT_USER_CALLBACK\",\n+\t\t\t\tsizeof(struct rte_eventdev_callback), 0);\n+\t\tif (user_cb != NULL) {\n+\t\t\tuser_cb->cb_fn = cb_fn;\n+\t\t\tuser_cb->cb_arg = cb_arg;\n+\t\t\tTAILQ_INSERT_TAIL(&(dev->enq_cbs), user_cb, next);\n+\t\t}\n+\t}\n+\n+\trte_spinlock_unlock(lock);\n+\n+\treturn (user_cb == NULL) ? -ENOMEM : 0;\n+}\n+\n+int __rte_experimental\n+rte_event_pstdeq_callback_register(uint8_t eventdev_id,\n+\t\t__rte_unused uint8_t port,\n+\t\trte_eventdev_cb_fn cb_fn, void *cb_arg)\n+{\n+#ifndef RTE_EVENTDEV_ENQDEQ_CALLBACKS\n+\trte_errno = ENOTSUP;\n+\treturn -ENOTSUP;\n+#endif\n+\n+\tstruct rte_eventdev *dev;\n+\tstatic rte_spinlock_t *lock = &rte_eventdev_pstdeq_cb_lock;\n+\tstruct rte_eventdev_callback *user_cb = NULL;\n+\n+\tif (!cb_fn)\n+\t\treturn -EINVAL;\n+\n+\tdev = &rte_eventdevs[eventdev_id];\n+\tRTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_stop, -EINVAL);\n+\n+\trte_spinlock_lock(lock);\n+\n+\tTAILQ_FOREACH(user_cb, &(dev->deq_cbs), next)\n+\t{\n+\t\tif (user_cb->cb_fn == cb_fn &&\n+\t\t\t\tuser_cb->cb_arg == cb_arg)\n+\t\t\tbreak;\n+\t}\n+\n+\t/* create a new callback. */\n+\tif (user_cb == NULL) {\n+\t\tuser_cb = rte_zmalloc(\"EVENT_USER_CALLBACK\",\n+\t\t\t\tsizeof(struct rte_eventdev_callback), 0);\n+\t\tif (user_cb != NULL) {\n+\t\t\tuser_cb->cb_fn = cb_fn;\n+\t\t\tuser_cb->cb_arg = cb_arg;\n+\t\t\tTAILQ_INSERT_TAIL(&(dev->deq_cbs), user_cb, next);\n+\t\t}\n+\t}\n+\n+\trte_spinlock_unlock(lock);\n+\n+\treturn (user_cb == NULL) ? -ENOMEM : 0;\n+}\n+\n+int __rte_experimental\n+rte_event_remove_preenq_callback(uint8_t eventdev_id,\n+\t\t__rte_unused uint8_t port,\n+\t\tconst struct rte_eventdev_callback *user_cb)\n+{\n+#ifndef RTE_EVENTDEV_ENQDEQ_CALLBACKS\n+\trte_errno = ENOTSUP;\n+\treturn -ENOTSUP;\n+#endif\n+\n+\tint ret = 0;\n+\tstruct rte_eventdev *dev;\n+\tstatic rte_spinlock_t *lock = &rte_eventdev_preenq_cb_lock;\n+\tstruct rte_eventdev_callback *cb, *next_cb;\n+\n+\tif (!user_cb)\n+\t\treturn -EINVAL;\n+\n+\tdev = &rte_eventdevs[eventdev_id];\n+\tRTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_stop, -EINVAL);\n+\n+\trte_spinlock_lock(lock);\n+\n+\tret = -EINVAL;\n+\tfor (cb = TAILQ_FIRST(&dev->enq_cbs); cb != NULL; cb = next_cb) {\n+\t\tnext_cb = TAILQ_NEXT(cb, next);\n+\n+\t\tif (cb == user_cb) {\n+\t\t\tnext_cb = TAILQ_NEXT(cb, next);\n+\t\t\tret = 0;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\trte_spinlock_unlock(lock);\n+\n+\treturn ret;\n+}\n+\n+int __rte_experimental\n+rte_event_remove_pstdeq_callback(uint8_t eventdev_id,\n+\t\t__rte_unused uint8_t port,\n+\t\tconst struct rte_eventdev_callback *user_cb)\n+{\n+#ifndef RTE_EVENTDEV_ENQDEQ_CALLBACKS\n+\trte_errno = ENOTSUP;\n+\treturn -ENOTSUP;\n+#endif\n+\n+\tint ret = 0;\n+\tstruct rte_eventdev *dev;\n+\tstatic rte_spinlock_t *lock = &rte_eventdev_pstdeq_cb_lock;\n+\tstruct rte_eventdev_callback *cb, *next_cb;\n+\n+\tif (!user_cb)\n+\t\treturn -EINVAL;\n+\n+\tdev = &rte_eventdevs[eventdev_id];\n+\tRTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_stop, -EINVAL);\n+\n+\trte_spinlock_lock(lock);\n+\n+\tret = -EINVAL;\n+\tfor (cb = TAILQ_FIRST(&dev->deq_cbs); cb != NULL; cb = next_cb) {\n+\t\tnext_cb = TAILQ_NEXT(cb, next);\n+\n+\t\tif (cb == user_cb) {\n+\t\t\tnext_cb = TAILQ_NEXT(cb, next);\n+\t\t\tret = 0;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\trte_spinlock_unlock(lock);\n+\n+\treturn ret;\n+}\n+\n+struct rte_eventdev_callback * __rte_experimental\n+rte_event_add_preenq_callback(uint8_t eventdev_id,\n+\t\t__rte_unused uint8_t port,\n+\t\trte_eventdev_cb_fn cb_fn, void *cb_arg)\n+{\n+#ifndef RTE_EVENTDEV_ENQDEQ_CALLBACKS\n+\trte_errno = ENOTSUP;\n+\treturn NULL;\n+#endif\n+\n+\tstruct rte_eventdev *dev;\n+\trte_spinlock_t *lock = &rte_eventdev_preenq_cb_lock;\n+\tstruct rte_eventdev_callback *user_cb = NULL;\n+\n+\tdev = &rte_eventdevs[eventdev_id];\n+\n+\tif ((*dev->dev_ops->dev_stop == NULL) || (!cb_fn)) {\n+\t\trte_errno = EINVAL;\n+\t\treturn NULL;\n+\t}\n+\n+\trte_spinlock_lock(lock);\n+\n+\tTAILQ_FOREACH(user_cb, &(dev->enq_cbs), next)\n+\t{\n+\t\tif (user_cb->cb_fn == cb_fn &&\n+\t\t\t\tuser_cb->cb_arg == cb_arg)\n+\t\t\tbreak;\n+\t}\n+\n+\t/* create a new callback. */\n+\tif (user_cb == NULL) {\n+\t\tuser_cb = rte_zmalloc(\"EVENT_USER_CALLBACK\",\n+\t\t\t\tsizeof(struct rte_eventdev_callback), 0);\n+\t\tif (user_cb != NULL) {\n+\t\t\tuser_cb->cb_fn = cb_fn;\n+\t\t\tuser_cb->cb_arg = cb_arg;\n+\t\t\tTAILQ_INSERT_TAIL(&(dev->enq_cbs), user_cb, next);\n+\t\t}\n+\t}\n+\n+\trte_spinlock_unlock(lock);\n+\tif (user_cb == NULL) {\n+\t\trte_errno = ENOMEM;\n+\t\treturn NULL;\n+\t}\n+\n+\treturn user_cb;\n+}\n+\n+struct rte_eventdev_callback * __rte_experimental\n+rte_event_add_pstdeq_callback(uint8_t eventdev_id,\n+\t\t__rte_unused uint8_t port,\n+\t\trte_eventdev_cb_fn cb_fn, void *cb_arg)\n+{\n+#ifndef RTE_EVENTDEV_ENQDEQ_CALLBACKS\n+\trte_errno = ENOTSUP;\n+\treturn NULL;\n+#endif\n+\n+\tstruct rte_eventdev *dev;\n+\trte_spinlock_t *lock = &rte_eventdev_pstdeq_cb_lock;\n+\tstruct rte_eventdev_callback *user_cb = NULL;\n+\n+\tdev = &rte_eventdevs[eventdev_id];\n+\n+\tif ((*dev->dev_ops->dev_stop == NULL) || (!cb_fn)) {\n+\t\trte_errno = EINVAL;\n+\t\treturn NULL;\n+\t}\n+\n+\trte_spinlock_lock(lock);\n+\n+\tTAILQ_FOREACH(user_cb, &(dev->enq_cbs), next)\n+\t{\n+\t\tif (user_cb->cb_fn == cb_fn &&\n+\t\t\t\tuser_cb->cb_arg == cb_arg)\n+\t\t\tbreak;\n+\t}\n+\n+\t/* create a new callback. */\n+\tif (user_cb == NULL) {\n+\t\tuser_cb = rte_zmalloc(\"EVENT_USER_CALLBACK\",\n+\t\t\t\tsizeof(struct rte_eventdev_callback), 0);\n+\t\tif (user_cb != NULL) {\n+\t\t\tuser_cb->cb_fn = cb_fn;\n+\t\t\tuser_cb->cb_arg = cb_arg;\n+\t\t\tTAILQ_INSERT_TAIL(&(dev->enq_cbs), user_cb, next);\n+\t\t}\n+\t}\n+\n+\trte_spinlock_unlock(lock);\n+\tif (user_cb == NULL) {\n+\t\trte_errno = ENOMEM;\n+\t\treturn NULL;\n+\t}\n+\n+\treturn user_cb;\n+}\n+\n+int __rte_experimental\n+rte_event_preenq_callback_unregister(uint8_t eventdev_id,\n+\t\t__rte_unused uint8_t port,\n+\t\trte_eventdev_cb_fn cb_fn, void *cb_arg)\n+{\n+#ifndef RTE_EVENTDEV_ENQDEQ_CALLBACKS\n+\treturn -ENOTSUP;\n+#endif\n+\n+\tint ret = 0;\n+\tstruct rte_eventdev *dev;\n+\tstatic rte_spinlock_t *lock = &rte_eventdev_preenq_cb_lock;\n+\tstruct rte_eventdev_callback *cb, *next;\n+\n+\tif (!cb_fn)\n+\t\treturn -EINVAL;\n+\n+\tdev = &rte_eventdevs[eventdev_id];\n+\tRTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_stop, -EINVAL);\n+\n+\trte_spinlock_lock(lock);\n+\n+\tret = -EINVAL;\n+\tfor (cb = TAILQ_FIRST(&dev->enq_cbs); cb != NULL; cb = next) {\n+\t\tnext = TAILQ_NEXT(cb, next);\n+\n+\t\tif (cb->cb_fn != cb_fn || cb->cb_arg != cb_arg)\n+\t\t\tcontinue;\n+\n+\t\tif (cb->active == 0) {\n+\t\t\tTAILQ_REMOVE(&(dev->enq_cbs), cb, next);\n+\t\t\trte_free(cb);\n+\t\t\tret = 0;\n+\t\t} else\n+\t\t\tret = -EAGAIN;\n+\t}\n+\n+\trte_spinlock_unlock(lock);\n+\n+\treturn ret;\n+}\n+\n+int __rte_experimental\n+rte_event_pstdeq_callback_unregister(uint8_t eventdev_id,\n+\t\t__rte_unused uint8_t port,\n+\t\trte_eventdev_cb_fn cb_fn, void *cb_arg)\n+{\n+#ifndef RTE_EVENTDEV_ENQDEQ_CALLBACKS\n+\treturn -ENOTSUP;\n+#endif\n+\n+\tint ret = 0;\n+\tstruct rte_eventdev *dev;\n+\tstatic rte_spinlock_t *lock = &rte_eventdev_pstdeq_cb_lock;\n+\tstruct rte_eventdev_callback *cb, *next;\n+\n+\tif (!cb_fn)\n+\t\treturn -EINVAL;\n+\n+\tdev = &rte_eventdevs[eventdev_id];\n+\tRTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_stop, -EINVAL);\n+\n+\trte_spinlock_lock(lock);\n+\n+\tret = -EINVAL;\n+\tfor (cb = TAILQ_FIRST(&dev->deq_cbs); cb != NULL; cb = next) {\n+\t\tnext = TAILQ_NEXT(cb, next);\n+\n+\t\tif (cb->cb_fn != cb_fn || cb->cb_arg != cb_arg)\n+\t\t\tcontinue;\n+\n+\t\tif (cb->active == 0) {\n+\t\t\tTAILQ_REMOVE(&(dev->deq_cbs), cb, next);\n+\t\t\trte_free(cb);\n+\t\t\tret = 0;\n+\t\t} else\n+\t\t\tret = -EAGAIN;\n+\t}\n+\n+\trte_spinlock_unlock(lock);\n+\n+\treturn ret;\n+}\n+\n static inline int\n rte_eventdev_data_alloc(uint8_t dev_id, struct rte_eventdev_data **data,\n \t\tint socket_id)\ndiff --git a/lib/librte_eventdev/rte_eventdev.h b/lib/librte_eventdev/rte_eventdev.h\nindex 517cd8083..30f52e6d5 100644\n--- a/lib/librte_eventdev/rte_eventdev.h\n+++ b/lib/librte_eventdev/rte_eventdev.h\n@@ -215,9 +215,13 @@ extern \"C\" {\n #include <rte_config.h>\n #include <rte_memory.h>\n #include <rte_errno.h>\n+#include <rte_spinlock.h>\n+\n+#include <sys/queue.h>\n \n struct rte_mbuf; /* we just use mbuf pointers; no need to include rte_mbuf.h */\n struct rte_event;\n+struct rte_eventdev_callback;\n \n /* Event device capability bitmap flags */\n #define RTE_EVENT_DEV_CAP_QUEUE_QOS           (1ULL << 0)\n@@ -307,6 +311,19 @@ struct rte_event;\n  * @see rte_event_port_link()\n  */\n \n+TAILQ_HEAD(rte_eventdev_enq_cb_list, rte_eventdev_callback);\n+TAILQ_HEAD(rte_eventdev_deq_cb_list, rte_eventdev_callback);\n+\n+typedef uint16_t (*rte_eventdev_cb_fn)(uint8_t dev_id, uint8_t port_id,\n+\t\tstruct rte_event *ev, uint16_t nb_events, void *cb_arg);\n+\n+struct rte_eventdev_callback {\n+\tTAILQ_ENTRY(rte_eventdev_callback) next; /* Callbacks list */\n+\trte_eventdev_cb_fn cb_fn; /* Callback address */\n+\tvoid *cb_arg; /* Parameter for callback */\n+\tuint32_t active; /* Callback is executing */\n+};\n+\n /**\n  * Get the total number of event devices that have been successfully\n  * initialised.\n@@ -1302,6 +1319,9 @@ struct rte_eventdev {\n \tstruct rte_device *dev;\n \t/**< Device info. supplied by probing */\n \n+\tstruct rte_eventdev_enq_cb_list enq_cbs;\n+\tstruct rte_eventdev_deq_cb_list deq_cbs;\n+\n \tRTE_STD_C11\n \tuint8_t attached : 1;\n \t/**< Flag indicating the device is attached */\n@@ -1310,9 +1330,217 @@ struct rte_eventdev {\n extern struct rte_eventdev *rte_eventdevs;\n /** @internal The pool of rte_eventdev structures. */\n \n+/**\n+ * Register a callback function for enqueue on device-port Event dev.\n+ *\n+ * @param dev_id\n+ *  Event device id.\n+ * @param port\n+ *  Event port.\n+ * @param cb_fn\n+ *  User supplied callback function to be called.\n+ * @param cb_arg\n+ *  Pointer to the parameters for the registered callback.\n+ *\n+ * @return\n+ *  - On success, zero.\n+ *  - On failure, a negative value.\n+ */\n+int __rte_experimental\n+rte_event_preenq_callback_register(uint8_t dev_id, uint8_t port_id,\n+\t\trte_eventdev_cb_fn cb_fn, void *cb_arg);\n+\n+/**\n+ * Register a callback function for dequeue on device-port Event dev.\n+ *\n+ * @param dev_id\n+ *  Event device id.\n+ * @param port\n+ *  Event port.\n+ * @param cb_fn\n+ *  User supplied callback function to be called.\n+ * @param cb_arg\n+ *  Pointer to the parameters for the registered callback.\n+ *\n+ * @return\n+ *  - On success, zero.\n+ *  - On failure, a negative value.\n+ */\n+int __rte_experimental\n+rte_event_pstdeq_callback_register(uint8_t dev_id, uint8_t port_id,\n+\t\trte_eventdev_cb_fn cb_fn, void *cb_arg);\n+\n+/**\n+ * Unregister a callback function for enqueue on device-port Event dev.\n+ *\n+ * @param dev_id\n+ *  Event device id.\n+ * @param port\n+ *  Event port.\n+ * @param cb_fn\n+ *  User supplied callback function to be called.\n+ * @param cb_arg\n+ *  Pointer to the parameters for the registered callback. -1 means to\n+ *  remove all for the same callback address and same event.\n+ *\n+ * @return\n+ *  - On success, zero.\n+ *  - On failure, a negative value.\n+ */\n+int __rte_experimental\n+rte_event_preenq_callback_unregister(uint8_t dev_id, uint8_t port_id,\n+\t\trte_eventdev_cb_fn cb_fn, void *cb_arg);\n+\n+/**\n+ * Unregister a callback function for dequeue on device-port Event dev.\n+ *\n+ * @param dev_id\n+ *  Event device id.\n+ * @param port\n+ *  Event port.\n+ * @param cb_fn\n+ *  User supplied callback function to be called.\n+ * @param cb_arg\n+ *  Pointer to the parameters for the registered callback. -1 means to\n+ *  remove all for the same callback address and same event.\n+ *\n+ * @return\n+ *  - On success, zero.\n+ *  - On failure, a negative value.\n+ */\n+int __rte_experimental\n+rte_event_pstdeq_callback_unregister(uint8_t dev_id, uint8_t port_id,\n+\t\trte_eventdev_cb_fn cb_fn, void *cb_arg);\n+\n+/**\n+ * Add a callback to be called on event enqueue on a given device & port.\n+ *\n+ * This API configures a function to be called for each burst of\n+ * events enqueued on a given event device-port. The return value is a pointer\n+ * that can be used to later remove the callback using\n+ * rte_eventdev_remove_preenq_callback().\n+ *\n+ * Multiple functions are called in the order that they are added.\n+ *\n+ * @param dev_id\n+ *   The device identifier of the Event device.\n+ * @param port_id\n+ *   The port on the Event device on which the callback is to be added.\n+ * @param fn\n+ *   The callback function\n+ * @param user_param\n+ *   A generic pointer parameter which will be passed to each invocation of the\n+ *   callback function on this port and queue.\n+ *\n+ * @return\n+ *   NULL on error.\n+ *   On success, a pointer value which can later be used to remove the callback.\n+ */\n+struct rte_eventdev_callback * __rte_experimental\n+rte_event_add_preenq_callback(uint8_t dev_id,\n+\t\t__rte_unused uint8_t port_id, rte_eventdev_cb_fn cb_fn,\n+\t\tvoid *cb_arg);\n+\n+/**\n+ * Add a callback to be called on event dequeue on a given device & port.\n+ *\n+ * This API configures a function to be called for each burst of\n+ * events dequeued on a given event device-port. The return value is a pointer\n+ * that can be used to later remove the callback using\n+ * rte_eventdev_remove_pstdeq_callback().\n+ *\n+ * Multiple functions are called in the order that they are added.\n+ *\n+ * @param dev_id\n+ *   The device identifier of the Event device.\n+ * @param port_id\n+ *   The port on the Event device on which the callback is to be added.\n+ * @param fn\n+ *   The callback function\n+ * @param user_param\n+ *   A generic pointer parameter which will be passed to each invocation of the\n+ *   callback function on this port and queue.\n+ *\n+ * @return\n+ *   NULL on error.\n+ *   On success, a pointer value which can later be used to remove the callback.\n+ */\n+struct rte_eventdev_callback * __rte_experimental\n+rte_event_add_pstdeq_callback(uint8_t dev_id,\n+\t\t__rte_unused uint8_t port_id, rte_eventdev_cb_fn cb_fn,\n+\t\tvoid *cb_arg);\n+\n+/**\n+ * Remove an event callback from a given dev and port.\n+ *\n+ * This function is used to remove callbacks that were added to a event dev-port\n+ * using rte_event_add_preenq_callback().\n+ *\n+ * Note: the callback is removed from the callback list but it isn't freed\n+ * since the it may still be in use. The memory for the callback can be\n+ * subsequently freed back by the application by calling rte_free():\n+ *\n+ * - Immediately - if the eventdev is stopped, or the user knows that no\n+ *   callbacks are in flight e.g. if called from the thread doing enqueue\n+ *   on that eventdev.\n+ *\n+ * - After a short delay - where the delay is sufficient to allow any\n+ *   in-flight callbacks to complete.\n+ *\n+ * @param dev_id\n+ *   The device identifier of the Event device.\n+ * @param port_id\n+ *   The port on the Event device from which the callback is to be removed.\n+ * @param user_cb\n+ *   User supplied callback created via rte_event_add_preenq_callback().\n+ *\n+ * @return\n+ *   - 0: Success. Callback was removed.\n+ *   - -ENOTSUP: Callback support is not available.\n+ *   - -EINVAL:  The dev_id or the port_id is out of range, or the callback\n+ *               is NULL or not found for the dev|port.\n+ */\n+int __rte_experimental\n+rte_event_remove_preenq_callback(uint8_t dev_id, uint8_t port_id,\n+\t\tconst struct rte_eventdev_callback *user_cb);\n+\n+/**\n+ * Remove an event callback from a given dev and port.\n+ *\n+ * This function is used to remove callbacks that were added to a event dev-port\n+ * using rte_event_add_pstdeq_callback().\n+ *\n+ * Note: the callback is removed from the callback list but it isn't freed\n+ * since the it may still be in use. The memory for the callback can be\n+ * subsequently freed back by the application by calling rte_free():\n+ *\n+ * - Immediately - if the eventdev is stopped, or the user knows that no\n+ *   callbacks are in flight e.g. if called from the thread doing dequeue\n+ *   on that eventdev.\n+ *\n+ * - After a short delay - where the delay is sufficient to allow any\n+ *   in-flight callbacks to complete.\n+ *\n+ * @param dev_id\n+ *   The device identifier of the Event device.\n+ * @param port_id\n+ *   The port on the Event device from which the callback is to be removed.\n+ * @param user_cb\n+ *   User supplied callback created via rte_event_add_pstdeq_callback().\n+ *\n+ * @return\n+ *   - 0: Success. Callback was removed.\n+ *   - -ENOTSUP: Callback support is not available.\n+ *   - -EINVAL:  The dev_id or the port_id is out of range, or the callback\n+ *               is NULL or not found for the dev|port.\n+ */\n+int __rte_experimental\n+rte_event_remove_pstdeq_callback(uint8_t dev_id, uint8_t port_id,\n+\t\tconst struct rte_eventdev_callback *user_cb);\n+\n static __rte_always_inline uint16_t\n __rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,\n-\t\t\tconst struct rte_event ev[], uint16_t nb_events,\n+\t\t\tstruct rte_event ev[], uint16_t nb_events,\n \t\t\tconst event_enqueue_burst_t fn)\n {\n \tconst struct rte_eventdev *dev = &rte_eventdevs[dev_id];\n@@ -1328,6 +1556,22 @@ __rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,\n \t\treturn 0;\n \t}\n #endif\n+\n+#ifdef RTE_EVENTDEV_ENQDEQ_CALLBACKS\n+\tif (likely(rte_eventdevs[dev_id].attached)) {\n+\t\tstruct rte_eventdev_callback *cb = NULL;\n+\t\tTAILQ_FOREACH(cb, &(dev->enq_cbs), next)\n+\t\t{\n+\t\t\tif (cb->cb_fn == NULL)\n+\t\t\t\tcontinue;\n+\n+\t\t\tcb->active = 1;\n+\t\t\tnb_events = cb->cb_fn(dev_id, port_id, ev, nb_events, cb->cb_arg);\n+\t\t\tcb->active = 0;\n+\t\t}\n+\t}\n+#endif\n+\n \t/*\n \t * Allow zero cost non burst mode routine invocation if application\n \t * requests nb_events as const one\n@@ -1383,7 +1627,7 @@ __rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,\n  */\n static inline uint16_t\n rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,\n-\t\t\tconst struct rte_event ev[], uint16_t nb_events)\n+\t\t\tstruct rte_event ev[], uint16_t nb_events)\n {\n \tconst struct rte_eventdev *dev = &rte_eventdevs[dev_id];\n \n@@ -1434,7 +1678,7 @@ rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,\n  */\n static inline uint16_t\n rte_event_enqueue_new_burst(uint8_t dev_id, uint8_t port_id,\n-\t\t\tconst struct rte_event ev[], uint16_t nb_events)\n+\t\t\tstruct rte_event ev[], uint16_t nb_events)\n {\n \tconst struct rte_eventdev *dev = &rte_eventdevs[dev_id];\n \n@@ -1485,7 +1729,7 @@ rte_event_enqueue_new_burst(uint8_t dev_id, uint8_t port_id,\n  */\n static inline uint16_t\n rte_event_enqueue_forward_burst(uint8_t dev_id, uint8_t port_id,\n-\t\t\tconst struct rte_event ev[], uint16_t nb_events)\n+\t\t\tstruct rte_event ev[], uint16_t nb_events)\n {\n \tconst struct rte_eventdev *dev = &rte_eventdevs[dev_id];\n \n@@ -1606,6 +1850,21 @@ rte_event_dequeue_burst(uint8_t dev_id, uint8_t port_id, struct rte_event ev[],\n \t}\n #endif\n \n+#ifdef RTE_EVENTDEV_ENQDEQ_CALLBACKS\n+\tif (likely(rte_eventdevs[dev_id].attached)) {\n+\t\tstruct rte_eventdev_callback *cb = NULL;\n+\t\tTAILQ_FOREACH(cb, &(dev->deq_cbs), next)\n+\t\t{\n+\t\t\tif (cb->cb_fn == NULL)\n+\t\t\t\tcontinue;\n+\n+\t\t\tcb->active = 1;\n+\t\t\tnb_events = cb->cb_fn(dev_id, port_id, ev, nb_events, cb->cb_arg);\n+\t\t\tcb->active = 0;\n+\t\t}\n+\t}\n+#endif\n+\n \t/*\n \t * Allow zero cost non burst mode routine invocation if application\n \t * requests nb_events as const one\ndiff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map\nindex 95fd089f9..8d52fc839 100644\n--- a/lib/librte_eventdev/rte_eventdev_version.map\n+++ b/lib/librte_eventdev/rte_eventdev_version.map\n@@ -126,6 +126,14 @@ DPDK_19.05 {\n EXPERIMENTAL {\n \tglobal:\n \n+\trte_event_add_preenq_callback;\n+\trte_event_add_pstdeq_callback;\n \trte_event_eth_rx_adapter_cb_register;\n \trte_event_eth_rx_adapter_stats_get;\n+\trte_event_preenq_callback_register;\n+\trte_event_preenq_callback_unregister;\n+\trte_event_pstdeq_callback_register;\n+\trte_event_pstdeq_callback_unregister;\n+\trte_event_remove_preenq_callback;\n+\trte_event_remove_pstdeq_callback;\n };\n",
    "prefixes": [
        "v1",
        "1/2"
    ]
}