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 A28ABA00BE; Tue, 17 May 2022 05:39:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8FE8942B73; Tue, 17 May 2022 05:39:32 +0200 (CEST) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20060.outbound.protection.outlook.com [40.107.2.60]) by mails.dpdk.org (Postfix) with ESMTP id 149E64068B for ; Tue, 17 May 2022 05:39:29 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jnqW0wHXuNxsojDePD6wfLPvdq040d1tmM5qx2U1AXKLD+y5ra42AuGhreEmYcMLVvF6qdFPxlRUWvFKHjvhDNfeplL7HZINtCtpadAweahP6kV0Bs3ZFpF8POUz+39pZmDsF5drjr+0pRZe1bo4jeOX5f0Eo0f6IA2JKK8w8pJL1ffUT9LsNFUd628r5kXDiS0XaO1Ei70ATdXoPcwUu0YkbLEnLI9N2XSsLh5IWsO3R92+gi7FEMLzHDxcL6FO0Uyks/7cW7BPwyIKUvcDYHEpmQaaCG08XKtfla8OfOoVjEvVxbCXe/7gzPMIJfWrRwIjyuD4af2d28qLlN2w4A== 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=04YWzjjYXL52M9aWNTweEUJA1gr6FuNllDbTriIr6MA=; b=CabU2Xtb4RyHYqEDMz9a921rl+V/s39gUAuN7udY2p/lfhO0TLII4pDWfJN/AZiF8srLiEb3gVVGhigO1x/61MEbwikrdF9/pjk7p9mhUJMmEPD7spwVT6MPMygF7o7cxOoFN7SDsrJnRuPlUvy58Q9V+yfdvKYPfgR+30xZem/bq2DobP9W0Dy7PZSCuUuvVHhyQpIEM9bmtKitDxGrA+T6cX7ECV2iONsqP48D7Qiyk6zmNUksLC6R7dFJ+sbV63Yc1JJfavjl20fHHOTF4eNN6+ifAukiCRiRcjbUKJy/coSrzZwQiJUPyYOK5J0Tgo0+1RoysolFFpd9dk9pdQ== 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=04YWzjjYXL52M9aWNTweEUJA1gr6FuNllDbTriIr6MA=; b=DJvTFFS1o9y2novEbRWVXlK3MmuzqOROHGPtIQPW3Qbvte7BW28ZimEOUqFGnVDCck6WoTLZ8/griKcLTrddgkVYolCopj642ovuaeVfEL3OTpdf7VSn2/gh89Gc/6UNe45LHTZhs4nfx0tHjbD/Z2nA6vC6/KwKACz86Zkdp8Y= 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 DB8PR04MB6937.eurprd04.prod.outlook.com (2603:10a6:10:113::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.18; Tue, 17 May 2022 03:39:28 +0000 Received: from AS8PR04MB8198.eurprd04.prod.outlook.com ([fe80::8cf1:93b:c340:3be2]) by AS8PR04MB8198.eurprd04.prod.outlook.com ([fe80::8cf1:93b:c340:3be2%9]) with mapi id 15.20.5250.018; Tue, 17 May 2022 03:39:28 +0000 From: Gagandeep Singh To: gakhil@marvell.com, dev@dpdk.org Cc: Gagandeep Singh Subject: [PATCH v2 3/7] examples/l2fwd-crypto: add signal handler for exit Date: Tue, 17 May 2022 09:08:54 +0530 Message-Id: <20220517033858.40394-4-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220517033858.40394-1-g.singh@nxp.com> References: <20220425041423.2232034-1-g.singh@nxp.com> <20220517033858.40394-1-g.singh@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2PR01CA0046.apcprd01.prod.exchangelabs.com (2603:1096:4:193::18) 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: eb95703a-7c38-4e08-68d3-08da37b6d4a9 X-MS-TrafficTypeDiagnostic: DB8PR04MB6937: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: wLaiYuWYcfMt6wehkThHarW22eSrmO9+Vy4WYZFDQ/LlBVJJPh+7eeESTLJPfUAtfIuAP43I7sxg0upZ9AeYHYLlDXzfzp2C3QoCdaReyRKsrhNKcypTCwdisAIfl/hqUYoC40gv0W+BLiHoihTyiGayDnVb0vty9whVeQUDzddBvt4vBpFbf0ZrpHyoKyWJTijz5Iye0KXIX5MzqmPJQi/bzKTNHNum8lyAZOoTMaNLplY1kE1tLOkcpIwMTX9MTSRNFAgrzCBlQ2QzLJPH7tdXHQujgPMtvaYkD48t+Ivcgr8uZluyKQ68av4WhVV3l5dmVtJEYMS98kiWMYetEo1A1ImhszPbtYO9S59vTMycsFa58+YLdI8txMYaTgjnuyqjfblIi2UgmdisBGyh2Orc8OaepdVqp2OGkbg+qpASiJ85e/J5beI4imYqfKgznmVhlaSCUZzhmBfshyiih2TtNDAYeMYWW9Geal/F+SKaiVCPoFqPMONXdDjPuWl8yWpc7IsHPbedhNK/jqinZjQFvQi1NTXomPmsnM76KT66hbNQ+12iZ4g8fQltMeqhzeODLDKX6NhdX3EBNgSdU75G6RezXnOlys8MHMW9pPPKEYWtIBjv5h9KE7JZSwvwPxmWkUUpfc1K42/FcUlFLkiFAwNJWCg5bcutV9jNj5Ygf7OBB3rkfjEu9bh/5luTmIEelC9kJajRzBFvi0gC8g== 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)(8936002)(316002)(55236004)(2906002)(38100700002)(2616005)(86362001)(66556008)(38350700002)(36756003)(26005)(186003)(6512007)(4326008)(6506007)(1076003)(6486002)(6666004)(52116002)(508600001)(8676002)(66946007)(5660300002)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ry1u0c2Fwyv+9ZlSrzv7vevgKMfe2hzh9zIl30DlCCOW5Msjc/H+6L5SoYmB?= =?us-ascii?Q?1upDrqBS2cj/KLYP37atS36FPmkyuvRV6ju3R6vm1fmCxsDgVVF2u+xAMRm5?= =?us-ascii?Q?alEu4UsCUm5yiSyX0/Fz6GzIGm721jOz5EHFgef72j8hng8fjZAI7cOT2NBQ?= =?us-ascii?Q?WzEnrCH/WtwADFNZgeQF5JwtLd2EAaKokImbA7xyG2kNPvL4nSec9ywG2GZv?= =?us-ascii?Q?ErchjS8XJL14RrAAWihSG8WTwy2M2apYN5qR4pL8eLlJ9E/w6f5VmC4NmE5A?= =?us-ascii?Q?UJt8mJZkrzqCb2oyySCqXUSXr8pHr1bGzn6y09tntfKLA2l8d9R4aqivFQpf?= =?us-ascii?Q?WCK8cfPnc//CcHEFFALQ8R0+7ngMoSV8CJX2EKix6ZfT5du9tMJaweGB65+s?= =?us-ascii?Q?QpSFtgO/d+LghHkbM4Edo1oPjjtmjSGs0S7z9rXvQl0p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k8rFvSHWCpy5x9URz/Y7Vw0FwetlPUHxLlh5Y?= =?us-ascii?Q?gMIAqdVffu1F0y5BtGkHG5KHFvQcb2UpAxesb0dP45F3PXTwLanre9ocoGUO?= =?us-ascii?Q?FzO0ZpAqVG81NVGz6B9XYeF+SaywCW8rFnPLSe7GFv0yjfRXEVoBpzF7O5XW?= =?us-ascii?Q?t1/M6TCTXN3f7+aPNSX0uAhRrumopwsfQWs9GeW3iYG7jfcxP2vdAr1z9SUW?= =?us-ascii?Q?poXoezDXA1LP6y5eAEXbKyscOSUXTx8UQsWPlh1w8YcRYZPwmQtznp9tY3Ew?= =?us-ascii?Q?cTtA+YiTxDBZpvumsQ5XVZov2V3qN5x1MzrUyS514pjISiJAS7MwSJR6ZmYg?= =?us-ascii?Q?akbRnxLEvl/TG0zy3GX29OL9L3kkVYXUn/I3vibltVmcS8dPaS26QD4r6izc?= =?us-ascii?Q?oRk4RCxDiw=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb95703a-7c38-4e08-68d3-08da37b6d4a9 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8198.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2022 03:39:21.9981 (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: kztI0DfcQGcONocK7AStYHOdhYLUftsUDH7wB011cc2Xtnz/NL4BbNRjjR1Ivecq X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB6937 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..0a1fc790fc 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 */ +unsigned int 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) +{ + signal_received = 1; + printf("Exiting on signal (%d)\n", signum); +} + 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