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 30F03A00BE; Mon, 25 Apr 2022 06:15:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0BF64427FA; Mon, 25 Apr 2022 06:15:12 +0200 (CEST) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140057.outbound.protection.outlook.com [40.107.14.57]) by mails.dpdk.org (Postfix) with ESMTP id 5EFFE427F2 for ; Mon, 25 Apr 2022 06:15:09 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CEkdV4CRPtckGBIe/5VqfpNrWmRYOIZzNtJ7upFkWzffs063kSuzkSeXjfhtiY9vDZ+kyEe33ZqEGrz7pa9RVH9oXE641lah061ddJoElO4Mut+zEwTktkfeL8zdfzmP+mrg/SjfFLFxba/PJp8EppFg2ahbqPoszJVai7VP7dEg12Si+sDTApY6OXIiq28X0BuvjTtlSEriClQ6PtFpAPm1WalcXFD0AMGSgoupGi9pBTenpCsYlJVAd5y2rVtWLUChLUvwVTVXM5TQ8IbJK810/Uph0r2O80NYTX2jvhwJPsjSes/tIkyC0J1gDLbBeT4xq+gIqLZ8Am8s537GEA== 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=4HVGQ9cACgFz6I2vJ5fGsM1mL4oLRNoO0wBFvh9/7GM=; b=eM7QbfqSQh2ILiv3y9cDPcpm6Ah71tf75yK59im3p6YJ2Db1Lb6jQYOaR5RS/QvoYGjsb9C2pxjZMcnbpaotx+KQMIPTmykb2AC5y3B8C/wt+CzVBftlTcEcPkFObkLO4PwoqwmUjuHRIpFkKmIt70w+vkq26c1m9e7bmXCA/krsUBU6iei8Lkcnw5S0yczViFcd1T4stJ3PaDrzv5475F4/CBkP8k2zAbfM7uucnf/UwAbj8kteEdRo5Qft9s61wbHaaEYCb84HD8nQ3dbEdDnj3zBhvK9OJHb9nH1Hd+J7VnghbGXXUPqcaN+iLa0toVLLoG4T+a5W2CZ4kRjwCQ== 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=4HVGQ9cACgFz6I2vJ5fGsM1mL4oLRNoO0wBFvh9/7GM=; b=piDI60QNsHpaTxXWqagzMCBU7vJmhWYdDnIyLE5qjdV9ZJymhjKEYQUPTqPzQf7h1ieUPErvHivCtnuAYiO9fX0MZoCm0GVKxCRRO4n30b2g76AO3IPY4gXf9LDUnpCEilwIWZ7UMN/QO5NL6x88j/3IMETNcfBfwlVVw9zSnBM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8198.eurprd04.prod.outlook.com (2603:10a6:20b:3b0::14) by PA4PR04MB9416.eurprd04.prod.outlook.com (2603:10a6:102:2ab::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.21; Mon, 25 Apr 2022 04:15:08 +0000 Received: from AS8PR04MB8198.eurprd04.prod.outlook.com ([fe80::8cf1:93b:c340:3be2]) by AS8PR04MB8198.eurprd04.prod.outlook.com ([fe80::8cf1:93b:c340:3be2%7]) with mapi id 15.20.5186.021; Mon, 25 Apr 2022 04:15:08 +0000 From: Gagandeep Singh To: gakhil@marvell.com, dev@dpdk.org Cc: Gagandeep Singh Subject: [PATCH 4/8] examples/l2fwd-crypto: add signal handler for exit Date: Mon, 25 Apr 2022 09:44:19 +0530 Message-Id: <20220425041423.2232034-4-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220425041423.2232034-1-g.singh@nxp.com> References: <20220425041423.2232034-1-g.singh@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR01CA0165.apcprd01.prod.exchangelabs.com (2603:1096:4:28::21) To AS8PR04MB8198.eurprd04.prod.outlook.com (2603:10a6:20b:3b0::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 88ba27fd-dcca-4429-1d2b-08da26722eda X-MS-TrafficTypeDiagnostic: PA4PR04MB9416: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: 8eHg4zNlRtbfyPgevePQdM/rBH3xXt8nShGdv/1qs6KO9QfIRU6bq5V/XRpVOD2+b5oesafNjygczF3RWcxxQqET/mfnxR2QCX2SGf88YGi9rRIsQZ/poDsje0o5rw1h9RA4T47iyTcXTwXv70j9UjBZcgEB6ctmABEZ3vkJ/Q9qDaE0aOyZMw2U7Zz3qN8ecagoZ7kdfVC233b4ENcR5eh1kYtV7YsY3iJvftCjz3/M28egwQIUsvLK8+aBHBETEUOxDLeX0uHAqfuMM5RzY66ViBKQ4K0Dhl26yiqf1+wE7dx8637cDJA2fHvnVTe01a68RI0j8L25bwcZJ9002T7Hc0ANyWzoDfd9a2Cep/mlFfgXG2K8/6YhZL+/rsriK4ZARPaFLTH7uws9krspB6f6wjQ5cUMA9nZfwczNxgaQPvhrHfuIUAtPQf18I2OvXud46FbroG4vxmf7ytEjIGFXfeqY/FCsFNxR1fKjTQJlADQxZr+92f3g+cYnPcZgOkwxn0Nr1yR5ZYptO3Hxkw8D5RBLITAJs6BBb3hBbIkWHhHN5D2RaOGVoWsWq5i39Vh7zL/kqj1BpYmfjJRKCku4Y0piGFbb1StuZBNMrAIIut9W1nYh//IBXo1bA61vaNxUJSJVFfueInv/Ze/8XgjEC9DgeM8GctvwNxkQ5cKn9yYXndhmbpiqdhLSbrJNjQIfWu0eHc89PI63ji9/iQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8198.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(4326008)(66556008)(6666004)(2616005)(5660300002)(66946007)(6512007)(8936002)(26005)(2906002)(38350700002)(86362001)(1076003)(38100700002)(52116002)(508600001)(6486002)(66476007)(8676002)(186003)(316002)(55236004)(6506007)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?7ruGKcj6aPWohyBul28pX6gb43gwPCwSuOTrrZlilpBMWJoeZPGapFNtyvCJ?= =?us-ascii?Q?WCcLa8jt0m70uA7SCgzTMfXKw5sZUcZfAbzHb3PHbr7aTjGMIo6oNxEeOsuu?= =?us-ascii?Q?/shJKITG4g/HBd4j8mYq0VDZ89HwP2u/SIc5FE3j4ShLlB2XZyrvT70RuukN?= =?us-ascii?Q?ycKXcJ62UJPyUYaZEqslEJvZ1eFhl9FaEpgGSpq/9N6pHtzcNOCOZYiKRa2l?= =?us-ascii?Q?i+w3Ul6jyWQfdiJ7ifeh40NZtujeLrTzg079WG7z8f7s6DAHinkGcarWQmG1?= =?us-ascii?Q?iuuCZQazz60d6X5hoNncqzju+OnBhm+aTGnjwUB5MgxtgIcRg9v++t/s+Djp?= =?us-ascii?Q?zziX9BKa3TY66UsBGsM/TVIom6rZcJu8sTeCQTDO2rzhVeDyp/6umz2PNL9p?= =?us-ascii?Q?kaFz3hkgM+GyF+THW7Yedr2uEF2a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io6aGp+ErOuoHtUexQ71qMu7zgf2IoYkCJSPQRHAyoBe6BCiaLeUTAq0Z?= =?us-ascii?Q?9m/8/V3vKYUVk5NIMoKtva/8vK2PjcSuwOmKvh6eHl1bn1g6wHOSR+I5K0tR?= =?us-ascii?Q?5Jyyz8QKqI3tuG2k8+AaTBlyNDcTJA+nECWCehYO1wgvr6wKqmsT7BXbbPE2?= =?us-ascii?Q?JaXvSlEFdsqOVSpSnCox4BFYgbD9wGOSKH4QUyiM+5+yRL8qWSYL7mJLgQDR?= =?us-ascii?Q?KEDIVhAK5P//4p4aAqBy2oRnUgYd9lnh9eSFHUGAlySyYC8UjNvTL9u1nckT?= =?us-ascii?Q?WqiMTJivP5ZEGSt0CbglnPR3/RmwRXEFEV+nuH1zRs3vRFSkgB5izkHLw4GU?= =?us-ascii?Q?Chkv1CSCq45QDXch3svpthOMwvpp4FVZcq9WEb/H25zwUIrQMR153BLYRlxc?= =?us-ascii?Q?xX89PDcSUw=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 88ba27fd-dcca-4429-1d2b-08da26722eda X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8198.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 04:15:08.4113 (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: WtXdJZzf1lklmp09D+WOViA75dyv92WsqQL2V7z058cEgKuxhyJyyQzL6mYSmAnV X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB9416 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 bbdb263143..1764fc7abc 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -258,6 +259,9 @@ struct l2fwd_crypto_statistics crypto_statistics[RTE_CRYPTO_MAX_DEVS]; /* default period is 10 seconds */ static int64_t timer_period = 10 * TIMER_MILLISECOND * 1000; +/* Global signal */ +unsigned int signal_received; + /* Print out statistics on packets dropped */ static void print_stats(void) @@ -925,6 +929,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; @@ -2762,6 +2768,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) +{ + signal_received = 1; + printf("Exiting on signal (%d)\n", signum); +} + int main(int argc, char **argv) { @@ -2774,6 +2787,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