From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6EDAAA0503; Fri, 20 May 2022 06:21:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 59D5042B76; Fri, 20 May 2022 06:21:31 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2046.outbound.protection.outlook.com [40.107.22.46]) by mails.dpdk.org (Postfix) with ESMTP id 5CA164282A for ; Fri, 20 May 2022 06:21:29 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rc73aZ35Vda+OvTHT79cdKH6rBRCtR5HdNtuCqs8z9dRdp2mvLHr6P03PLzXmKnxfABESPKCrveDPYb1QoasnuGnV1LWtkvnQ7GQJYQHFCf6buooy0WJJIP6e5PO+55oYrTJs6NsW/6WfJIUANWg/zt1DNt76qMPBejC6jNDGaK9XahG4QSEQCk+fYAfDGr7oHTHjBeRFdr6As4ROYnhY0+pLPrf8bdqu+bU1wjjeEq4NTfdjAY55FxJBRLeK4zB5tMtbQtsaLDWI0c2RHZ+ZymZNV7sztuA8xNsfj1tf0UXMITx7SRglb8IKBeCRbTHzPpWcF4JRQYwcfVe8Qgy7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sZOs13naEtoJSpBaB0/6ldSxzlGVIWFqFDb9o1zdw9k=; b=UDsG4hEq/6uAq424FJSTBmRTb2tD9oyzIfL6emxjY5MryGEs0g/IX96oHdbgRDZLbjfayiA5ESHhUDkumGEpyR4NhuQOpaRh1ong1tqliYgpZGeSDUYqYljgLantDzZOOfURD0ekrAFIYKNZM96y8nqZaDOggM8PLXFj38SGWmvqgxshWFk1KYoOkJmWCzHvkoCeLHU/X1a6QvvKRVwEYWjlOQFLnnz+B08IT+JfyqDDylWBUbqaTT2iATep5PHtRhHfIS5O6tjnkpG9jhfC4/1/VU0D+OkXSdvDx2j/WmqD+/ZxVOGYKVD0WlyQS5JIVIaQ3w2clLz+zidS9t970Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sZOs13naEtoJSpBaB0/6ldSxzlGVIWFqFDb9o1zdw9k=; b=cUFqAa6TGS5y6ZuCq9c+B1F2IbJtB8pNvhrYwoCpOOmZbDchTRajK9tJnvjkrUYHliVnOeOOdeuEQzgALxUJio3uiWokdrbLyRoAs7bBQZwCJwM8qsRPgpwGSbGSF/Q+SNy4zT8iGcr5Qics545IgpRcvvdO+J5RK7xYgf3IWcU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8194.eurprd04.prod.outlook.com (2603:10a6:20b:3e6::7) by GV1PR04MB9149.eurprd04.prod.outlook.com (2603:10a6:150:24::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.23; Fri, 20 May 2022 04:21:28 +0000 Received: from AM9PR04MB8194.eurprd04.prod.outlook.com ([fe80::c1b2:4c14:c10a:3dde]) by AM9PR04MB8194.eurprd04.prod.outlook.com ([fe80::c1b2:4c14:c10a:3dde%8]) with mapi id 15.20.5273.017; Fri, 20 May 2022 04:21:28 +0000 From: Gagandeep Singh To: gakhil@marvell.com, dev@dpdk.org Cc: Gagandeep Singh Subject: [PATCH v3 3/7] examples/l2fwd-crypto: add signal handler for exit Date: Fri, 20 May 2022 09:51:00 +0530 Message-Id: <20220520042104.3784908-4-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220520042104.3784908-1-g.singh@nxp.com> References: <20220517033858.40394-2-g.singh@nxp.com> <20220520042104.3784908-1-g.singh@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2PR04CA0005.apcprd04.prod.outlook.com (2603:1096:4:197::16) To AM9PR04MB8194.eurprd04.prod.outlook.com (2603:10a6:20b:3e6::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5a5c06c2-1f94-4854-55e7-08da3a1835b3 X-MS-TrafficTypeDiagnostic: GV1PR04MB9149:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ir40spapZ2XPVdelCm6BsOolThwefkOrRDscBP6cKb7l+P5jzAAY4g2H4xlRwcoay80mD+pmxjV9bOVqLSLpF0p3fxgyhgluXk3eu30VTKhNA6+e4EPJD27LXS20O6e65MKcUoNR44E6yM+XaxoOVNMmv2f1zG78xM1Lb2BPyuk3kzzWR6RQ+D7m+3EBf0oJMvZtAihylqSfIanDjr3ImZdjWw08rjFfPpO4wjMujWRQsiyHzEiD+fN3QArxFEQCJzmUk0bYDOEPIiwhCD/EgJYtu+X2Z0z+/1yJEZG0FsroofqopPRMyx7rsJIOVYxarLOdo6ryaV4TFMRO6e9gAwGYkmbz8OJTQ29rAW+BWHpNqAH/wWLtOZOCSCfAUYQcCNsx7DLt2rufUoXnVSoywWXN0B/MJU1JGbrEofdOFirD8x3ZsMw0dT4qenIv5FVQITFBiVxAkxrK3iHyy/PSlRc4vgDKawFaOFSQ6gopl5kbQrMdjulx8GaGEydIfNFCBmlIooMiIDg/pp7L5mPJFnUgx81y3OKRbLVrewCNNsvSvfEp8tPzk5PYBm1WKhlRMnroaikkbH0VQGL5c9c6rqh5OpT2U9DBrAeBXItm9xZh+NfXkuKzlv24cawJV2MYI/0dqAzPIZtDtrS0w3qy0JmlgU/ultPhrUUMKhBlwxLFrc7RVanYcuR91pkiUFN7LS7sp8nnfmQ5PKS3+/SIwQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR04MB8194.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(38350700002)(66946007)(2906002)(55236004)(6666004)(36756003)(508600001)(38100700002)(8676002)(66556008)(6486002)(6506007)(1076003)(8936002)(26005)(5660300002)(2616005)(316002)(66476007)(52116002)(4326008)(86362001)(186003)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?HxAFcBwTcJ2+DMzOf/bjoNIDuOr6KrpIdRI69XeYTVBSHjc7drltUzsmrAtu?= =?us-ascii?Q?PnnBOHenBpOg6W7tML76wmDsU7LIErl0STT9veodXomFdDs7aKacU94ojXRY?= =?us-ascii?Q?IHbgc3LENzI0wTK3GKT5uqWMJS9iX6yDiZJpEDk9F9sOYcOZhBGshO9M2io3?= =?us-ascii?Q?oros1W+i4x0oppe4z9FxqamtP+KubMLwXOW50T75fGvoM41RXblJjZXh/h5c?= =?us-ascii?Q?pz3VS8LRyEK4H6BRcu5rZasQe410IbJT4pcefir9/aqJU7awhCYT72u5wNcC?= =?us-ascii?Q?pcgMyMJZA34lXCJ6ntBEiAcUehjrBtaYrDLpYclomCoqwO+Lr+kcCrrui5k+?= =?us-ascii?Q?R4s0RvhMNnM9X9XMa60ZPttZclBHdLUD5f2pVST1Bn0OJapE7qKEtOWU+4MP?= =?us-ascii?Q?EptbCDigE70WN7KzIbr4ipX/IrnMjQaBWhqDsQucQ1e/eL1fUyjV96L2yqga?= =?us-ascii?Q?AHHsfJWTH+EFUYKf/moSKjngtHU2iVvbgqeYZryDdZxw8NF4Q2hlheEvmQm9?= =?us-ascii?Q?VBwCztchbPKTn7sMQA1vPG19natOZ2kOQwxe+VXt2MCtoNdRQS6j0wcuYUVo?= =?us-ascii?Q?UrcHoSp++I05Neyfe1onxYfixP/ltD0jOMxgDBmXPSF1yvRRo+fgZbhup0rZ?= =?us-ascii?Q?0nqATqCfA/duhZP5KwM2y88M9MyvHioLyoqzwe1Ryursq63zMZR7x0Ms2R4o?= =?us-ascii?Q?i/n4w+tnKgq5KJo8oNZZymxb022e1cl+miKntQqYkXAMnFin1WGLEZBtYKR4?= =?us-ascii?Q?dF8GOUv5+9PnRWMsZa/Z6k8jMCYiwOt+cndg901RxdJJSjz0ZyOU1uHPmBSK?= =?us-ascii?Q?tpu4WrFtLM0D6uKfx8OJasz9SHC8pET8XXF0RSMcgNRpD0h1F1el/mequid5?= =?us-ascii?Q?qtnAGpb5pnMblcoQaWF9FJHSafnV0/9/mlhPhGJVWv/YJNCJ9nWceB7J3Hko?= =?us-ascii?Q?nnnWSg4EZm7FNgf06Cbw30WcsQho5WqSYPCLXx1Dw6ORLgfmMl6lJfyx+FWg?= =?us-ascii?Q?bAnPo8MqVmlcgupfco92saKO/D9gcXqI0LqoIvpYv9Rxa52gSdb2K+DScjaV?= =?us-ascii?Q?fhvayKsL7ViZFkkSeypv02ZPzjGUznI97cgFVA8UJe48cQNURLeGSb1vAY8d?= =?us-ascii?Q?x8G057J50V7gW1bFQe04xRyDWOLIEzaqRtQu8+owBRPClrMlgMpjhVYPkn2b?= =?us-ascii?Q?185yDJHXqfMMbPQR16TZlU18CvdqIk4zVW8VhiWmN8JFuCA9Ml1K32ueu21w?= =?us-ascii?Q?epua74oBBF0QTEMo/gbtlKyg4KVLw3f0qNBIOsgbVmYB27yURgIA43a+a4EK?= =?us-ascii?Q?W0fMvXzEJjHzCiwfiQ6rjMzb2aURwTmuo3XSIZ/BVDEaDntcmMHTjjAKDC85?= =?us-ascii?Q?3bVTaaKFIQASY90mdvsdrQyWjJec89gE7Xyx82tUVeAid7+N3ujNdrJ+8UtY?= =?us-ascii?Q?n9WtzU8udIswGH8AufaltFykOXNjxAqtLGRItOnOmE7WOzUd0vSrxitGKLTw?= =?us-ascii?Q?5AIUtdtc03R9totn//9l2AZLrYW9r4JaL39X8IMge2JsL0FdYCASc1UAVtEH?= =?us-ascii?Q?dN3YLlMsVEJP3qJGfXSBOftyXd+oP4/wt0v7AGsN2ZvGlCUOPaaX8Spt/YsU?= =?us-ascii?Q?xgDVAjPyoTdHWUNl/ph2c874e3t8l5wHvszGJstdOsbmHziV2UCLzzU+vu+t?= =?us-ascii?Q?yHRhotLSXFrMHO96adMkE7wDAtLgG5uAoyNXLQzbjihRCRdaykeryq4vYxp1?= =?us-ascii?Q?NajebkCDiA=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5a5c06c2-1f94-4854-55e7-08da3a1835b3 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8194.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2022 04:21:28.3261 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wF5QwhcDOiaiBhyTQVFm/IR/8f1ubRd8KgZiW1UgdJZqQEdsCOQmvxJOpafjjV2D X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB9149 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 Handle SIGINT and SIGTERM signals. Signed-off-by: Gagandeep Singh --- examples/l2fwd-crypto/main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index b1e2613ccf..bf4b862379 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -256,6 +257,9 @@ struct l2fwd_crypto_statistics crypto_statistics[RTE_CRYPTO_MAX_DEVS]; #define MAX_TIMER_PERIOD 86400UL /* 1 day max */ #define DEFAULT_TIMER_PERIOD 10UL +/* Global signal */ +static volatile bool signal_received; + /* Print out statistics on packets dropped */ static void print_stats(void) @@ -922,6 +926,8 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options) nb_rx = rte_eth_rx_burst(portid, 0, pkts_burst, MAX_PKT_BURST); + if (unlikely(signal_received)) + return; port_statistics[portid].rx += nb_rx; @@ -2760,6 +2766,13 @@ reserve_key_memory(struct l2fwd_crypto_options *options) options->aad.phys_addr = rte_malloc_virt2iova(options->aad.data); } +static void +raise_signal(int signum) +{ + if (signum == SIGINT || signum == SIGTERM) + signal_received = true; +} + int main(int argc, char **argv) { @@ -2772,6 +2785,9 @@ main(int argc, char **argv) int ret, enabled_cdevcount, enabled_portcount; uint8_t enabled_cdevs[RTE_CRYPTO_MAX_DEVS] = {0}; + signal(SIGINT, raise_signal); + signal(SIGTERM, raise_signal); + /* init EAL */ ret = rte_eal_init(argc, argv); if (ret < 0) -- 2.25.1