DPDK patches and discussions
 help / color / mirror / Atom feed
From: John McNamara <john.mcnamara@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] ethdev: call rxtx callbacks in the order they were added
Date: Fri, 10 Jul 2015 14:08:13 +0100	[thread overview]
Message-ID: <1436533693-24525-1-git-send-email-john.mcnamara@intel.com> (raw)

Change the order that user supplied RX and TX callbacks are called
to the order that they were added (fifo).

The previous calling order was the reverse of this (lifo) and was
counter intuitive for users.

Signed-off-by: John McNamara <john.mcnamara@intel.com>
---
 lib/librte_ether/rte_ethdev.c | 32 ++++++++++++++++++++++++++++----
 lib/librte_ether/rte_ethdev.h |  4 ++++
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index b79e5f7..ddf3658 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3179,8 +3179,20 @@ rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id,
 
 	cb->fn.rx = fn;
 	cb->param = user_param;
-	cb->next = rte_eth_devices[port_id].post_rx_burst_cbs[queue_id];
-	rte_eth_devices[port_id].post_rx_burst_cbs[queue_id] = cb;
+
+	/* Add the callbacks in fifo order. */
+	struct rte_eth_rxtx_callback *tail =
+		rte_eth_devices[port_id].post_rx_burst_cbs[queue_id];
+
+	if (!tail) {
+		rte_eth_devices[port_id].post_rx_burst_cbs[queue_id] = cb;
+
+	} else {
+		while (tail->next)
+			tail = tail->next;
+		tail->next = cb;
+	}
+
 	return cb;
 }
 
@@ -3208,8 +3220,20 @@ rte_eth_add_tx_callback(uint8_t port_id, uint16_t queue_id,
 
 	cb->fn.tx = fn;
 	cb->param = user_param;
-	cb->next = rte_eth_devices[port_id].pre_tx_burst_cbs[queue_id];
-	rte_eth_devices[port_id].pre_tx_burst_cbs[queue_id] = cb;
+
+	/* Add the callbacks in fifo order. */
+	struct rte_eth_rxtx_callback *tail =
+		rte_eth_devices[port_id].pre_tx_burst_cbs[queue_id];
+
+	if (!tail) {
+		rte_eth_devices[port_id].pre_tx_burst_cbs[queue_id] = cb;
+
+	} else {
+		while (tail->next)
+			tail = tail->next;
+		tail->next = cb;
+	}
+
 	return cb;
 }
 
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 79bde89..f5b3069 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -3538,6 +3538,8 @@ int rte_eth_dev_filter_ctrl(uint8_t port_id, enum rte_filter_type filter_type,
  * that can be used to later remove the callback using
  * rte_eth_remove_rx_callback().
  *
+ * Multiple functions are called in the order that they are added.
+ *
  * @param port_id
  *   The port identifier of the Ethernet device.
  * @param queue_id
@@ -3563,6 +3565,8 @@ void *rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id,
  * that can be used to later remove the callback using
  * rte_eth_remove_tx_callback().
  *
+ * Multiple functions are called in the order that they are added.
+ *
  * @param port_id
  *   The port identifier of the Ethernet device.
  * @param queue_id
-- 
1.8.1.4

Change suggested by this thread:

    http://dpdk.org/ml/archives/dev/2015-July/020749.html

             reply	other threads:[~2015-07-10 13:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-10 13:08 John McNamara [this message]
2015-07-12 21:40 ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1436533693-24525-1-git-send-email-john.mcnamara@intel.com \
    --to=john.mcnamara@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).