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 D8167A034F; Mon, 7 Feb 2022 11:32:42 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6CBDF410F3; Mon, 7 Feb 2022 11:32:42 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id DBD5A410EA for ; Mon, 7 Feb 2022 11:32:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644229961; x=1675765961; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=tgryJ6aYmVC37bOYQ3GeldDt/xNeuWKddRrBFZRk1UQ=; b=eAvLyoJFRlngbVj9OEmwV+Xc9aHAqs/7dVJlOfu+YEGA4XN4uwMac5iC ExV06KZ0mu0P8kiJzbbRztKFTkngle5TDa5V72ZJ5is7KYL5NP2TROiTQ 7SjpaJEUsPSa9wdP2Sem4DI+jVsFDSXFP7gV2a/wDtiA8yVsh6uHEHfAD +p9+AKo87rHpLddxmjlum7EccLhogSKUozY+uz34a9FEkJWYuqeFajvhn UOJBlTs8EmA2/KYPlQ6ZBmwxt35wEvZjkI314BTCVWypbyaGd1tKuDt1Z ojNFZ0RKizR2PdRLVFK2pDB4AfVbTF7AivvUiY1yAs//c84ZS6NuDzbit g==; X-IronPort-AV: E=McAfee;i="6200,9189,10250"; a="228658659" X-IronPort-AV: E=Sophos;i="5.88,349,1635231600"; d="scan'208";a="228658659" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2022 02:32:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,349,1635231600"; d="scan'208";a="632412564" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga004.jf.intel.com with ESMTP; 07 Feb 2022 02:32:39 -0800 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Mon, 7 Feb 2022 02:32:38 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Mon, 7 Feb 2022 02:32:38 -0800 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.106) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Mon, 7 Feb 2022 02:32:38 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fBetTRL2nQ318nYD3NZe28d5IxjojhUXKgzN8ioajBgjWTQCoykJ3ZUh9P/H7aY/jvc81HEwAjX5tpc1hXQ5WJJbJuunXH/w1SmEP2H6k/i9Y43uEtaMqqeG/7jShlPRdscLbvFRR16Q1wZ/Nt0oS6wS9hxD+l1uoQK0CchHQfmCyOCNNZnhzB8/uYATn1dpFHCg0BL2rURBFxaZ9+IzzjpAMEGczGbco4C+zOXSdLrRYvLANr/+nRnrffdPVRSWDezs9QcVISwG5O7l2GVeYooCC4yRuWSe+rx+wH9rthBxhKImbsGmXOzQ+H3vnUqiPmgb2HZJONa4i6LsvQ6xSw== 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=IOZZE2ljBvU4XVi+A3yA6j2i/ckOzJ2pm//cdLq/nHM=; b=HCT8zI/bS/xV5/RjituY/NAtJHtSP8Rnk8APtjcE5QaY5bc12mBN7NtFJFI/gdzAmEAmJUxoOK2vmYmlA6u33PdmxtkkF03TfJ0DhTHWfVhKI83JLmM5UY8zkvjlI4P80oSqIbL4uYnNPWW7qbUgbjJrl+OAHZG2xUSYzLmyVWLgwrLW+w7lymiG1nnvhBr4DboHIKZ9qiawZC2piZzalLXPizL7tajlXwZ/7T7ONTN4BsqGqf4lWnZdFHRxsA/Oa6DrkAGQn0IbsJI1016JTFFaFQ1RqyTxLyhMLdSaFE456DxyWJUd5CCcH8KWnHqyC5kXxV3dSzzKnXpKdT8Z/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MW4PR11MB5911.namprd11.prod.outlook.com (2603:10b6:303:16b::16) by BN6PR11MB1921.namprd11.prod.outlook.com (2603:10b6:404:104::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Mon, 7 Feb 2022 10:32:36 +0000 Received: from MW4PR11MB5911.namprd11.prod.outlook.com ([fe80::e00c:1274:42e2:8355]) by MW4PR11MB5911.namprd11.prod.outlook.com ([fe80::e00c:1274:42e2:8355%7]) with mapi id 15.20.4951.016; Mon, 7 Feb 2022 10:32:36 +0000 From: "Kundapura, Ganapati" To: "Gujjar, Abhinandan S" , "jerinjacobk@gmail.com" , "Jayatheerthan, Jay" , "dev@dpdk.org" Subject: RE: [PATCH v3 1/2] eventdev/crypto_adapter: move crypto ops to circular buffer Thread-Topic: [PATCH v3 1/2] eventdev/crypto_adapter: move crypto ops to circular buffer Thread-Index: AQHYBtcwyOQ4anj+bkaoATfLgEMdFaxgzVQAgCc/q8A= Date: Mon, 7 Feb 2022 10:32:36 +0000 Message-ID: References: <20220104123114.1053806-1-ganapati.kundapura@intel.com> <20220111103631.3664763-1-ganapati.kundapura@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.6.200.16 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1d50a1b8-933a-49ef-a49e-08d9ea25285e x-ms-traffictypediagnostic: BN6PR11MB1921:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:378; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: cBe6+LTX62xhl/XeWYFWJGiOdKQvoL91meJVIzxT2gr3vLnx+7essArqFJv9RfSk3HwGrxZDlWjMjDbBKLcwka90Ko0V9OrW296Txv5UEhe0QSmODciPDKYlZ+TfqlCcaB0Byq9PMQOx3/Dg55ForXw4UpoFYVQfa81CLaBPW+lXEfKm9Ox6PGGADDkGMv6DeK1s5aJWK9Ug7WdO8R8XfDuwsKXFOMMtoFaj4BzKb0Stdn/V3ByPFRJw6UQUHHUdXjuk8wppHofmB/SU4c6Na+RzTDFONUTB0qC70N3Bg/Dmcw6brXRCKVAZfZc9t1tThSqVjzqM3ZZJYa1/9+cFUPC9FdVi49emtDxU5BqsHLFZ2uaqZ7+wmXEgnZ5J0f0lhXeFY51cAM0tBMIUX1uA2SwLvIB6fGmwfcQDqktuw3tutPlLFbOMZqNFnspEr7+OSjamJupWfwm6NgFPa++ouZbV2TLbrFz4j7/S8OeE6x9BA5IXSwZA4DqaFw3wYIfrgC2v7gMGlQ71xgsG83p9Cc3v065NEozU0i24Bc08AndmisePs9MWhLO7KXPuQtbf7IpYPMigrUTOfPvyA0bkt3q1kkJxWLGWTJ5Z3+Ofj5D8FrLaukjRtTz5c3YDASQIix0/bYLhx7YUKFM5CJ94TXYmuWn2/HAhuwXQ2awNeAPG1ibhNFfp8dYCWZfkG7/MEhi2ql4nQQnbuu6KbDjiKg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW4PR11MB5911.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(84040400005)(508600001)(53546011)(7696005)(6506007)(9686003)(33656002)(316002)(55236004)(2906002)(82960400001)(110136005)(8676002)(30864003)(66446008)(52536014)(8936002)(66476007)(38070700005)(64756008)(76116006)(66946007)(66556008)(5660300002)(86362001)(38100700002)(122000001)(55016003)(26005)(83380400001)(186003)(71200400001)(579004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?B8LB50l5yARB/OGrUPX98fQXgi/kaYjkH7to621sMQonhGpDpp1a1iOz+7ZS?= =?us-ascii?Q?Um9DRv2lRGQ65nuVSoy0YqbLbG4kCdLWyheTVmE9h9qO/SKXrcNi0jr80lML?= =?us-ascii?Q?L/XMMBYluv+VQxeSQs0+qr3KzJ3lVz4GCzUmG0yUbmheUsWgFh2pOx9tRDOc?= =?us-ascii?Q?fb1qTNo+BBygGsCICnC18Bhbl17bs74bWNeiHHkgleenStzfmwrsZJEl6EWK?= =?us-ascii?Q?QXR84iryZ8FJp7W4MxtevgWz4qDJ18GJWVHdd7SMmzw00mjPyEkQlcX60hcf?= =?us-ascii?Q?CbykmOQY/GMawy/N7iCycWiGiyVMaryVe7/fh89miXqlVu7lov7LsFMapoce?= =?us-ascii?Q?COxcVAYkM1n9ECpQ6e9WSSF7qjexRkZyYxPNYP4sEAYuqB+Ne2qkCKEJu1py?= =?us-ascii?Q?pRxnWiAuScVEmKeIx/nXvtallZWWuKq31I0i/TZiIGvXs+kJVHdvmJ1gQD/w?= =?us-ascii?Q?oF2um9i2Jkwe2DI87Bv5wNoa8k59LS5sd4/X3jUTvM8eSwigeWatWhIkN+79?= =?us-ascii?Q?0ff4VUvTfH6Hf1k2Wn9utzxoyOBqODSa+NfZPxRRdr6z0qpEhqzqZTx/Cmjd?= =?us-ascii?Q?ug/cZkoazLwKbhFGWbT/V460L6IZwb1zAAqpBvNyc0vuPRu7ZWVNQATYng5Z?= =?us-ascii?Q?11lgFEFrCzW/aiT2BqWI5LElpv93gwfqvoJPyBD4DTvCgR8/iiObNqxqOV9n?= =?us-ascii?Q?wvGYF8i9M15/Yl4YAFMusgyu9zV4T8Qt3jkdY0UR8bmtYQIKk6vzpfUbJ+Gw?= =?us-ascii?Q?nZ9jguyrneLrJ6lvoaQ7/+ikLJUSk8Vvcfccd9CM3j/mwZPDXWI+cn7EHEgH?= =?us-ascii?Q?bzU7dEobrajx8Xi+z5ulvCJYd0Hlw0tGMwKm/RABQvZTVbS2KoT7tChRJL3O?= =?us-ascii?Q?pGnsXgb4RmneY8QzmsVUPRf8s0e2zYDNbA2A0XlGMaWMJH6uj0PKdsqNnd9f?= =?us-ascii?Q?WIo9DsyngCxpsoAxVH9hqjSPNwurSy+9qQYf8j62vlS/tOGKHo9R56CUc9zT?= =?us-ascii?Q?1dKnbbIysa4Ka5aG2HcAKAAORAVYKU/prBvZKFoWV64JUzm3aK4pL1lo2IrG?= =?us-ascii?Q?FF4hCSnZWcwjaPw+5nky8REh1xtqqgIq5Z0uWHp7aENu2p+AwSxXzm65Cb3w?= =?us-ascii?Q?l02ZZTwaG1BoQBMnImheK4qJ236G9jxCVQTnP61w+JwpAbtEDw8iotItcsus?= =?us-ascii?Q?UTrEOtQD2qmLKtTgaO+QoTe0upql2tM1yhP/aKg8VDz0VOlsxEtajyU7SCmI?= =?us-ascii?Q?v93jQOR6eF0cAhElJpzo30N2OdNgawGJKE+4ObVKpyoHaYw/XapoS8RG+P6D?= =?us-ascii?Q?vw+v8dfiZlZazgLhjDbM7LoFCutNqyhlBC4wauqKy6m8qOpUjiTKEAaeW3O2?= =?us-ascii?Q?Zn7rpLQioENpBhb66V0l3JbymwKDKq0D1rpqsHs1YILjwqcph6utSp4zpQl6?= =?us-ascii?Q?xldRNzQ0NCz5msdT2hPQjQVUtNqf3XUkgCqnlD9FBJfw7+jTg4dhWpPNHqOT?= =?us-ascii?Q?bki/+WAvVnWnEo3J6NCGfpr75ENd+KTHaYbxa++TTzuryk0+fTwSzeZgfeFH?= =?us-ascii?Q?XVodP+TAA+9wMctX47urPuYefsE7t6vfP6Zi+67ypAMnIr4OtMjhW9ekyaUq?= =?us-ascii?Q?Hz2JDg510swSQdoYnd0ftki7RGFAmxVcnvjI+m00zMVHpCSoyx9fcXxv1gfN?= =?us-ascii?Q?EnCRkQ=3D=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB5911.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d50a1b8-933a-49ef-a49e-08d9ea25285e X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Feb 2022 10:32:36.0523 (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: W07GPT94i33bMry/SCw8knVGIe2RgxGbCogxfCkJzc4fxo160DbQdgjgADKV5QfX/AXTXNGni80N7WKiFRUFrclydYE+LMa3w9LPIH3vrzI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1921 X-OriginatorOrg: intel.com 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 Hi Abhi, > -----Original Message----- > From: Gujjar, Abhinandan S > Sent: 13 January 2022 16:36 > To: Kundapura, Ganapati ; > jerinjacobk@gmail.com; Jayatheerthan, Jay ; > dev@dpdk.org > Subject: RE: [PATCH v3 1/2] eventdev/crypto_adapter: move crypto ops to > circular buffer >=20 > Hi Ganapati, >=20 >=20 > > -----Original Message----- > > From: Kundapura, Ganapati > > Sent: Tuesday, January 11, 2022 4:07 PM > > To: jerinjacobk@gmail.com; Jayatheerthan, Jay > > ; dev@dpdk.org > > Cc: Gujjar, Abhinandan S > > Subject: [PATCH v3 1/2] eventdev/crypto_adapter: move crypto ops to > > circular buffer > > > > Move crypto ops to circular buffer to retain crypto ops when > > cryptodev/eventdev are temporarily full > > > > --- > > v3: > > * update eca_ops_buffer_flush() to flush out all the crypto > > ops out of circular buffer. > > * remove freeing of failed crypto ops from eca_ops_enqueue_burst() > > and add to cirular buffer for later processing. > > > > v2: > > * reset cryptp adapter next cdev id before dequeueing from the > Cryptp -> crypto Updated in v4 > > next cdev > > --- > > > > Signed-off-by: Ganapati Kundapura > I don't see sign off after applying the patch. Could you take a look? > commit 18d9c3b1728f325dba5fe5dbb51df2366b70527a Moved signed-off before version history > Author: Ganapati Kundapura > Date: Tue Jan 11 04:36:30 2022 -0600 >=20 > eventdev/crypto_adapter: move crypto ops to circular buffer >=20 > Move crypto ops to circular buffer to retain crypto > ops when cryptodev/eventdev are temporarily full >=20 >=20 > > > > diff --git a/lib/eventdev/rte_event_crypto_adapter.c > > b/lib/eventdev/rte_event_crypto_adapter.c > > index d840803..9086368 100644 > > --- a/lib/eventdev/rte_event_crypto_adapter.c > > +++ b/lib/eventdev/rte_event_crypto_adapter.c > > @@ -25,11 +25,27 @@ > > #define CRYPTO_ADAPTER_MEM_NAME_LEN 32 #define > > CRYPTO_ADAPTER_MAX_EV_ENQ_RETRIES 100 > > > > +#define CRYPTO_ADAPTER_OPS_BUFFER_SZ (BATCH_SIZE + BATCH_SIZE) > > #define > > +CRYPTO_ADAPTER_BUFFER_SZ 1024 > > + > > /* Flush an instance's enqueue buffers every > CRYPTO_ENQ_FLUSH_THRESHOLD > > * iterations of eca_crypto_adapter_enq_run() > > */ > > #define CRYPTO_ENQ_FLUSH_THRESHOLD 1024 > > > > +struct crypto_ops_circular_buffer { > > + /* index of head element in circular buffer */ > > + uint16_t head; > > + /* index of tail element in circular buffer */ > > + uint16_t tail; > > + /* number elements in buffer */ > number elements -> number of elements updated > > + uint16_t count; > > + /* size of circular buffer */ > > + uint16_t size; > > + /* Pointer to hold rte_crypto_ops for batching */ > > + struct rte_crypto_op **op_buffer; > > +} __rte_cache_aligned; > > + > > struct event_crypto_adapter { > > /* Event device identifier */ > > uint8_t eventdev_id; > > @@ -47,6 +63,8 @@ struct event_crypto_adapter { > > struct crypto_device_info *cdevs; > > /* Loop counter to flush crypto ops */ > > uint16_t transmit_loop_count; > > + /* Circular buffer for batching crypto ops to eventdev */ > > + struct crypto_ops_circular_buffer ebuf; > > /* Per instance stats structure */ > > struct rte_event_crypto_adapter_stats crypto_stats; > > /* Configuration callback for rte_service configuration */ @@ -93,8 > > +111,8 @@ struct crypto_device_info { struct crypto_queue_pair_info { > > /* Set to indicate queue pair is enabled */ > > bool qp_enabled; > > - /* Pointer to hold rte_crypto_ops for batching */ > > - struct rte_crypto_op **op_buffer; > > + /* Circular buffer for batching crypto ops to cdev */ > > + struct crypto_ops_circular_buffer cbuf; > > /* No of crypto ops accumulated */ > > uint8_t len; > > } __rte_cache_aligned; > > @@ -141,6 +159,77 @@ eca_init(void) > > return 0; > > } > > > > +static inline bool > > +eca_circular_buffer_batch_ready(struct crypto_ops_circular_buffer > > +*bufp) { > > + return bufp->count >=3D BATCH_SIZE; > > +} > > + > > +static inline void > > +eca_circular_buffer_free(struct crypto_ops_circular_buffer *bufp) { > > + rte_free(bufp->op_buffer); > > +} > > + > > +static inline int > > +eca_circular_buffer_init(const char *name, > > + struct crypto_ops_circular_buffer *bufp, > > + uint16_t sz) > > +{ > > + bufp->op_buffer =3D rte_zmalloc(name, > > + sizeof(struct rte_crypto_op *) * sz, > > + 0); > > + if (bufp->op_buffer =3D=3D NULL) > > + return -ENOMEM; > > + > > + bufp->size =3D sz; > > + return 0; > > +} > > + > > +static inline int > > +eca_circular_buffer_add(struct crypto_ops_circular_buffer *bufp, > > + struct rte_crypto_op *op) > > +{ > > + uint16_t *tailp =3D &bufp->tail; > > + > > + bufp->op_buffer[*tailp] =3D op; > > + *tailp =3D (*tailp + 1) % bufp->size; > Provide a comment saying you are taking care of buffer rollover condition > > + bufp->count++; > > + > > + return 0; > > +} > > + > > +static inline int > > +eca_circular_buffer_flush_to_cdev(struct crypto_ops_circular_buffer > *bufp, > > + uint8_t cdev_id, uint16_t qp_id, > > + uint16_t *nb_ops_flushed) > This function is returning a value but caller does not check! > > +{ > > + uint16_t n =3D 0; > > + uint16_t *headp =3D &bufp->head; > > + uint16_t *tailp =3D &bufp->tail; > > + struct rte_crypto_op **ops =3D bufp->op_buffer; > > + > > + if (*tailp > *headp) > > + n =3D *tailp - *headp; > > + else if (*tailp < *headp) > > + n =3D bufp->size - *headp; > > + else { > > + *nb_ops_flushed =3D 0; > > + return 0; /* buffer empty */ > > + } > > + > > + *nb_ops_flushed =3D rte_cryptodev_enqueue_burst(cdev_id, qp_id, > > + &ops[*headp], n); > > + bufp->count -=3D *nb_ops_flushed; > > + if (!bufp->count) { > > + *headp =3D 0; > > + *tailp =3D 0; > > + } else > > + *headp =3D (*headp + *nb_ops_flushed) % bufp->size; > > + > > + return *nb_ops_flushed =3D=3D n ? 0 : -1; } > > + > > static inline struct event_crypto_adapter * > > eca_id_to_adapter(uint8_t id) { @@ -237,10 +326,19 @@ > > rte_event_crypto_adapter_create_ext(uint8_t id, uint8_t dev_id, > > return -ENOMEM; > > } > > > > + if (eca_circular_buffer_init("eca_edev_circular_buffer", > > + &adapter->ebuf, > > + CRYPTO_ADAPTER_BUFFER_SZ)) { > > + RTE_EDEV_LOG_ERR("Failed to get mem for edev buffer"); > Mem -> memory, edev -> eventdev. Updated in v4 > > + rte_free(adapter); > > + return -ENOMEM; > > + } > > + > > ret =3D rte_event_dev_info_get(dev_id, &dev_info); > > if (ret < 0) { > > RTE_EDEV_LOG_ERR("Failed to get info for eventdev %d: > %s!", > > dev_id, dev_info.driver_name); > > + eca_circular_buffer_free(&adapter->ebuf); > > rte_free(adapter); > > return ret; > > } > > @@ -259,6 +357,7 @@ rte_event_crypto_adapter_create_ext(uint8_t id, > > uint8_t dev_id, > > socket_id); > > if (adapter->cdevs =3D=3D NULL) { > > RTE_EDEV_LOG_ERR("Failed to get mem for crypto > devices\n"); > > + eca_circular_buffer_free(&adapter->ebuf); > > rte_free(adapter); > > return -ENOMEM; > > } > > @@ -337,11 +436,10 @@ eca_enq_to_cryptodev(struct > event_crypto_adapter > > *adapter, struct rte_event *ev, > > struct crypto_queue_pair_info *qp_info =3D NULL; > > struct rte_crypto_op *crypto_op; > > unsigned int i, n; > > - uint16_t qp_id, len, ret; > > + uint16_t qp_id, len, nb_enqueued =3D 0; > > uint8_t cdev_id; > > > > len =3D 0; > > - ret =3D 0; > > n =3D 0; > > stats->event_deq_count +=3D cnt; > > > > @@ -367,7 +465,7 @@ eca_enq_to_cryptodev(struct > event_crypto_adapter > > *adapter, struct rte_event *ev, > > continue; > > } > > len =3D qp_info->len; > > - qp_info->op_buffer[len] =3D crypto_op; > > + eca_circular_buffer_add(&qp_info->cbuf, > crypto_op); > > len++; > > } else if (crypto_op->sess_type =3D=3D > > RTE_CRYPTO_OP_SESSIONLESS && > > crypto_op->private_data_offset) { @@ - > 383,7 +481,7 @@ > > eca_enq_to_cryptodev(struct event_crypto_adapter *adapter, struct > > rte_event *ev, > > continue; > > } > > len =3D qp_info->len; > > - qp_info->op_buffer[len] =3D crypto_op; > > + eca_circular_buffer_add(&qp_info->cbuf, > crypto_op); > > len++; > > } else { > > rte_pktmbuf_free(crypto_op->sym->m_src); > > @@ -391,18 +489,17 @@ eca_enq_to_cryptodev(struct > event_crypto_adapter > > *adapter, struct rte_event *ev, > > continue; > > } > > > > - if (len =3D=3D BATCH_SIZE) { > > - struct rte_crypto_op **op_buffer =3D qp_info- > > >op_buffer; > > - ret =3D rte_cryptodev_enqueue_burst(cdev_id, > > + if (eca_circular_buffer_batch_ready(&qp_info->cbuf)) { > > + eca_circular_buffer_flush_to_cdev(&qp_info->cbuf, > > + cdev_id, > > qp_id, > > - op_buffer, > > - BATCH_SIZE); > > + &nb_enqueued); > > + stats->crypto_enq_count +=3D nb_enqueued; > > + n +=3D nb_enqueued; > > > > - stats->crypto_enq_count +=3D ret; > > - > > - while (ret < len) { > > + while (nb_enqueued < len) { > > struct rte_crypto_op *op; > > - op =3D op_buffer[ret++]; > > + op =3D qp_info- > > >cbuf.op_buffer[nb_enqueued++]; > > stats->crypto_enq_fail++; > > rte_pktmbuf_free(op->sym->m_src); > > rte_crypto_op_free(op); > Not sure, why are you free the ops which are not enqueued to cryptodev. > Isn't it the goal of the patch is to retain those non-enqueued crypto_ops > temporarily and retry later? Retained failed ops >=20 > > @@ -413,7 +510,6 @@ eca_enq_to_cryptodev(struct > event_crypto_adapter > > *adapter, struct rte_event *ev, > > > > if (qp_info) > > qp_info->len =3D len; > > - n +=3D ret; > > } > > > > return n; > > @@ -425,14 +521,12 @@ eca_crypto_enq_flush(struct > event_crypto_adapter > > *adapter) > > struct rte_event_crypto_adapter_stats *stats =3D &adapter- > >crypto_stats; > > struct crypto_device_info *curr_dev; > > struct crypto_queue_pair_info *curr_queue; > > - struct rte_crypto_op **op_buffer; > > struct rte_cryptodev *dev; > > uint8_t cdev_id; > > uint16_t qp; > > - uint16_t ret; > > + uint16_t nb_enqueued =3D 0, nb =3D 0; > > uint16_t num_cdev =3D rte_cryptodev_count(); > > > > - ret =3D 0; > > for (cdev_id =3D 0; cdev_id < num_cdev; cdev_id++) { > > curr_dev =3D &adapter->cdevs[cdev_id]; > > dev =3D curr_dev->dev; > > @@ -444,16 +538,17 @@ eca_crypto_enq_flush(struct > event_crypto_adapter > > *adapter) > > if (!curr_queue->qp_enabled) > > continue; > > > > - op_buffer =3D curr_queue->op_buffer; > > - ret =3D rte_cryptodev_enqueue_burst(cdev_id, > > + eca_circular_buffer_flush_to_cdev(&curr_queue- > >cbuf, > > + cdev_id, > > qp, > > - op_buffer, > > - curr_queue->len); > > - stats->crypto_enq_count +=3D ret; > > + &nb_enqueued); > > > > - while (ret < curr_queue->len) { > > + stats->crypto_enq_count +=3D nb_enqueued; > > + nb +=3D nb_enqueued; > > + > > + while (nb_enqueued < curr_queue->len) { > > struct rte_crypto_op *op; > > - op =3D op_buffer[ret++]; > > + op =3D curr_queue- > > >cbuf.op_buffer[nb_enqueued++]; > > stats->crypto_enq_fail++; > > rte_pktmbuf_free(op->sym->m_src); > > rte_crypto_op_free(op); > > @@ -462,7 +557,7 @@ eca_crypto_enq_flush(struct > event_crypto_adapter > > *adapter) > > } > > } > > > > - return ret; > > + return nb; > > } > > > > static int > > @@ -499,9 +594,9 @@ eca_crypto_adapter_enq_run(struct > > event_crypto_adapter *adapter, > > return nb_enqueued; > > } > > > > -static inline void > > +static inline uint16_t > > eca_ops_enqueue_burst(struct event_crypto_adapter *adapter, > > - struct rte_crypto_op **ops, uint16_t num) > > + struct rte_crypto_op **ops, uint16_t num) > > { > > struct rte_event_crypto_adapter_stats *stats =3D &adapter- > >crypto_stats; > > union rte_event_crypto_metadata *m_data =3D NULL; @@ -518,6 > +613,8 @@ > > eca_ops_enqueue_burst(struct event_crypto_adapter *adapter, > > num =3D RTE_MIN(num, BATCH_SIZE); > > for (i =3D 0; i < num; i++) { > > struct rte_event *ev =3D &events[nb_ev++]; > > + > > + m_data =3D NULL; > > if (ops[i]->sess_type =3D=3D RTE_CRYPTO_OP_WITH_SESSION) { > > m_data =3D > rte_cryptodev_sym_session_get_user_data( > > ops[i]->sym->session); > > @@ -548,21 +645,58 @@ eca_ops_enqueue_burst(struct > > event_crypto_adapter *adapter, > > event_port_id, > > &events[nb_enqueued], > > nb_ev - nb_enqueued); > > + > > } while (retry++ < CRYPTO_ADAPTER_MAX_EV_ENQ_RETRIES && > > nb_enqueued < nb_ev); > > > > - /* Free mbufs and rte_crypto_ops for failed events */ > > - for (i =3D nb_enqueued; i < nb_ev; i++) { > > - struct rte_crypto_op *op =3D events[i].event_ptr; > > - rte_pktmbuf_free(op->sym->m_src); > > - rte_crypto_op_free(op); > > - } > > - > > stats->event_enq_fail_count +=3D nb_ev - nb_enqueued; > > stats->event_enq_count +=3D nb_enqueued; > > stats->event_enq_retry_count +=3D retry - 1; > > + > > + return nb_enqueued; > > } > > > > +static int > > +eca_circular_buffer_flush_to_evdev(struct event_crypto_adapter > *adapter, > > + struct crypto_ops_circular_buffer *bufp) { > > + uint16_t n =3D 0, nb_ops_flushed; > > + uint16_t *headp =3D &bufp->head; > > + uint16_t *tailp =3D &bufp->tail; > > + struct rte_crypto_op **ops =3D bufp->op_buffer; > > + > > + if (*tailp > *headp) > > + n =3D *tailp - *headp; > > + else if (*tailp < *headp) > > + n =3D bufp->size - *headp; > > + else > > + return 0; /* buffer empty */ > > + > > + nb_ops_flushed =3D eca_ops_enqueue_burst(adapter, ops, n); > > + bufp->count -=3D nb_ops_flushed; > > + if (!bufp->count) { > > + *headp =3D 0; > > + *tailp =3D 0; > > + > Extra line not required removed > > + return 0; /* buffer empty */ > > + } > > + > > + *headp =3D (*headp + nb_ops_flushed) % bufp->size; > > + > Extra line not required removed > > + return 1; > > +} > > + > > + > > +static void > > +eca_ops_buffer_flush(struct event_crypto_adapter *adapter) { > > + if (adapter->ebuf.count =3D=3D 0) > > + return; > > + > > + while (eca_circular_buffer_flush_to_evdev(adapter, > > + &adapter->ebuf)) > > + ; > > +} > > static inline unsigned int > > eca_crypto_adapter_deq_run(struct event_crypto_adapter *adapter, > > unsigned int max_deq) > > @@ -571,7 +705,7 @@ eca_crypto_adapter_deq_run(struct > > event_crypto_adapter *adapter, > > struct crypto_device_info *curr_dev; > > struct crypto_queue_pair_info *curr_queue; > > struct rte_crypto_op *ops[BATCH_SIZE]; > > - uint16_t n, nb_deq; > > + uint16_t n, nb_deq, nb_enqueued, i; > > struct rte_cryptodev *dev; > > uint8_t cdev_id; > > uint16_t qp, dev_qps; > > @@ -579,16 +713,20 @@ eca_crypto_adapter_deq_run(struct > > event_crypto_adapter *adapter, > > uint16_t num_cdev =3D rte_cryptodev_count(); > > > > nb_deq =3D 0; > > + eca_ops_buffer_flush(adapter); > > + > > do { > > - uint16_t queues =3D 0; > > done =3D true; > > > > for (cdev_id =3D adapter->next_cdev_id; > > cdev_id < num_cdev; cdev_id++) { > > + uint16_t queues =3D 0; > > + > > curr_dev =3D &adapter->cdevs[cdev_id]; > > dev =3D curr_dev->dev; > > if (dev =3D=3D NULL) > > continue; > > + > > dev_qps =3D dev->data->nb_queue_pairs; > > > > for (qp =3D curr_dev->next_queue_pair_id; @@ -596,7 > > +734,8 @@ eca_crypto_adapter_deq_run(struct event_crypto_adapter > > *adapter, > > queues++) { > > > > curr_queue =3D &curr_dev->qpairs[qp]; > > - if (!curr_queue->qp_enabled) > > + if (curr_queue =3D=3D NULL || > > + !curr_queue->qp_enabled) > > continue; > > > > n =3D rte_cryptodev_dequeue_burst(cdev_id, > qp, @@ -605,11 +744,27 > > @@ eca_crypto_adapter_deq_run(struct event_crypto_adapter *adapter, > > continue; > > > > done =3D false; > > + nb_enqueued =3D 0; > > + > > stats->crypto_deq_count +=3D n; > > - eca_ops_enqueue_burst(adapter, ops, n); > > + > > + if (unlikely(!adapter->ebuf.count)) > > + nb_enqueued =3D > > eca_ops_enqueue_burst( > > + adapter, ops, n); > > + > > + if (nb_enqueued =3D=3D n) > > + goto check; > > + > > + /* Failed to enqueue events case */ > > + for (i =3D nb_enqueued; i < n; i++) > > + eca_circular_buffer_add( > > + &adapter->ebuf, > > + ops[nb_enqueued]); > > + > > +check: > > nb_deq +=3D n; > > > > - if (nb_deq > max_deq) { > > + if (nb_deq >=3D max_deq) { > > if ((qp + 1) =3D=3D dev_qps) { > > adapter->next_cdev_id =3D > > (cdev_id + 1) > > @@ -622,6 +777,7 @@ eca_crypto_adapter_deq_run(struct > > event_crypto_adapter *adapter, > > } > > } > > } > > + adapter->next_cdev_id =3D 0; > > } while (done =3D=3D false); > > return nb_deq; > > } > > @@ -751,11 +907,10 @@ eca_add_queue_pair(struct > event_crypto_adapter > > *adapter, uint8_t cdev_id, > > return -ENOMEM; > > > > qpairs =3D dev_info->qpairs; > > - qpairs->op_buffer =3D rte_zmalloc_socket(adapter- > >mem_name, > > - BATCH_SIZE * > > - sizeof(struct rte_crypto_op *), > > - 0, adapter->socket_id); > > - if (!qpairs->op_buffer) { > > + > > + if (eca_circular_buffer_init("eca_cdev_circular_buffer", > > + &qpairs->cbuf, > > + > > CRYPTO_ADAPTER_OPS_BUFFER_SZ)) { > > rte_free(qpairs); > > return -ENOMEM; > > } > > -- > > 2.6.4