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 C6D74A00C2; Wed, 2 Nov 2022 17:51:17 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A870D40694; Wed, 2 Nov 2022 17:51:17 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 5473340693 for ; Wed, 2 Nov 2022 17:51:16 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2A2F86a7028436; Wed, 2 Nov 2022 09:51:15 -0700 Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3kktx4ren0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Nov 2022 09:51:15 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fIP3C5llvTxO+4fYbVnYXIRnrkzvjvOOSXsm8pWMWPNm1kjwJzp6DonnZpKXFoiim3Wkl84KFztpfjUgFFCIvyam3ORbpGWyudPTHM5hesf/NXHTff176+YcYv4gV10ufdWfUV8c7Ra1TsUGf0AikejnfRxl5mIhL6uCZzKoTd9+MO233lnwAH8a4tiuD4Na/dN0yB3bb2aM2b6tEL7KQBEMsT6epplndkcpUc9eph7GlV2+z5FAh4mV0MbojxO80FrNQcqWJcPb9zulmyn8pGQW+2zQw5dU0WweMKR5hrUUdHQDLSjKUVXXArwEs4lMkls+QtzZtl+9lXQH4cTViQ== 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=4DLEL95HNOp4ZCYZcImvL6VKv0OnJpYKgeBSiJQ6hN4=; b=gyXhlbhprLFanZsGfXVzRtZWXg9vr/ncVTxvqClnHC7suQp/4lsw9GWjiyBxIaofF2N4B8SbopWWdHmUbuH6KWvWIOIrJp/ZGt+KqX2Y9Ip4uFMqBgu7R1DWds4vgFilbbjyvkWTCnkKsXOCBGap5k0BtMHeLLYYKn36DH8R6hD1Vc3k6xzSA67zBVaUNheY0AFtTvkRfhgeTcE6DObDwNDxJMsfGURpur7twMFwLa+H0la11OB6NRv3c9o/GffMl4y2br6BSWnuu1ALheQyD8Siy9N0mKOwMxLmfoMrvdYAsL75srjLXqH9Zir30R8c0BFjUCYottyhS9pAlRUAKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4DLEL95HNOp4ZCYZcImvL6VKv0OnJpYKgeBSiJQ6hN4=; b=nSIW5eL/9t5H0BNwlZ9VbCVqiAWJ+/SeMA2H0BzvVyKafvS1eOlrcLHdgJUjXFIQpI9ex2/Pwmz/sgnxfxPkA8u8aZn9ewCTV2QT0Kqmf+O1tDSNhqQin88ea6UoyHR6lhm92mcAYZjmaaSaKLRhy0pDmL2vQz4n/niH5/JRe1A= Received: from CO6PR18MB3844.namprd18.prod.outlook.com (2603:10b6:5:340::7) by DM6PR18MB3506.namprd18.prod.outlook.com (2603:10b6:5:2ab::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.16; Wed, 2 Nov 2022 16:51:12 +0000 Received: from CO6PR18MB3844.namprd18.prod.outlook.com ([fe80::333b:b4e5:5176:c964]) by CO6PR18MB3844.namprd18.prod.outlook.com ([fe80::333b:b4e5:5176:c964%4]) with mapi id 15.20.5769.022; Wed, 2 Nov 2022 16:51:12 +0000 From: Rahul Bhansali To: "dev@dpdk.org" , Kirill Rybalchenko Subject: RE: [PATCH] examples/ptpclient: add signal handler for cleanup Thread-Topic: [PATCH] examples/ptpclient: add signal handler for cleanup Thread-Index: AQHYvQXOm4bs8qMoPEqh9VOKCstcXq4sPBjw Date: Wed, 2 Nov 2022 16:51:11 +0000 Message-ID: References: <20220831064925.2580881-1-rbhansali@marvell.com> In-Reply-To: <20220831064925.2580881-1-rbhansali@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CO6PR18MB3844:EE_|DM6PR18MB3506:EE_ x-ms-office365-filtering-correlation-id: 0d5b1474-b003-4cc6-15a5-08dabcf272c0 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: GxOcQWed36SvRTtYmvryRi+G20vyK0YREKWZrATGN3PoNOhCmHqml0lh7tWeWSBTkZo4mp92EKKxVhBSsx6E6sz2760Sbro5ucNS03LyAhzbCHbPF0GejoNBdRarM59jlUYvmGM6+b5m73kflov0JTDlpVMtf+zqzKcdXwrc8OMgFk3axez4kTaZAwER1o1RZmwQj2Qzv75NEHPr5bAnKTH9kJMSmfqPAnptuYSNdHL/+d/q2eHn1Wr/VAT/5OjEHs+M6BWapL90VSMqbTl01JJuZH88cz2i16DPqYNBq7NZFk570Wer3YzTi1FB0MqA81/53Rc9Ym6C+eYrwN81r4Z6mHai25rMkoVJZInOd+n2WorJ1QgdVAVePrTMemdIJcRSPmlLhNTlqUCVrI72aLDA4wh1150vvC1mo8gOh5U4mmXkFKsTmtHE16Iaaf7D/27d5ixzOv1u/927uk4tv/Olx5Ujc5TSS5NvTaBjnLs9gu1arHcsRJKOOOqrROy4jo6Zk/pzmwjsn+lZRpZgaMaTZ/qIVScq3+FQ0SenCQV97yarxNEUaamap6ZjspCsVz3VtItB+wOOeu1+QgZYsx5QCTH7DcUSBcE58dIPcZF2btiavqRKqOMz8Lwt5q8JUf3eN1kxI6DrEAKyYAMybw2veDuFwJTFnLO11IlbyMEmV3kv8sP8YRSbBPHR9b2cYMjGmc4AbDxsCtvVE+RGOniVX0VHHq/nSj/jU44sMwZ0PTKbEVGLmTmpAsJnfV2F6xa2PkC8YJrWpMdr4cJqvg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR18MB3844.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(366004)(39860400002)(346002)(136003)(376002)(396003)(451199015)(76116006)(66946007)(110136005)(316002)(66476007)(66556008)(66446008)(26005)(7696005)(8676002)(6506007)(64756008)(53546011)(41300700001)(9686003)(478600001)(2906002)(52536014)(8936002)(186003)(71200400001)(5660300002)(86362001)(83380400001)(55016003)(33656002)(38070700005)(122000001)(38100700002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?9nvUerm4wWXJXlok8pbRurjAFv4sqScYbiFExDdkv+BVlLtRJf4olTWwQ1aQ?= =?us-ascii?Q?BaTAai02nUlInWJ5N6O/X+qw1734s6cwbY9zv0CCLqn6lPzAkzXpdBPFZy/0?= =?us-ascii?Q?hv+SAldbtcaDXjnMZNDp0ViZXn3vMYqqLaieSuLbia+zW00flEgXnQEX1H0w?= =?us-ascii?Q?iO8ZKcLCuMGkFWdMLeA/BV3kBItZbPvoYIFlAHAAyc4U7Rex0mxpu6VUvUPv?= =?us-ascii?Q?iHL3p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BxdT3pA5mey?= =?us-ascii?Q?VZ+O84pkFSbj2z5q6IQvwLyhMl1M+K3s1dcTFtKFUoOSxnWMNDPpuwKXAxYo?= =?us-ascii?Q?Liu5XOQKQmUj5j+cDWIBIwMOPFpAfnkreLuIOtARQ3Rd3QavCTSEgVjwv4Up?= =?us-ascii?Q?qstEFbY3lyDuJ9jzc8FlbkncEpnQlY43kRMvOsHjO303lwLzqkmugbZ+LcU0?= =?us-ascii?Q?rpwl+MuO2N+j9YhP3xmpdNWxBFutWeq1fOi+/KYXbJz184gzDMAGQIiTjtww?= =?us-ascii?Q?AFTtfX+k7g1DjEmknusqrvUn6cxQLIijR0yhMGu3RBo7YRmzfaIEpo3GoSPf?= =?us-ascii?Q?X3k8N4kbh7e4izn4hJucqA0ldECuKo+ya94ev2MxJZTVu0LYEOyrpFWI2Nj+?= =?us-ascii?Q?dpdqGGDLPQc3WM7V+AzMTbp+OoPlAJAk119h0ocP/5c6+I4loBDh3pXHPylP?= =?us-ascii?Q?ElKIbE/umHo8/pzqzls/noVZBsQ7HIZZFojmBLrb?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: marvell.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO6PR18MB3844.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d5b1474-b003-4cc6-15a5-08dabcf272c0 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Nov 2022 16:51:11.9021 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Zu2qwhMDkZ8sxaBnX12JDi5DFbZo1EkMZr2UpcVbfMOyBr2oBD4hz1wO1NMVc/QhOOPLDdGirLUrKufebvwkaA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR18MB3506 X-Proofpoint-GUID: ql0eS7wm5rDPm9HgRS8ZLPOh2dyE9EYu X-Proofpoint-ORIG-GUID: ql0eS7wm5rDPm9HgRS8ZLPOh2dyE9EYu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-02_13,2022-11-02_01,2022-06-22_01 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 Ping. > -----Original Message----- > From: Rahul Bhansali > Sent: Wednesday, August 31, 2022 12:19 PM > To: dev@dpdk.org; Kirill Rybalchenko > Cc: Rahul Bhansali > Subject: [PATCH] examples/ptpclient: add signal handler for cleanup >=20 > This adds the signal handler for SIGINT, SIGTERM. > Also, this will come out from infinite loop and do cleanup once it receiv= es any of > the registered signal. >=20 > Signed-off-by: Rahul Bhansali > --- > examples/ptpclient/ptpclient.c | 32 ++++++++++++++++++++++++++++++-- > 1 file changed, 30 insertions(+), 2 deletions(-) >=20 > diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclien= t.c > index 1f1c9c9c52..8b69716be1 100644 > --- a/examples/ptpclient/ptpclient.c > +++ b/examples/ptpclient/ptpclient.c > @@ -19,6 +19,9 @@ > #include > #include > #include > +#include > + > +static volatile bool force_quit; >=20 > #define RX_RING_SIZE 1024 > #define TX_RING_SIZE 1024 > @@ -609,7 +612,7 @@ parse_ptp_frames(uint16_t portid, struct rte_mbuf *m) > { > * The lcore main. This is the main thread that does the work, reading f= rom an > * input port and writing to an output port. > */ > -static __rte_noreturn void > +static void > lcore_main(void) > { > uint16_t portid; > @@ -621,7 +624,7 @@ lcore_main(void) >=20 > /* Run until the application is quit or killed. */ >=20 > - while (1) { > + while (!force_quit) { > /* Read packet from RX queues. 8< */ > for (portid =3D 0; portid < ptp_enabled_port_nb; portid++) { >=20 > @@ -734,6 +737,13 @@ ptp_parse_args(int argc, char **argv) > return 0; > } >=20 > +static void > +signal_handler(int signum) > +{ > + if (signum =3D=3D SIGINT || signum =3D=3D SIGTERM) > + force_quit =3D true; > +} > + > /* > * The main function, which does initialization and calls the per-lcore > * functions. > @@ -758,6 +768,10 @@ main(int argc, char *argv[]) > argc -=3D ret; > argv +=3D ret; >=20 > + force_quit =3D false; > + signal(SIGINT, signal_handler); > + signal(SIGTERM, signal_handler); > + > ret =3D ptp_parse_args(argc, argv); > if (ret < 0) > rte_exit(EXIT_FAILURE, "Error with PTP initialization\n"); @@ - > 802,6 +816,20 @@ main(int argc, char *argv[]) > /* Call lcore_main on the main core only. */ > lcore_main(); >=20 > + RTE_ETH_FOREACH_DEV(portid) { > + if ((ptp_enabled_port_mask & (1 << portid)) =3D=3D 0) > + continue; > + > + /* Disable timesync timestamping for the Ethernet device */ > + rte_eth_timesync_disable(portid); > + > + ret =3D rte_eth_dev_stop(portid); > + if (ret !=3D 0) > + printf("rte_eth_dev_stop: err=3D%d, port=3D%d\n", ret, > portid); > + > + rte_eth_dev_close(portid); > + } > + > /* clean up the EAL */ > rte_eal_cleanup(); >=20 > -- > 2.25.1