get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 3650,
    "url": "http://patches.dpdk.org/api/patches/3650/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1424716210-25773-3-git-send-email-john.mcnamara@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": "<1424716210-25773-3-git-send-email-john.mcnamara@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1424716210-25773-3-git-send-email-john.mcnamara@intel.com",
    "date": "2015-02-23T18:30:09",
    "name": "[dpdk-dev,v6,2/3] ethdev: add optional rxtx callback support",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "8438e74e2877fe621516f4ea6bb2f78e64dca93a",
    "submitter": {
        "id": 154,
        "url": "http://patches.dpdk.org/api/people/154/?format=api",
        "name": "John McNamara",
        "email": "john.mcnamara@intel.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1424716210-25773-3-git-send-email-john.mcnamara@intel.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/3650/comments/",
    "check": "pending",
    "checks": "http://patches.dpdk.org/api/patches/3650/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 [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id D0DC6ADE2;\n\tMon, 23 Feb 2015 19:30:29 +0100 (CET)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby dpdk.org (Postfix) with ESMTP id AFF6DADD7\n\tfor <dev@dpdk.org>; Mon, 23 Feb 2015 19:30:24 +0100 (CET)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby fmsmga102.fm.intel.com with ESMTP; 23 Feb 2015 10:30:22 -0800",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby fmsmga002.fm.intel.com with ESMTP; 23 Feb 2015 10:30:19 -0800",
            "from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com\n\t[10.237.217.46])\n\tby irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id\n\tt1NIUJvL022134; Mon, 23 Feb 2015 18:30:19 GMT",
            "from sivswdev02.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev02.ir.intel.com with ESMTP id t1NIUJ6M025907;\n\tMon, 23 Feb 2015 18:30:19 GMT",
            "(from jmcnam2x@localhost)\n\tby sivswdev02.ir.intel.com with  id t1NIUJFe025903;\n\tMon, 23 Feb 2015 18:30:19 GMT"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.09,632,1418112000\"; d=\"scan'208\";a=\"682146583\"",
        "From": "John McNamara <john.mcnamara@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Mon, 23 Feb 2015 18:30:09 +0000",
        "Message-Id": "<1424716210-25773-3-git-send-email-john.mcnamara@intel.com>",
        "X-Mailer": "git-send-email 1.7.4.1",
        "In-Reply-To": "<1424716210-25773-1-git-send-email-john.mcnamara@intel.com>",
        "References": "<1424281343-2994-1-git-send-email-john.mcnamara@intel.com>\n\t<1424716210-25773-1-git-send-email-john.mcnamara@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v6 2/3] ethdev: add optional rxtx callback support",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Richardson, Bruce <bruce.richardson@intel.com>\n\nAdd optional support for inline processing of packets inside the RX\nor TX call. For an RX callback, what happens is that we get a set of\npackets from the NIC and then pass them to a callback function, if\nconfigured, to allow additional processing to be done on them, e.g.\nfilling in more mbuf fields, before passing back to the application.\nOn TX, the packets are similarly post-processed before being handed\nto the NIC for transmission.\n\nSigned-off-by: Bruce Richardson <bruce.richardson@intel.com>\nSigned-off-by: John McNamara <john.mcnamara@intel.com>\n---\n config/common_bsdapp                   |    1 +\n config/common_linuxapp                 |    1 +\n lib/librte_ether/rte_ethdev.c          |  204 +++++++++++++++++++++++++++++++-\n lib/librte_ether/rte_ethdev.h          |  203 +++++++++++++++++++++++++++++++-\n lib/librte_ether/rte_ether_version.map |    4 +\n 5 files changed, 407 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/config/common_bsdapp b/config/common_bsdapp\nindex f11ff39..6fc7074 100644\n--- a/config/common_bsdapp\n+++ b/config/common_bsdapp\n@@ -133,6 +133,7 @@ CONFIG_RTE_LIBRTE_ETHDEV_DEBUG=n\n CONFIG_RTE_MAX_ETHPORTS=32\n CONFIG_RTE_LIBRTE_IEEE1588=n\n CONFIG_RTE_ETHDEV_QUEUE_STAT_CNTRS=16\n+CONFIG_RTE_ETHDEV_RXTX_CALLBACKS=y\n \n #\n # Support NIC bypass logic\ndiff --git a/config/common_linuxapp b/config/common_linuxapp\nindex f921d8c..c0ef9d6 100644\n--- a/config/common_linuxapp\n+++ b/config/common_linuxapp\n@@ -131,6 +131,7 @@ CONFIG_RTE_LIBRTE_ETHDEV_DEBUG=n\n CONFIG_RTE_MAX_ETHPORTS=32\n CONFIG_RTE_LIBRTE_IEEE1588=n\n CONFIG_RTE_ETHDEV_QUEUE_STAT_CNTRS=16\n+CONFIG_RTE_ETHDEV_RXTX_CALLBACKS=y\n \n #\n # Support NIC bypass logic\ndiff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c\nindex 7c4e772..9bba89d 100644\n--- a/lib/librte_ether/rte_ethdev.c\n+++ b/lib/librte_ether/rte_ethdev.c\n@@ -337,6 +337,20 @@ rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)\n \t\t\tdev->data->nb_rx_queues = 0;\n \t\t\treturn -(ENOMEM);\n \t\t}\n+\n+#ifdef RTE_ETHDEV_RXTX_CALLBACKS\n+\t\tdev->post_rx_burst_cbs = rte_zmalloc(\n+\t\t\t\"ethdev->post_rx_burst_cbs\",\n+\t\t\tsizeof(*dev->post_rx_burst_cbs) * nb_queues,\n+\t\t\tRTE_CACHE_LINE_SIZE);\n+\t\tif (dev->post_rx_burst_cbs == NULL) {\n+\t\t\trte_free(dev->data->rx_queues);\n+\t\t\tdev->data->rx_queues = NULL;\n+\t\t\tdev->data->nb_rx_queues = 0;\n+\t\t\treturn -(ENOMEM);\n+\t\t}\n+#endif\n+\n \t} else { /* re-configure */\n \t\tFUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_release, -ENOTSUP);\n \n@@ -349,9 +363,25 @@ rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)\n \t\tif (rxq == NULL)\n \t\t\treturn -(ENOMEM);\n \n-\t\tif (nb_queues > old_nb_queues)\n+#ifdef RTE_ETHDEV_RXTX_CALLBACKS\n+\t\tdev->post_rx_burst_cbs = rte_realloc(\n+\t\t\tdev->post_rx_burst_cbs,\n+\t\t\tsizeof(*dev->post_rx_burst_cbs) *\n+\t\t\t\tnb_queues, RTE_CACHE_LINE_SIZE);\n+\t\tif (dev->post_rx_burst_cbs == NULL)\n+\t\t\treturn -(ENOMEM);\n+#endif\n+\n+\t\tif (nb_queues > old_nb_queues) {\n+\t\t\tuint16_t new_qs = nb_queues - old_nb_queues;\n \t\t\tmemset(rxq + old_nb_queues, 0,\n-\t\t\t\tsizeof(rxq[0]) * (nb_queues - old_nb_queues));\n+\t\t\t\tsizeof(rxq[0]) * new_qs);\n+\n+#ifdef RTE_ETHDEV_RXTX_CALLBACKS\n+\t\t\tmemset(dev->post_rx_burst_cbs + old_nb_queues, 0,\n+\t\t\t\tsizeof(dev->post_rx_burst_cbs[0]) * new_qs);\n+#endif\n+\t\t}\n \n \t\tdev->data->rx_queues = rxq;\n \n@@ -479,6 +509,20 @@ rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)\n \t\t\tdev->data->nb_tx_queues = 0;\n \t\t\treturn -(ENOMEM);\n \t\t}\n+\n+#ifdef RTE_ETHDEV_RXTX_CALLBACKS\n+\t\tdev->pre_tx_burst_cbs = rte_zmalloc(\n+\t\t\t\"ethdev->pre_tx_burst_cbs\",\n+\t\t\tsizeof(*dev->pre_tx_burst_cbs) * nb_queues,\n+\t\t\tRTE_CACHE_LINE_SIZE);\n+\t\tif (dev->pre_tx_burst_cbs == NULL) {\n+\t\t\trte_free(dev->data->tx_queues);\n+\t\t\tdev->data->tx_queues = NULL;\n+\t\t\tdev->data->nb_tx_queues = 0;\n+\t\t\treturn -(ENOMEM);\n+\t\t}\n+#endif\n+\n \t} else { /* re-configure */\n \t\tFUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_release, -ENOTSUP);\n \n@@ -491,9 +535,25 @@ rte_eth_dev_tx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)\n \t\tif (txq == NULL)\n \t\t\treturn -(ENOMEM);\n \n-\t\tif (nb_queues > old_nb_queues)\n+#ifdef RTE_ETHDEV_RXTX_CALLBACKS\n+\t\tdev->pre_tx_burst_cbs = rte_realloc(\n+\t\t\tdev->pre_tx_burst_cbs,\n+\t\t\tsizeof(*dev->pre_tx_burst_cbs) *\n+\t\t\t\tnb_queues, RTE_CACHE_LINE_SIZE);\n+\t\tif (dev->pre_tx_burst_cbs == NULL)\n+\t\t\treturn -(ENOMEM);\n+#endif\n+\n+\t\tif (nb_queues > old_nb_queues) {\n+\t\t\tuint16_t new_qs = nb_queues - old_nb_queues;\n \t\t\tmemset(txq + old_nb_queues, 0,\n-\t\t\t\tsizeof(txq[0]) * (nb_queues - old_nb_queues));\n+\t\t\t\tsizeof(txq[0]) * new_qs);\n+\n+#ifdef RTE_ETHDEV_RXTX_CALLBACKS\n+\t\t\tmemset(dev->pre_tx_burst_cbs + old_nb_queues, 0,\n+\t\t\t\tsizeof(dev->pre_tx_burst_cbs[0]) * new_qs);\n+#endif\n+\t\t}\n \n \t\tdev->data->tx_queues = txq;\n \n@@ -3258,3 +3318,139 @@ rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type,\n \tFUNC_PTR_OR_ERR_RET(*dev->dev_ops->filter_ctrl, -ENOTSUP);\n \treturn (*dev->dev_ops->filter_ctrl)(dev, filter_type, filter_op, arg);\n }\n+\n+void *\n+rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id,\n+\t\trte_rxtx_callback_fn fn, void *user_param)\n+{\n+#ifndef RTE_ETHDEV_RXTX_CALLBACKS\n+\trte_errno = ENOTSUP;\n+\treturn NULL;\n+#endif\n+\t/* check input parameters */\n+\tif (port_id >= nb_ports || fn == NULL ||\n+\t\t    queue_id >= rte_eth_devices[port_id].data->nb_rx_queues) {\n+\t\trte_errno = EINVAL;\n+\t\treturn NULL;\n+\t}\n+\n+\tstruct rte_eth_rxtx_callback *cb = rte_zmalloc(NULL, sizeof(*cb), 0);\n+\n+\tif (cb == NULL) {\n+\t\trte_errno = ENOMEM;\n+\t\treturn NULL;\n+\t}\n+\n+\tcb->fn = fn;\n+\tcb->param = user_param;\n+\tcb->next = rte_eth_devices[port_id].post_rx_burst_cbs[queue_id];\n+\trte_eth_devices[port_id].post_rx_burst_cbs[queue_id] = cb;\n+\treturn cb;\n+}\n+\n+void *\n+rte_eth_add_tx_callback(uint8_t port_id, uint16_t queue_id,\n+\t\trte_rxtx_callback_fn fn, void *user_param)\n+{\n+#ifndef RTE_ETHDEV_RXTX_CALLBACKS\n+\trte_errno = ENOTSUP;\n+\treturn NULL;\n+#endif\n+\t/* check input parameters */\n+\tif (port_id >= nb_ports || fn == NULL ||\n+\t\t    queue_id >= rte_eth_devices[port_id].data->nb_tx_queues) {\n+\t\trte_errno = EINVAL;\n+\t\treturn NULL;\n+\t}\n+\n+\tstruct rte_eth_rxtx_callback *cb = rte_zmalloc(NULL, sizeof(*cb), 0);\n+\n+\tif (cb == NULL) {\n+\t\trte_errno = ENOMEM;\n+\t\treturn NULL;\n+\t}\n+\n+\tcb->fn = fn;\n+\tcb->param = user_param;\n+\tcb->next = rte_eth_devices[port_id].pre_tx_burst_cbs[queue_id];\n+\trte_eth_devices[port_id].pre_tx_burst_cbs[queue_id] = cb;\n+\treturn cb;\n+}\n+\n+int\n+rte_eth_remove_rx_callback(uint8_t port_id, uint16_t queue_id,\n+\t\tstruct rte_eth_rxtx_callback *user_cb)\n+{\n+#ifndef RTE_ETHDEV_RXTX_CALLBACKS\n+\treturn (-ENOTSUP);\n+#endif\n+\t/* Check input parameters. */\n+\tif (port_id >= nb_ports || user_cb == NULL ||\n+\t\t    queue_id >= rte_eth_devices[port_id].data->nb_rx_queues) {\n+\t\treturn (-EINVAL);\n+\t}\n+\n+\tstruct rte_eth_dev *dev = &rte_eth_devices[port_id];\n+\tstruct rte_eth_rxtx_callback *cb = dev->post_rx_burst_cbs[queue_id];\n+\tstruct rte_eth_rxtx_callback *prev_cb;\n+\n+\t/* Reset head pointer and remove user cb if first in the list. */\n+\tif (cb == user_cb) {\n+\t\tdev->post_rx_burst_cbs[queue_id] = user_cb->next;\n+\t\treturn 0;\n+\t}\n+\n+\t/* Remove the user cb from the callback list. */\n+\tdo {\n+\t\tprev_cb = cb;\n+\t\tcb = cb->next;\n+\n+\t\tif (cb == user_cb) {\n+\t\t\tprev_cb->next = user_cb->next;\n+\t\t\treturn 0;\n+\t\t}\n+\n+\t} while (cb != NULL);\n+\n+\t/* Callback wasn't found. */\n+\treturn (-EINVAL);\n+}\n+\n+int\n+rte_eth_remove_tx_callback(uint8_t port_id, uint16_t queue_id,\n+\t\tstruct rte_eth_rxtx_callback *user_cb)\n+{\n+#ifndef RTE_ETHDEV_RXTX_CALLBACKS\n+\treturn (-ENOTSUP);\n+#endif\n+\t/* Check input parameters. */\n+\tif (port_id >= nb_ports || user_cb == NULL ||\n+\t\t    queue_id >= rte_eth_devices[port_id].data->nb_tx_queues) {\n+\t\treturn (-EINVAL);\n+\t}\n+\n+\tstruct rte_eth_dev *dev = &rte_eth_devices[port_id];\n+\tstruct rte_eth_rxtx_callback *cb = dev->pre_tx_burst_cbs[queue_id];\n+\tstruct rte_eth_rxtx_callback *prev_cb;\n+\n+\t/* Reset head pointer and remove user cb if first in the list. */\n+\tif (cb == user_cb) {\n+\t\tdev->pre_tx_burst_cbs[queue_id] = user_cb->next;\n+\t\treturn 0;\n+\t}\n+\n+\t/* Remove the user cb from the callback list. */\n+\tdo {\n+\t\tprev_cb = cb;\n+\t\tcb = cb->next;\n+\n+\t\tif (cb == user_cb) {\n+\t\t\tprev_cb->next = user_cb->next;\n+\t\t\treturn 0;\n+\t\t}\n+\n+\t} while (cb != NULL);\n+\n+\t/* Callback wasn't found. */\n+\treturn (-EINVAL);\n+}\ndiff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h\nindex 48e4ac9..d6d3a05 100644\n--- a/lib/librte_ether/rte_ethdev.h\n+++ b/lib/librte_ether/rte_ethdev.h\n@@ -1523,6 +1523,47 @@ struct eth_dev_ops {\n };\n \n /**\n+ * Function type used for callbacks for processing packets on RX and TX\n+ *\n+ * If configured for RX, it is called with a burst of packets that have just\n+ * been received on the given port and queue. On TX, it is called with a burst\n+ * of packets immediately before those packets are put onto the hardware queue\n+ * for transmission.\n+ *\n+ * @param port\n+ *   The ethernet port on which rx or tx is being performed\n+ * @param queue\n+ *   The queue on the ethernet port which is being used to receive or transmit\n+ *   the packets.\n+ * @param pkts\n+ *   The burst of packets on which processing is to be done. On RX, these\n+ *   packets have just been received. On TX, they are about to be transmitted.\n+ * @param nb_pkts\n+ *   The number of packets in the burst pointed to by \"pkts\"\n+ * @param user_param\n+ *   The arbitrary user parameter passed in by the application when the callback\n+ *   was originally configured.\n+ * @return\n+ *   The number of packets remaining in pkts are processing.\n+ *\t* On RX, this will be returned to the user as the return value from\n+ *\t  rte_eth_rx_burst.\n+ *\t* On TX, this will be the number of packets actually written to the NIC.\n+ */\n+typedef uint16_t (*rte_rxtx_callback_fn)(uint8_t port, uint16_t queue,\n+\tstruct rte_mbuf *pkts[], uint16_t nb_pkts, void *user_param);\n+\n+/**\n+ * @internal\n+ * Structure used to hold information about the callbacks to be called for a\n+ * queue on RX and TX.\n+ */\n+struct rte_eth_rxtx_callback {\n+\tstruct rte_eth_rxtx_callback *next;\n+\trte_rxtx_callback_fn fn;\n+\tvoid *param;\n+};\n+\n+/**\n  * @internal\n  * The generic data structure associated with each ethernet device.\n  *\n@@ -1539,7 +1580,20 @@ struct rte_eth_dev {\n \tconst struct eth_driver *driver;/**< Driver for this device */\n \tstruct eth_dev_ops *dev_ops;    /**< Functions exported by PMD */\n \tstruct rte_pci_device *pci_dev; /**< PCI info. supplied by probing */\n-\tstruct rte_eth_dev_cb_list link_intr_cbs; /**< User application callbacks on interrupt*/\n+\t/** User application callbacks for NIC interrupts */\n+\tstruct rte_eth_dev_cb_list link_intr_cbs;\n+\n+\t/**\n+\t * User-supplied functions called from rx_burst to post-process\n+\t * received packets before passing them to the user\n+\t */\n+\tstruct rte_eth_rxtx_callback **post_rx_burst_cbs;\n+\n+\t/**\n+\t * User-supplied functions called from tx_burst to pre-process\n+\t * received packets before passing them to the driver for transmission.\n+\t */\n+\tstruct rte_eth_rxtx_callback **pre_tx_burst_cbs;\n };\n \n struct rte_eth_dev_sriov {\n@@ -2393,7 +2447,23 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,\n \tstruct rte_eth_dev *dev;\n \n \tdev = &rte_eth_devices[port_id];\n-\treturn (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id], rx_pkts, nb_pkts);\n+\n+\tnb_pkts = (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id], rx_pkts,\n+\t\t\tnb_pkts);\n+\n+#ifdef RTE_ETHDEV_RXTX_CALLBACKS\n+\tstruct rte_eth_rxtx_callback *cb = dev->post_rx_burst_cbs[queue_id];\n+\n+\tif (unlikely(cb != NULL)) {\n+\t\tdo {\n+\t\t\tnb_pkts = cb->fn(port_id, queue_id, rx_pkts, nb_pkts,\n+\t\t\t\t\tcb->param);\n+\t\t\tcb = cb->next;\n+\t\t} while (cb != NULL);\n+\t}\n+#endif\n+\n+\treturn nb_pkts;\n }\n #endif\n \n@@ -2520,6 +2590,19 @@ rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,\n \tstruct rte_eth_dev *dev;\n \n \tdev = &rte_eth_devices[port_id];\n+\n+#ifdef RTE_ETHDEV_RXTX_CALLBACKS\n+\tstruct rte_eth_rxtx_callback *cb = dev->pre_tx_burst_cbs[queue_id];\n+\n+\tif (unlikely(cb != NULL)) {\n+\t\tdo {\n+\t\t\tnb_pkts = cb->fn(port_id, queue_id, tx_pkts, nb_pkts,\n+\t\t\t\t\tcb->param);\n+\t\t\tcb = cb->next;\n+\t\t} while (cb != NULL);\n+\t}\n+#endif\n+\n \treturn (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id], tx_pkts, nb_pkts);\n }\n #endif\n@@ -3667,6 +3750,122 @@ int rte_eth_dev_filter_supported(uint8_t port_id, enum rte_filter_type filter_ty\n int rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type,\n \t\t\tenum rte_filter_op filter_op, void *arg);\n \n+/**\n+ * Add a callback to be called on packet RX on a given port and queue.\n+ *\n+ * This API configures a function to be called for each burst of\n+ * packets received on a given NIC port queue. The return value is a pointer\n+ * that can be used to later remove the callback using\n+ * rte_eth_remove_rx_callback().\n+ *\n+ * @param port_id\n+ *   The port identifier of the Ethernet device.\n+ * @param queue_id\n+ *   The queue on the Ethernet 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+void *rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id,\n+\t\trte_rxtx_callback_fn fn, void *user_param);\n+\n+/**\n+ * Add a callback to be called on packet TX on a given port and queue.\n+ *\n+ * This API configures a function to be called for each burst of\n+ * packets sent on a given NIC port queue. The return value is a pointer\n+ * that can be used to later remove the callback using\n+ * rte_eth_remove_tx_callback().\n+ *\n+ * @param port_id\n+ *   The port identifier of the Ethernet device.\n+ * @param queue_id\n+ *   The queue on the Ethernet 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+void *rte_eth_add_tx_callback(uint8_t port_id, uint16_t queue_id,\n+\t\trte_rxtx_callback_fn fn, void *user_param);\n+\n+/**\n+ * Remove an RX packet callback from a given port and queue.\n+ *\n+ * This function is used to removed callbacks that were added to a NIC port\n+ * queue using rte_eth_add_rx_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 port is stopped, or the user knows that no\n+ *    callbacks are in flight e.g. if called from the thread doing RX/TX\n+ *    on that queue.\n+ *\n+ * - After a short delay - where the delay is sufficient to allow any\n+ *   in-flight callbacks to complete.\n+ *\n+ * @param port_id\n+ *   The port identifier of the Ethernet device.\n+ * @param queue_id\n+ *   The queue on the Ethernet device from which the callback is to be removed.\n+ * @param user_cb\n+ *   User supplied callback created via rte_eth_add_rx_callback().\n+ *\n+ * @return\n+ *   - 0: Success. Callback was removed.\n+ *   - -ENOTSUP: Callback support is not available.\n+ *   - -EINVAL:  The port_id or the queue_id is out of range, or the callback\n+ *               is NULL or not found for the port/queue.\n+ */\n+int rte_eth_remove_rx_callback(uint8_t port_id, uint16_t queue_id,\n+\t\tstruct rte_eth_rxtx_callback *user_cb);\n+\n+/**\n+ * Remove a TX packet callback from a given port and queue.\n+ *\n+ * This function is used to removed callbacks that were added to a NIC port\n+ * queue using rte_eth_add_tx_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 port is stopped, or the user knows that no\n+ *    callbacks are in flight e.g. if called from the thread doing RX/TX\n+ *    on that queue.\n+ *\n+ * - After a short delay - where the delay is sufficient to allow any\n+ *   in-flight callbacks to complete.\n+ *\n+ * @param port_id\n+ *   The port identifier of the Ethernet device.\n+ * @param queue_id\n+ *   The queue on the Ethernet device from which the callback is to be removed.\n+ * @param user_cb\n+ *   User supplied callback created via rte_eth_add_tx_callback().\n+ *\n+ * @return\n+ *   - 0: Success. Callback was removed.\n+ *   - -ENOTSUP: Callback support is not available.\n+ *   - -EINVAL:  The port_id or the queue_id is out of range, or the callback\n+ *               is NULL or not found for the port/queue.\n+ */\n+int rte_eth_remove_tx_callback(uint8_t port_id, uint16_t queue_id,\n+\t\tstruct rte_eth_rxtx_callback *user_cb);\n+\n #ifdef __cplusplus\n }\n #endif\ndiff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map\nindex 7316530..3227cda 100644\n--- a/lib/librte_ether/rte_ether_version.map\n+++ b/lib/librte_ether/rte_ether_version.map\n@@ -2,6 +2,8 @@ DPDK_2.0 {\n \tglobal:\n \n \t_rte_eth_dev_callback_process;\n+\trte_eth_add_rx_callback;\n+\trte_eth_add_tx_callback;\n \trte_eth_allmulticast_disable;\n \trte_eth_allmulticast_enable;\n \trte_eth_allmulticast_get;\n@@ -96,6 +98,8 @@ DPDK_2.0 {\n \trte_eth_promiscuous_disable;\n \trte_eth_promiscuous_enable;\n \trte_eth_promiscuous_get;\n+\trte_eth_remove_rx_callback;\n+\trte_eth_remove_tx_callback;\n \trte_eth_rx_burst;\n \trte_eth_rx_descriptor_done;\n \trte_eth_rx_queue_count;\n",
    "prefixes": [
        "dpdk-dev",
        "v6",
        "2/3"
    ]
}