From patchwork Tue Sep 12 06:39:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feifei Wang X-Patchwork-Id: 131347 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D581A42579; Tue, 12 Sep 2023 08:39:35 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0A90B4067C; Tue, 12 Sep 2023 08:39:22 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 50305402EE for ; Tue, 12 Sep 2023 08:39:21 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DAD6DD75; Mon, 11 Sep 2023 23:39:57 -0700 (PDT) Received: from net-x86-dell-8268.shanghai.arm.com (net-x86-dell-8268.shanghai.arm.com [10.169.210.116]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DBC0A3F67D; Mon, 11 Sep 2023 23:39:18 -0700 (PDT) From: Feifei Wang To: Cristian Dumitrescu Cc: dev@dpdk.org, nd@arm.com, Feifei Wang , Ruifeng Wang Subject: [PATCH v3 3/3] app/test-pipeline: add dev close operation Date: Tue, 12 Sep 2023 14:39:03 +0800 Message-Id: <20230912063903.1266245-4-feifei.wang2@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230912063903.1266245-1-feifei.wang2@arm.com> References: <20230626074538.3354554-1-feifei.wang2@arm.com> <20230912063903.1266245-1-feifei.wang2@arm.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org For test-pipeline, there is dev start operation, but when thread need to exit, there is no dev close operation. This is not safe, to fix this, add dev close operation. Signed-off-by: Feifei Wang Reviewed-by: Ruifeng Wang --- app/test-pipeline/main.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/test-pipeline/main.c b/app/test-pipeline/main.c index 8633933fd9..73f6d31f82 100644 --- a/app/test-pipeline/main.c +++ b/app/test-pipeline/main.c @@ -55,6 +55,7 @@ int main(int argc, char **argv) { uint32_t lcore; + uint32_t i; int ret; /* Init EAL */ @@ -85,6 +86,24 @@ main(int argc, char **argv) return -1; } + /*Close ports */ + for (i = 0; i < app.n_ports; i++) { + uint16_t port; + int ret; + + port = app.ports[i]; + printf("Closing port %d...", port); + ret = rte_eth_dev_stop(port); + if (ret != 0) + printf("rte_eth_dev_stop: err=%d, port=%u\n", + ret, port); + rte_eth_dev_close(port); + printf("Done\n"); + } + + /* Clean up the EAL */ + rte_eal_cleanup(); + return 0; }