From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 57A05B6E4 for ; Fri, 20 Feb 2015 13:11:18 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 20 Feb 2015 04:10:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,614,1418112000"; d="scan'208";a="669066635" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 20 Feb 2015 04:10:55 -0800 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 t1KCAsbE006198 for ; Fri, 20 Feb 2015 12:10:54 GMT Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id t1KCAsRB006868 for ; Fri, 20 Feb 2015 12:10:54 GMT Received: (from smonroy@localhost) by sivswdev02.ir.intel.com with id t1KCAsX8006864 for dev@dpdk.org; Fri, 20 Feb 2015 12:10:54 GMT From: Sergio Gonzalez Monroy To: dev@dpdk.org Date: Fri, 20 Feb 2015 12:10:53 +0000 Message-Id: <1424434253-6808-4-git-send-email-sergio.gonzalez.monroy@intel.com> X-Mailer: git-send-email 1.8.5.4 In-Reply-To: <1424434253-6808-1-git-send-email-sergio.gonzalez.monroy@intel.com> References: <1424434253-6808-1-git-send-email-sergio.gonzalez.monroy@intel.com> Subject: [dpdk-dev] [PATCH 3/3] examples/packet_ordering: move creation of reorder buffer 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, 20 Feb 2015 12:11:19 -0000 There was no error checking after calling rte_reorder_create. Move the creation of the reorder buffer before launching threads in case of memory error. Signed-off-by: Sergio Gonzalez Monroy --- examples/packet_ordering/main.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/examples/packet_ordering/main.c b/examples/packet_ordering/main.c index 75e2f46..3d7daaa 100644 --- a/examples/packet_ordering/main.c +++ b/examples/packet_ordering/main.c @@ -82,6 +82,11 @@ struct worker_thread_args { struct rte_ring *ring_out; }; +struct send_thread_args { + struct rte_ring *ring_in; + struct rte_reorder_buffer *buffer; +}; + struct output_buffer { unsigned count; struct rte_mbuf *mbufs[MAX_PKTS_BURST]; @@ -455,7 +460,7 @@ flush_one_port(struct output_buffer *outbuf, uint8_t outp) * transmitting. */ static int -send_thread(struct rte_ring *ring_in) +send_thread(struct send_thread_args *args) { int ret; unsigned int i, dret; @@ -464,15 +469,13 @@ send_thread(struct rte_ring *ring_in) static struct output_buffer tx_buffers[RTE_MAX_ETHPORTS]; struct rte_mbuf *mbufs[MAX_PKTS_BURST]; struct rte_mbuf *rombufs[MAX_PKTS_BURST] = {NULL}; - struct rte_reorder_buffer *buffer; - RTE_LOG(INFO, REORDERAPP, "%s() started on lcore %u\n", __func__, - rte_lcore_id()); - buffer = rte_reorder_create("PKT_RO", rte_socket_id(), REORDER_BUFFER_SIZE); + RTE_LOG(INFO, REORDERAPP, "%s() started on lcore %u\n", __func__, rte_lcore_id()); + while (!quit_signal) { /* deque the mbufs from workers_to_tx ring */ - nb_dq_mbufs = rte_ring_dequeue_burst(ring_in, + nb_dq_mbufs = rte_ring_dequeue_burst(args->ring_in, (void *)mbufs, MAX_PKTS_BURST); if (unlikely(nb_dq_mbufs == 0)) @@ -482,7 +485,7 @@ send_thread(struct rte_ring *ring_in) for (i = 0; i < nb_dq_mbufs; i++) { /* send dequeued mbufs for reordering */ - ret = rte_reorder_insert(buffer, mbufs[i]); + ret = rte_reorder_insert(args->buffer, mbufs[i]); if (ret == -1 && rte_errno == ERANGE) { /* Too early pkts should be transmitted out directly */ @@ -510,7 +513,7 @@ send_thread(struct rte_ring *ring_in) * drain MAX_PKTS_BURST of reordered * mbufs for transmit */ - dret = rte_reorder_drain(buffer, rombufs, MAX_PKTS_BURST); + dret = rte_reorder_drain(args->buffer, rombufs, MAX_PKTS_BURST); for (i = 0; i < dret; i++) { struct output_buffer *outbuf; @@ -584,6 +587,7 @@ main(int argc, char **argv) uint8_t port_id; uint8_t nb_ports_available; struct worker_thread_args worker_args = {NULL, NULL}; + struct send_thread_args send_args = {NULL, NULL}; struct rte_ring *rx_to_workers; struct rte_ring *workers_to_tx; @@ -661,6 +665,13 @@ main(int argc, char **argv) if (workers_to_tx == NULL) rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno)); + if (!disable_reorder) { + send_args.buffer = rte_reorder_create("PKT_RO", rte_socket_id(), + REORDER_BUFFER_SIZE); + if (send_args.buffer == NULL) + rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno)); + } + last_lcore_id = get_last_lcore_id(); master_lcore_id = rte_get_master_lcore(); @@ -673,14 +684,16 @@ main(int argc, char **argv) rte_eal_remote_launch(worker_thread, (void *)&worker_args, lcore_id); - if (disable_reorder) + if (disable_reorder) { /* Start tx_thread() on the last slave core */ rte_eal_remote_launch((lcore_function_t *)tx_thread, workers_to_tx, last_lcore_id); - else + } else { + send_args.ring_in = workers_to_tx; /* Start send_thread() on the last slave core */ - rte_eal_remote_launch((lcore_function_t *)send_thread, workers_to_tx, - last_lcore_id); + rte_eal_remote_launch((lcore_function_t *)send_thread, + (void *)&send_args, last_lcore_id); + } /* Start rx_thread() on the master core */ rx_thread(rx_to_workers); -- 1.9.3