From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3F432A04B1; Mon, 23 Nov 2020 16:44:47 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1C176C8F6; Mon, 23 Nov 2020 16:44:46 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id A70DCC8F4 for ; Mon, 23 Nov 2020 16:44:43 +0100 (CET) IronPort-SDR: Lgw7qmp9Y1mLLPH2T59Ulpf5zHX5IioeLJGO7wwsc4EwHIofTJcrr19bWL7rcv5JYg+41Cu8dy MNErur8MZ46w== X-IronPort-AV: E=McAfee;i="6000,8403,9813"; a="171004543" X-IronPort-AV: E=Sophos;i="5.78,363,1599548400"; d="scan'208";a="171004543" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2020 07:44:41 -0800 IronPort-SDR: dC0umRcGyhX4iA5JqCmd4m5EpUcH+kYAih9GRnsl9PTsOvEmDzathPpR3Z88hypMuTKxroAenT pgUTdTMCbq7A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,363,1599548400"; d="scan'208";a="534500590" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga006.fm.intel.com with ESMTP; 23 Nov 2020 07:44:41 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 23 Nov 2020 07:44:40 -0800 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 23 Nov 2020 07:44:40 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 23 Nov 2020 07:44:40 -0800 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.106) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Mon, 23 Nov 2020 07:44:39 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pp0CtThm+SnnLZIlxsBzlWmU3H79fiAtQAVbxMDYJ3TtlngDWGyq4tNlLq8STHCVGbHXBk0cm1D9Al5QijcpAUNqfJIQH31v4iiWRVE2FX7/4EUrzFop+DEmGwLDMPZL/lkBRjFpInqtGidB4kUZLBrI5p708vjRclUM3R15L8O0a/wfc2GlLbZaJJWDVQ4zSRSgVyXo7jds3o33dIn/+83RgqCDbUg+bMOdKqwGG4Hpf9XRqLP98J7U1c+wbnbnFrJuZcDncDlcBnirLfAi7PQ2UXpH2p1sa9TostgwkOcprS5ed8TfNXQle3nOje4+37Omn8GFxHC0xBwJzfIhig== 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-SenderADCheck; bh=HJxH0pyULaC6VkrJd8ZkZJjhkw23Vuxdgrbj5Hgsdv4=; b=jXpy5+ERhuSiidSt5fimx0o7WpHDyYz8vcDQl+tK8Lvf3s+iG/JyYiJcOBgsLm8Mp6ZluG2nrq49uV37y85joZEFnE3gTpmGPoPZmJdx/RGIbM9zRYPDql7ga4BRVj6MNCo/0ED4HgPtB4Ff7jxXodMV5918yWKsYz67r4DvngnrWtKYhJwSsjHE3WiLpW92q+YFVuqsREgNnLFj7Qy9aIiyNbdH+3WrHY+tZlD9dCiWoOSjwR/HuC4uC3r+SBxZDKOiyUivaWcG4ySYV7w6osunFcYkzRSO5PG052K/5++EbOkH3wAv/x0nvTiu0wHzHom4Sbwb+AUO0ZFrzVngOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HJxH0pyULaC6VkrJd8ZkZJjhkw23Vuxdgrbj5Hgsdv4=; b=rppa9wIWHEm9GN7ovu73d02hRkaHBClLjfGZdQ9nDYPh4JY4pm+ev68EZnLysq2nbZNDYFphz7YVgTaH9SWdSob7Z8Nn0UtOkMATjYYp7tkL5SnrlK81lf7iQ4ekoiupPt5q/NDjS6ZtfM97wdfk/yu9bg8ax1wFkCyr+pzttoo= Received: from BL0PR11MB3043.namprd11.prod.outlook.com (2603:10b6:208:33::19) by MN2PR11MB4272.namprd11.prod.outlook.com (2603:10b6:208:196::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.25; Mon, 23 Nov 2020 15:44:36 +0000 Received: from BL0PR11MB3043.namprd11.prod.outlook.com ([fe80::cad:4bf2:7678:568d]) by BL0PR11MB3043.namprd11.prod.outlook.com ([fe80::cad:4bf2:7678:568d%3]) with mapi id 15.20.3589.029; Mon, 23 Nov 2020 15:44:36 +0000 From: "Zhang, Roy Fan" To: Ibtisam Tariq , "Doherty, Declan" CC: "dev@dpdk.org" , Thomas Monjalon , "Trahe, Fiona" , Akhil Goyal Thread-Topic: [dpdk-dev] [PATCH 2/2] examples/l2fwd-crypto: Free resources on exit Thread-Index: AQHWYCcLDKFtCg9qI0iy1S8I18ikoanWm/9A Date: Mon, 23 Nov 2020 15:44:36 +0000 Message-ID: References: <20200722125026.2595-1-ibtisam.tariq@emumba.com> <20200722125026.2595-2-ibtisam.tariq@emumba.com> In-Reply-To: <20200722125026.2595-2-ibtisam.tariq@emumba.com> Accept-Language: zh-Hans-HK, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.5.1.3 dlp-reaction: no-action dlp-product: dlpe-windows authentication-results: emumba.com; dkim=none (message not signed) header.d=none;emumba.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [95.44.220.85] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0618e051-d057-4be1-f9ec-08d88fc6ae5a x-ms-traffictypediagnostic: MN2PR11MB4272: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1002; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: iLgvjTOnPEmj77q1koEus82Mo0BZ6BUa+gxfKpssDaTqbB23p8DMbPqeeylSoFa2UgXuIPVJOEpMpRW/9TGuVC6/0MNjHHb7ZWt5hVwqlu8TsQmDW3v+zFzwy0n6btrRQ/YOU1eNqjgd/srnZmHghFeCSiXJsLBMfMwijHvTFbcQCFVOIsML1JWhFTM+Ot4TamJFgjUb2uNbOn7JzFjjbExdQCnk3JqHY/OYtlcLFjBxbL2VhY4xKYrwwfbRaaytJcuS7CRPQV0PmFZad7vRwN/vm96Tc9axfULyfdvv0PsiIuT68NSGFbq96xA20YPmyPRqKyxUhA87c9+ZOcpFcg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL0PR11MB3043.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(366004)(136003)(346002)(376002)(66446008)(52536014)(5660300002)(71200400001)(64756008)(2906002)(76116006)(66556008)(83380400001)(66476007)(66946007)(86362001)(33656002)(110136005)(54906003)(4326008)(9686003)(186003)(316002)(26005)(6506007)(53546011)(478600001)(55016002)(7696005)(8676002)(6636002)(8936002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: =?Windows-1252?Q?GeOcGWxjBN3hgFfLu5H/+uISWy4gGGG5k235btMVgor661lt6+hShZSj?= =?Windows-1252?Q?OdzAz2TV45l7kPjGvdouQETvyMMeMLTsLJeZqw7qKrgS0Vw684sD2fhX?= =?Windows-1252?Q?i6P3RL7JWtRDy5o8kRAOSAtXXOeJ0857zPQ8lwO3/gXeht1OP95jx4r1?= =?Windows-1252?Q?h4kNUaJlMxg1RbdIJNtAh+xsELZOIvsxHYsfZ51Q7py0IlUo1M83GxAd?= =?Windows-1252?Q?LmiJqP7RFhPdAiNAtlTzaGcPG0g3Yk6crYTaw+S1GJhpxXBsend7Pn5i?= =?Windows-1252?Q?cv5NjcWULhPi9SN2twnVp7WwY6IVLiqDf6KHpS3FVLinjZDAMi0NWNTT?= =?Windows-1252?Q?Ra5yKzr65FlNX7oJ8EXXqrWBFJkXAVcPEqjPat+XyT8hvELumIr3xvCb?= =?Windows-1252?Q?NuCV2aUSrWgQTlydeNknugGb+mqRhJPI3bOCwgStuUu4a7W/fzPwcSjA?= =?Windows-1252?Q?5ZMmjB+iRNwvf2I/rwVhR6idGe0cLzCikIFcEjJwNwLKDTANJsf3NEwu?= =?Windows-1252?Q?gQFt6qHAteZ0toICkxZfFPiMF/Pmvo03P15BFxqUuvFLowiEWDuph+uk?= =?Windows-1252?Q?DCyWtwjf/cUeoqckd0Ut1ZFYUTfdgByAF7yZoMbGerAgdcXTdJu3U02Y?= =?Windows-1252?Q?vEtj/DOHzudYZyjpGZ386hLZVNBeptyQybg9MLIoz93Tp5K1FQ7vBD0W?= =?Windows-1252?Q?e/vO64b0QZt3jnQ7yWjtNfku7tLDgigxjvIuFlBOLdqMU++UQdQrh+IZ?= =?Windows-1252?Q?Cu2ZLD+/QOur9MGK3CH64G9DqtBIPWl9h9oZwI+gAii5Jc0lYZj3kFFn?= =?Windows-1252?Q?YTJMO/mQrjPUQYktRhpijiKysnXHmb3s87++8VDbRIWVAtcOpSnKTEEs?= =?Windows-1252?Q?qyFHFu6ztqfDka6gEYdLrTISKqdP0rCxZ+efIWqF5NtljSy+VRCiFaD6?= =?Windows-1252?Q?xgimVQsIlb8bZnuRfb3FxtCsg0xAQRCLWI2S3v7Vj2cNmu17LDRy7mXn?= =?Windows-1252?Q?y3wFEVs/XA+DLeIcFlnDlXg+rFe9H6PA+J+PwaI/4Ity8RXad1U=3D?= Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BL0PR11MB3043.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0618e051-d057-4be1-f9ec-08d88fc6ae5a X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Nov 2020 15:44:36.2710 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: S9gO7M/Jdd9+FUWBhsgoNuSmtzwtAUdSVQn23iBYCU0eNuOPWCIKvCTOPSOoiTr+3Ea+oevtuW+q1sdLpc5cdA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4272 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH 2/2] examples/l2fwd-crypto: Free resources on exit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Ibtisam, > -----Original Message----- > From: dev On Behalf Of Ibtisam Tariq > Sent: Wednesday, July 22, 2020 1:50 PM > To: Doherty, Declan > Cc: dev@dpdk.org; Ibtisam Tariq > Subject: [dpdk-dev] [PATCH 2/2] examples/l2fwd-crypto: Free resources on > exit >=20 > When exiting the application, resources should be cleared. >=20 > Signed-off-by: Ibtisam Tariq > --- > examples/l2fwd-crypto/main.c | 31 ++++++++++++++++++++++++++++++- > 1 file changed, 30 insertions(+), 1 deletion(-) >=20 > diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c > index 827da9b3e..5b00e2ade 100644 > --- a/examples/l2fwd-crypto/main.c > +++ b/examples/l2fwd-crypto/main.c > @@ -18,6 +18,7 @@ > #include > #include > #include > +#include >=20 > #include > #include > @@ -47,6 +48,8 @@ > #include > #endif >=20 > +static volatile bool force_quit; > + > enum cdev_type { > CDEV_TYPE_ANY, > CDEV_TYPE_HW, > @@ -838,7 +841,7 @@ l2fwd_main_loop(struct l2fwd_crypto_options > *options) > * so user can see the crypto information. > */ > prev_tsc =3D rte_rdtsc(); > - while (1) { > + while (!force_quit) { >=20 > cur_tsc =3D rte_rdtsc(); >=20 > @@ -1738,8 +1741,12 @@ check_all_ports_link_status(uint32_t port_mask) > printf("\nChecking link status"); > fflush(stdout); > for (count =3D 0; count <=3D MAX_CHECK_TIME; count++) { > + if (force_quit) > + return; > all_ports_up =3D 1; > RTE_ETH_FOREACH_DEV(portid) { > + if (force_quit) > + return; > if ((port_mask & (1 << portid)) =3D=3D 0) > continue; > memset(&link, 0, sizeof(link)); > @@ -2662,6 +2669,16 @@ reserve_key_memory(struct > l2fwd_crypto_options *options) > options->aad.phys_addr =3D rte_malloc_virt2iova(options->aad.data); > } >=20 > +static void > +signal_handler(int signum) > +{ > + if (signum =3D=3D SIGINT || signum =3D=3D SIGTERM) { > + printf("\n\nSignal %d received, preparing to exit...\n", > + signum); > + force_quit =3D true; > + } > +} > + > int > main(int argc, char **argv) > { > @@ -2681,6 +2698,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); > + > /* reserve memory for Cipher/Auth key and IV */ > reserve_key_memory(&options); >=20 > @@ -2807,6 +2828,14 @@ main(int argc, char **argv) > if (rte_eal_wait_lcore(lcore_id) < 0) > return -1; > } > + RTE_ETH_FOREACH_DEV(portid) { > + printf("Closing port %d...", portid); > + rte_eth_dev_stop(portid); > + rte_eth_dev_close(portid); > + printf(" Done\n"); > + } > + rte_eal_cleanup(); > + printf("Bye...\n"); >=20 > return 0; > } > -- > 2.17.1 Thanks for the patch and sorry for not reviewing for so long. In addition to Ethdev resources, some Cryptodev resource may need to be cle= aned too, e.g. draining all pending crypto operations from Cryptodev queue = and stop/close the device before closing the application. For SW Crypto PMD= s and QAT not doing the above steps are fine. But I am not sure about if it= is a necessary step for other vendor's PMDs. Other than that the patch looks good to me. Akhil what do you think? Regards, Fan