From patchwork Fri Jan 24 04:05:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavan Nikhilesh Bhagavatula X-Patchwork-Id: 65106 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7868BA052F; Fri, 24 Jan 2020 05:07:23 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4132F1BF30; Fri, 24 Jan 2020 05:06:30 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 3F4B61BF30 for ; Fri, 24 Jan 2020 05:06:28 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00O44ndf005203; Thu, 23 Jan 2020 20:06:27 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=20Qe1xCHoAdZtSLxfhssrhLY6Ysx2KwgVskZCKYcvAY=; b=tQVvE7jNI3xpzUekrm0VFD/7DXb4zkgk9VYuD0NqpFfhS70+17+XiiY7Aw3qrB0ZBIOG A4rHKN1QmH/+Bv6NuoZsJm8YPysFkgM+GxwSc0RzeCLlcY0U/c9Qg6OyoXHJYTyxQ6qC 7Fb4RhcMpgzff24r8STGLIBH+HEqpe8e31RrE/nnWY/3zH5nYJIE/0mpwS9KdHiKRWqW nl7Wfl2liltMWcTlaH4emgwwhfGm69YSgjyU9LhyYojeR8fl2IF6iVTzCUzpNAyJgJwu 83YFhaxfLN8XIOYCPuR6tN0nUHkx0hZO9NlWQ7kzc/opTzhUlA4egR3mSZj6R/BOVDht vg== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2xm2dteub1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 23 Jan 2020 20:06:27 -0800 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 23 Jan 2020 20:06:25 -0800 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 23 Jan 2020 20:06:25 -0800 Received: from BG-LT7430.marvell.com (bg-lt7430.marvell.com [10.28.10.90]) by maili.marvell.com (Postfix) with ESMTP id 03F7D3F7041; Thu, 23 Jan 2020 20:06:21 -0800 (PST) From: To: , , Marko Kovacevic , Ori Kam , Bruce Richardson , Radu Nicolau , "Akhil Goyal" , Tomasz Kantecki , Sunil Kumar Kori , Pavan Nikhilesh CC: Date: Fri, 24 Jan 2020 09:35:41 +0530 Message-ID: <20200124040542.2360-11-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200124040542.2360-1-pbhagavatula@marvell.com> References: <20200122182817.1667-1-pbhagavatula@marvell.com> <20200124040542.2360-1-pbhagavatula@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-01-23_13:2020-01-23, 2020-01-23 signatures=0 Subject: [dpdk-dev] [PATCH v5 10/11] examples/l3fwd: add graceful teardown for eventdevice X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Pavan Nikhilesh Add graceful teardown that addresses both event mode and poll mode. Signed-off-by: Pavan Nikhilesh --- examples/l3fwd/main.c | 50 +++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index c95b1655e..dda430d68 100644 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -1092,8 +1092,6 @@ l3fwd_poll_resource_setup(void) ret, portid); } } - - } static inline int @@ -1191,7 +1189,7 @@ main(int argc, char **argv) uint16_t queueid, portid; unsigned int lcore_id; uint8_t queue; - int ret; + int i, ret; /* init EAL */ ret = rte_eal_init(argc, argv); @@ -1280,21 +1278,41 @@ main(int argc, char **argv) ret = 0; /* launch per-lcore init on every lcore */ rte_eal_mp_remote_launch(l3fwd_lkp.main_loop, NULL, CALL_MASTER); - RTE_LCORE_FOREACH_SLAVE(lcore_id) { - if (rte_eal_wait_lcore(lcore_id) < 0) { - ret = -1; - break; + if (evt_rsrc->enabled) { + for (i = 0; i < evt_rsrc->rx_adptr.nb_rx_adptr; i++) + rte_event_eth_rx_adapter_stop( + evt_rsrc->rx_adptr.rx_adptr[i]); + for (i = 0; i < evt_rsrc->tx_adptr.nb_tx_adptr; i++) + rte_event_eth_tx_adapter_stop( + evt_rsrc->tx_adptr.tx_adptr[i]); + + RTE_ETH_FOREACH_DEV(portid) { + if ((enabled_port_mask & (1 << portid)) == 0) + continue; + rte_eth_dev_stop(portid); } - } - /* stop ports */ - RTE_ETH_FOREACH_DEV(portid) { - if ((enabled_port_mask & (1 << portid)) == 0) - continue; - printf("Closing port %d...", portid); - rte_eth_dev_stop(portid); - rte_eth_dev_close(portid); - printf(" Done\n"); + rte_eal_mp_wait_lcore(); + RTE_ETH_FOREACH_DEV(portid) { + if ((enabled_port_mask & (1 << portid)) == 0) + continue; + rte_eth_dev_close(portid); + } + + rte_event_dev_stop(evt_rsrc->event_d_id); + rte_event_dev_close(evt_rsrc->event_d_id); + + } else { + rte_eal_mp_wait_lcore(); + + RTE_ETH_FOREACH_DEV(portid) { + if ((enabled_port_mask & (1 << portid)) == 0) + continue; + printf("Closing port %d...", portid); + rte_eth_dev_stop(portid); + rte_eth_dev_close(portid); + printf(" Done\n"); + } } printf("Bye...\n");