From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 200BEC2FC for ; Fri, 10 Jul 2015 15:08:21 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 10 Jul 2015 06:08:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,446,1432623600"; d="scan'208";a="744454246" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 10 Jul 2015 06:08:20 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t6AD8J18021369; Fri, 10 Jul 2015 14:08:19 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id t6AD8JIw024561; Fri, 10 Jul 2015 14:08:19 +0100 Received: (from jmcnam2x@localhost) by sivswdev02.ir.intel.com with id t6AD8JfT024557; Fri, 10 Jul 2015 14:08:19 +0100 From: John McNamara To: dev@dpdk.org Date: Fri, 10 Jul 2015 14:08:13 +0100 Message-Id: <1436533693-24525-1-git-send-email-john.mcnamara@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] ethdev: call rxtx callbacks in the order they were added X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jul 2015 13:08:22 -0000 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 --- 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