From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id ED8461D7 for ; Mon, 12 Nov 2018 22:01:13 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2018 13:01:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,496,1534834800"; d="scan'208";a="99686592" Received: from irsmsx152.ger.corp.intel.com ([163.33.192.66]) by orsmga003.jf.intel.com with ESMTP; 12 Nov 2018 13:01:10 -0800 Received: from irsmsx156.ger.corp.intel.com (10.108.20.68) by IRSMSX152.ger.corp.intel.com (163.33.192.66) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 12 Nov 2018 21:01:09 +0000 Received: from irsmsx101.ger.corp.intel.com ([169.254.1.134]) by IRSMSX156.ger.corp.intel.com ([169.254.3.140]) with mapi id 14.03.0415.000; Mon, 12 Nov 2018 21:01:08 +0000 From: "Trahe, Fiona" To: "Ananyev, Konstantin" , "dev@dpdk.org" CC: "De Lara Guarch, Pablo" , Akhil Goyal , "Doherty, Declan" , "Ravi Kumar" , Jerin Jacob , "Zhang, Roy Fan" , Tomasz Duszynski , Hemant Agrawal , Natalie Samsonov , Dmitri Epshtein , Jay Zhou , "Trahe, Fiona" Thread-Topic: [RFC] cryptodev: proposed changes in rte_cryptodev_sym_session Thread-Index: AQHUO9Lgj4uhEYXKc0eAMj3Nvkgz2qVNEv6g Date: Mon, 12 Nov 2018 21:01:07 +0000 Message-ID: <348A99DA5F5B7549AA880327E580B43589676DA2@IRSMSX101.ger.corp.intel.com> References: <1535132906-5167-1-git-send-email-konstantin.ananyev@intel.com> In-Reply-To: <1535132906-5167-1-git-send-email-konstantin.ananyev@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzYyYmEwZjAtMjg1NC00MGY1LTg2NmQtNDNiNjczMzg1NDVmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiOXBaRkJ2SHFiVEhWS1pnZGZGZE5OcDYrb0dXUG9Bc2RDMXhZKzZcL1kxanlINTRERnd5UWszbXlzQ2M3Z1I3a0sifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [RFC] cryptodev: proposed changes in rte_cryptodev_sym_session 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: , X-List-Received-Date: Mon, 12 Nov 2018 21:01:14 -0000 Hi Konstantin, Sorry for the delay in reviewing this and thanks for your proposals. > -----Original Message----- > From: Ananyev, Konstantin > Sent: Friday, August 24, 2018 10:48 AM > To: dev@dpdk.org > Cc: Ananyev, Konstantin ; De Lara Guarch, P= ablo > ; Akhil Goyal ; Dohe= rty, Declan > ; Ravi Kumar ; Jerin Jacob > ; Zhang, Roy Fan ; Trahe, Fiona > ; Tomasz Duszynski ; Hemant Agra= wal > ; Natalie Samsonov ; Dmitri= Epshtein > ; Jay Zhou > Subject: [RFC] cryptodev: proposed changes in rte_cryptodev_sym_session >=20 > This RFC for proposes several changes inside rte_cryptodev_sym_session. > Note that this is just RFC not a complete patch, so for now > I modified only the librte_cryptodev itself, > some cryptodev PMD, test-crypto-perf and ipsec-secgw example. > Proposed changes means ABI/API breakage inside cryptodev, > so looking for feedback from crypto-dev lib and crypto-PMD maintainiers. > Below are details and reasoning for proposed changes. >=20 > 1.rte_cryptodev_sym_session_init()/ rte_cryptodev_sym_session_clear() > operate based on cytpodev device id, though inside > rte_cryptodev_sym_session device specific data is addressed > by driver id (not device id). > That creates a problem with current implementation when we have > two or more devices with the same driver used by the same session. > Consider the following example: >=20 > struct rte_cryptodev_sym_session *sess; > rte_cryptodev_sym_session_init(dev_id=3DX, sess, ...); > rte_cryptodev_sym_session_init(dev_id=3DY, sess, ...); > rte_cryptodev_sym_session_clear(dev_id=3DX, sess); >=20 > After that point if X and Y uses the same driver, > then sess can't be used by device Y any more. > The reason for that - driver specific (not device specific) > data per session, plus there is no information > how many device instances use that data. > Probably the simplest way to deal with that issue - > add a reference counter per each driver data. [Fiona] Ok, I agree with this issue and proposed fix. We need to also document that it's user's responsibility not to call either init() or clear() twice on same device, as that would break the ref count. The same should be added to asym_session - though I accept it'sbe outside of the scope of this patch. > 2.rte_cryptodev_sym_session_set_user_data() and > rte_cryptodev_sym_session_get_user_data() - > with current implementation there is no defined way for the user to > determine what is the max allowed size of the private data. > Even within rte_cryptodev_sym_session_set_user_data() we just blindly > copying user provided data without checking memory boundaries violation= . > To overcome that issue I added 'uint16_t priv_size' into > rte_cryptodev_sym_session structure. [Fiona] I agree, this is needed. But I propose to call it user_data_sz NOT priv_size.=20 See https://patches.dpdk.org/patch/42515/ to understand why. =20 > 3.rte_cryptodev_sym_session contains an array of variable size for > driver specific data. > Though number of elements in that array is determined by static > variable nb_drivers, that could be modified by > rte_cryptodev_allocate_driver(). > That construction seems to work ok so far, as right now users register > all their PMDs at startup, though it doesn't mean that it would always > remain like that. > To make it less error prone I added 'uint16_t nb_drivers' into the > rte_cryptodev_sym_session structure. > At least that allows related functions to check that provided > driver id wouldn't overrun variable array boundaries, > again it allows to determine size of already allocated session > without accessing global variable. [Fiona] I agree with both issue and solution.=20 The same should be added to asym_session - though again it's outside of the scope of this patch. > 4.#2 and #3 above implies that now each struct rte_cryptodev_sym_session > would have sort of readonly type data (init once at allocation time, > keep unmodified through session life-time). > That requires more changes in current cryptodev implementation: > Right now inside cryptodev framework both rte_cryptodev_sym_session > and driver specific session data are two completely different sctrucure= s > (e.g. struct struct null_crypto_session and struct null_crypto_session)= . > Though current cryptodev implementation implicitly assumes that driver > will allocate both of them from within the same mempool. > Plus this is done in a manner that they override each other fields > (reuse the same space - sort of implicit C union). > That's probably not the best programming practice, > plus make impossible to have readonly fields inside both of them. > So to overcome that situation I changed an API a bit, to allow > to use two different mempools for these two distinct data structures. >=20 > 5. Add 'uint64_t userdata' inside struct rte_cryptodev_sym_session. > I suppose that self-explanatory, and might be used in a lot of places > (would be quite useful for ipsec library we develop). [Fiona] Seems unnecessary - the set_user_data can be used. Why have 2 separate user data spaces in the session? - it's confusing. If these is some good reason, then a different name should be used for clar= ity. Not private. And not user. Possibly opaque data. Though afaik we had this i= n the op and removed it as it was felt appending user_data was enough. > So the new proposed layout for rte_cryptodev_sym_session: > struct rte_cryptodev_sym_session { > uint64_t userdata; > /**< Can be used for external metadata */ > uint16_t nb_drivers; > /**< number of elements in sess_data array */ > uint16_t priv_size; > /**< session private data will be placed after sess_data */ > __extension__ struct { > void *data; > uint16_t refcnt; > } sess_data[0]; > /**< Driver specific session material, variable size */ > }; >=20 >=20 > Signed-off-by: Konstantin Ananyev > --- > app/test-crypto-perf/cperf.h | 1 + > app/test-crypto-perf/cperf_ops.c | 11 +- > app/test-crypto-perf/cperf_ops.h | 2 +- > app/test-crypto-perf/cperf_test_latency.c | 5 +- > app/test-crypto-perf/cperf_test_latency.h | 1 + > app/test-crypto-perf/cperf_test_pmd_cyclecount.c | 5 +- > app/test-crypto-perf/cperf_test_pmd_cyclecount.h | 1 + > app/test-crypto-perf/cperf_test_throughput.c | 5 +- > app/test-crypto-perf/cperf_test_throughput.h | 1 + > app/test-crypto-perf/cperf_test_verify.c | 5 +- > app/test-crypto-perf/cperf_test_verify.h | 1 + > app/test-crypto-perf/main.c | 111 +++++++++++----= -- > drivers/crypto/aesni_gcm/aesni_gcm_pmd.c | 10 +- > drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c | 5 +- > drivers/crypto/aesni_gcm/aesni_gcm_pmd_private.h | 4 +- > drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 10 +- > drivers/crypto/aesni_mb/rte_aesni_mb_pmd_ops.c | 5 +- > drivers/crypto/aesni_mb/rte_aesni_mb_pmd_private.h | 4 +- > drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 3 +- > drivers/crypto/dpaa_sec/dpaa_sec.c | 3 +- > drivers/crypto/null/null_crypto_pmd.c | 14 ++- > drivers/crypto/null/null_crypto_pmd_ops.c | 5 +- > drivers/crypto/null/null_crypto_pmd_private.h | 4 +- > drivers/crypto/scheduler/scheduler_pmd_ops.c | 5 +- > drivers/crypto/virtio/virtio_cryptodev.c | 6 +- > examples/ipsec-secgw/ipsec-secgw.c | 116 ++++++++++++---= --- > examples/ipsec-secgw/ipsec.h | 2 + > lib/librte_cryptodev/rte_cryptodev.c | 134 ++++++++++++---= ------ > lib/librte_cryptodev/rte_cryptodev.h | 53 ++++++-- > lib/librte_cryptodev/rte_cryptodev_pmd.h | 16 ++- > 30 files changed, 356 insertions(+), 192 deletions(-) >=20 ///snip/// > struct cnt_blk { > diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/= rte_cryptodev.c > index 63ae23f00..e25282445 100644 > --- a/lib/librte_cryptodev/rte_cryptodev.c > +++ b/lib/librte_cryptodev/rte_cryptodev.c > @@ -943,8 +943,7 @@ rte_cryptodev_close(uint8_t dev_id) >=20 > int > rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id, > - const struct rte_cryptodev_qp_conf *qp_conf, int socket_id, > - struct rte_mempool *session_pool) > + const struct rte_cryptodev_qp_conf *qp_conf, int socket_id) >=20 > { > struct rte_cryptodev *dev; > @@ -954,6 +953,12 @@ rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint1= 6_t queue_pair_id, > return -EINVAL; > } >=20 > + if (qp_conf =3D=3D NULL || qp_conf->sess_pool =3D=3D NULL || > + qp_conf->priv_sess_pool =3D=3D NULL) { > + CDEV_LOG_ERR("Invalid queue_pair config"); > + return -EINVAL; > + } > + > dev =3D &rte_crypto_devices[dev_id]; > if (queue_pair_id >=3D dev->data->nb_queue_pairs) { > CDEV_LOG_ERR("Invalid queue_pair_id=3D%d", queue_pair_id); > @@ -969,7 +974,7 @@ rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16= _t queue_pair_id, > RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_pair_setup, -ENOTSUP); >=20 > return (*dev->dev_ops->queue_pair_setup)(dev, queue_pair_id, qp_conf, > - socket_id, session_pool); > + socket_id); > } >=20 >=20 > @@ -1146,6 +1151,41 @@ rte_cryptodev_pmd_callback_process(struct rte_cryp= todev *dev, > rte_spinlock_unlock(&rte_cryptodev_cb_lock); > } >=20 > +static void > +cryptodev_sym_session_init_elem(__rte_unused struct rte_mempool *pool, > + void *arg, void *obj, __rte_unused uint32_t idx) > +{ > + struct rte_cryptodev_sym_session *ds; > + const struct rte_cryptodev_sym_session *ss; > + > + ds =3D obj; > + ss =3D arg; > + > + *ds =3D *ss; > + memset(ds->sess_data, 0, rte_cryptodev_sym_session_data_size(ds)); > +} > + > +struct rte_mempool * > +rte_cryptodev_sym_session_pool_create(const char *name, > + uint32_t nb_elts, uint32_t cache_size, uint16_t priv_size, > + int socket_id) > +{ > + struct rte_mempool *mp; > + uint32_t elt_size; > + struct rte_cryptodev_sym_session s =3D { > + .nb_drivers =3D nb_drivers, > + .priv_size =3D priv_size, > + }; > + > + elt_size =3D rte_cryptodev_sym_session_max_size(priv_size); > + mp =3D rte_mempool_create(name, nb_elts, elt_size, cache_size, 0, > + NULL, NULL, cryptodev_sym_session_init_elem, &s, > + socket_id, 0); > + if (mp =3D=3D NULL) > + CDEV_LOG_ERR("%s(name=3D%s) failed, rte_errno=3D%d\n", > + __func__, name, rte_errno); > + return mp; > +} >=20 > int > rte_cryptodev_sym_session_init(uint8_t dev_id, > @@ -1163,12 +1203,15 @@ rte_cryptodev_sym_session_init(uint8_t dev_id, > return -EINVAL; >=20 > index =3D dev->driver_id; > + if (index > sess->nb_drivers) > + return -EINVAL; >=20 > RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->sym_session_configure, -ENOTSUP)= ; >=20 > - if (sess->sess_private_data[index] =3D=3D NULL) { > + if (sess->sess_data[index].refcnt =3D=3D 0) { > ret =3D dev->dev_ops->sym_session_configure(dev, xforms, > - sess, mp); > + sess, mp); > + > if (ret < 0) { > CDEV_LOG_ERR( > "dev_id %d failed to configure session details", > @@ -1177,6 +1220,7 @@ rte_cryptodev_sym_session_init(uint8_t dev_id, > } > } >=20 > + sess->sess_data[index].refcnt++; > return 0; > } >=20 > @@ -1229,8 +1273,7 @@ rte_cryptodev_sym_session_create(struct rte_mempool= *mp) > /* Clear device session pointer. > * Include the flag indicating presence of user data > */ > - memset(sess, 0, (sizeof(void *) * nb_drivers) + sizeof(uint8_t)); > - > + memset(sess->sess_data, 0, rte_cryptodev_sym_session_data_size(sess)); > return sess; > } >=20 > @@ -1258,16 +1301,20 @@ rte_cryptodev_sym_session_clear(uint8_t dev_id, > struct rte_cryptodev_sym_session *sess) > { > struct rte_cryptodev *dev; > + uint32_t idx; >=20 > dev =3D rte_cryptodev_pmd_get_dev(dev_id); >=20 > - if (dev =3D=3D NULL || sess =3D=3D NULL) > + if (dev =3D=3D NULL || sess =3D=3D NULL || dev->driver_id > sess->nb_dr= ivers) > return -EINVAL; >=20 > RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->sym_session_clear, -ENOTSUP); >=20 > - dev->dev_ops->sym_session_clear(dev, sess); > + idx =3D dev->driver_id; > + if (--sess->sess_data[idx].refcnt !=3D 0) > + return -EBUSY; >=20 > + dev->dev_ops->sym_session_clear(dev, sess); > return 0; > } >=20 > @@ -1285,7 +1332,6 @@ rte_cryptodev_asym_session_clear(uint8_t dev_id, > RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->asym_session_clear, -ENOTSUP); >=20 > dev->dev_ops->asym_session_clear(dev, sess); > - > return 0; > } >=20 > @@ -1293,7 +1339,6 @@ int > rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess) > { > uint8_t i; > - void *sess_priv; > struct rte_mempool *sess_mp; >=20 > if (sess =3D=3D NULL) > @@ -1301,8 +1346,7 @@ rte_cryptodev_sym_session_free(struct rte_cryptodev= _sym_session *sess) >=20 > /* Check that all device private data has been freed */ > for (i =3D 0; i < nb_drivers; i++) { [Fiona] Use the sess.nb_drivers rather than the global. Actually maybe name slightly differently to reduce the chance of that mista= ke happening, e.g.=20 rename sess.nb_drivers to sess.num_drivers? > - sess_priv =3D get_sym_session_private_data(sess, i); > - if (sess_priv !=3D NULL) > + if (sess->sess_data[i].refcnt !=3D 0) > return -EBUSY; > } >=20 > @@ -1313,6 +1357,23 @@ rte_cryptodev_sym_session_free(struct rte_cryptode= v_sym_session *sess) > return 0; > } >=20 > +unsigned int > +rte_cryptodev_sym_session_max_data_size(void) [Fiona] Suggest renaming this=20 rte_cryptodev_sym_session_max_array_size() > +{ > + struct rte_cryptodev_sym_session *sess =3D NULL; > + > + return (sizeof(sess->sess_data[0]) * nb_drivers); > +} > + > +size_t > +rte_cryptodev_sym_session_max_size(uint16_t priv_size) > +{ > + struct rte_cryptodev_sym_session *sess =3D NULL; > + > + return (sizeof(*sess) + priv_size + > + rte_cryptodev_sym_session_max_data_size()); > +} > + > int __rte_experimental > rte_cryptodev_asym_session_free(struct rte_cryptodev_asym_session *sess) > { > @@ -1337,18 +1398,6 @@ rte_cryptodev_asym_session_free(struct rte_cryptod= ev_asym_session *sess) > return 0; > } >=20 > - > -unsigned int > -rte_cryptodev_sym_get_header_session_size(void) > -{ > - /* > - * Header contains pointers to the private data > - * of all registered drivers, and a flag which > - * indicates presence of user data > - */ > - return ((sizeof(void *) * nb_drivers) + sizeof(uint8_t)); > -} > - > unsigned int __rte_experimental > rte_cryptodev_asym_get_header_session_size(void) > { > @@ -1361,11 +1410,9 @@ rte_cryptodev_asym_get_header_session_size(void) > } >=20 > unsigned int > -rte_cryptodev_sym_get_private_session_size(uint8_t dev_id) > +rte_cryptodev_sym_private_session_size(uint8_t dev_id) > { > struct rte_cryptodev *dev; > - unsigned int header_size =3D sizeof(void *) * nb_drivers; > - unsigned int priv_sess_size; >=20 > if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) > return 0; > @@ -1375,18 +1422,7 @@ rte_cryptodev_sym_get_private_session_size(uint8_t= dev_id) > if (*dev->dev_ops->sym_session_get_size =3D=3D NULL) > return 0; >=20 > - priv_sess_size =3D (*dev->dev_ops->sym_session_get_size)(dev); > - > - /* > - * If size is less than session header size, > - * return the latter, as this guarantees that > - * sessionless operations will work > - */ > - if (priv_sess_size < header_size) > - return header_size; > - > - return priv_sess_size; > - > + return (*dev->dev_ops->sym_session_get_size)(dev); > } >=20 > unsigned int __rte_experimental > @@ -1409,7 +1445,6 @@ rte_cryptodev_asym_get_private_session_size(uint8_t= dev_id) > return header_size; >=20 > return priv_sess_size; > - > } >=20 > int __rte_experimental > @@ -1418,15 +1453,10 @@ rte_cryptodev_sym_session_set_user_data( > void *data, > uint16_t size) > { > - uint16_t off_set =3D sizeof(void *) * nb_drivers; > - uint8_t *user_data_present =3D (uint8_t *)sess + off_set; > - > - if (sess =3D=3D NULL) > + if (sess =3D=3D NULL || sess->priv_size < size) > return -EINVAL; >=20 > - *user_data_present =3D 1; > - off_set +=3D sizeof(uint8_t); > - rte_memcpy((uint8_t *)sess + off_set, data, size); > + rte_memcpy(sess->sess_data + sess->nb_drivers, data, size); > return 0; > } >=20 > @@ -1434,14 +1464,10 @@ void * __rte_experimental > rte_cryptodev_sym_session_get_user_data( > struct rte_cryptodev_sym_session *sess) > { > - uint16_t off_set =3D sizeof(void *) * nb_drivers; > - uint8_t *user_data_present =3D (uint8_t *)sess + off_set; > - > - if (sess =3D=3D NULL || !*user_data_present) > + if (sess =3D=3D NULL || sess->priv_size =3D=3D 0) > return NULL; >=20 > - off_set +=3D sizeof(uint8_t); > - return (uint8_t *)sess + off_set; > + return (sess->sess_data + sess->nb_drivers); > } >=20 > /** Initialise rte_crypto_op mempool element */ > diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/= rte_cryptodev.h > index 4099823f1..d88454f02 100644 > --- a/lib/librte_cryptodev/rte_cryptodev.h > +++ b/lib/librte_cryptodev/rte_cryptodev.h > @@ -495,6 +495,14 @@ enum rte_cryptodev_event_type { > /** Crypto device queue pair configuration structure. */ > struct rte_cryptodev_qp_conf { > uint32_t nb_descriptors; /**< Number of descriptors per queue pair */ > + struct rte_mempool *sess_pool; > + /**< Pointer to crypto sessions mempool, > + * used for session-less operations. > + */ > + struct rte_mempool *priv_sess_pool; > + /**< Pointer to device specific sessions mempool, > + * used for session-less operations. > + */ > }; >=20 > /** > @@ -680,17 +688,13 @@ rte_cryptodev_close(uint8_t dev_id); > * *SOCKET_ID_ANY* if there is no NUMA constraint > * for the DMA memory allocated for the receive > * queue pair. > - * @param session_pool Pointer to device session mempool, used > - * for session-less operations. > - * > * @return > * - 0: Success, queue pair correctly set up. > * - <0: Queue pair configuration failed > */ > extern int > rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id, > - const struct rte_cryptodev_qp_conf *qp_conf, int socket_id, > - struct rte_mempool *session_pool); > + const struct rte_cryptodev_qp_conf *qp_conf, int socket_id); >=20 > /** > * Get the number of queue pairs on a specific crypto device > @@ -954,10 +958,43 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_= t qp_id, > * has a fixed algo, key, op-type, digest_len etc. > */ > struct rte_cryptodev_sym_session { > - __extension__ void *sess_private_data[0]; > - /**< Private symmetric session material */ > + uint64_t userdata; > + /**< Can be used for external metadata */ > + uint16_t nb_drivers; > + /**< number of elements in sess_data array */ > + uint16_t priv_size; > + /**< session private data will be placed after sess_data */ > + __extension__ struct { > + void *data; > + uint16_t refcnt; > + } sess_data[0]; > + /**< Driver specific session material, variable size */ > }; >=20 > +static inline size_t > +rte_cryptodev_sym_session_data_size(const struct rte_cryptodev_sym_sessi= on *s) > +{ > + return (sizeof(s->sess_data[0]) * s->nb_drivers); > +} > + > +static inline size_t > +rte_cryptodev_sym_session_size(const struct rte_cryptodev_sym_session *s= ) > +{ > + return (sizeof(*s) + (s)->priv_size + > + rte_cryptodev_sym_session_data_size(s)); > +} > + [Fiona] Are above 2 fns used?=20 Look like duplicates of the "max" fns? > +unsigned int > +rte_cryptodev_sym_session_max_data_size(void); > + > +size_t > +rte_cryptodev_sym_session_max_size(uint16_t priv_size); > + > +struct rte_mempool * > +rte_cryptodev_sym_session_pool_create(const char *name, > + uint32_t nb_elts, uint32_t cache_size, uint16_t priv_size, > + int socket_id); > + > /** Cryptodev asymmetric crypto session */ > struct rte_cryptodev_asym_session { > __extension__ void *sess_private_data[0]; > @@ -1123,7 +1160,7 @@ rte_cryptodev_asym_get_header_session_size(void); > * symmetric session > */ > unsigned int > -rte_cryptodev_sym_get_private_session_size(uint8_t dev_id); > +rte_cryptodev_sym_private_session_size(uint8_t dev_id); >=20 > /** > * Get the size of the private data for asymmetric session > diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_crypto= dev/rte_cryptodev_pmd.h > index 6ff49d64d..2f98f65d1 100644 > --- a/lib/librte_cryptodev/rte_cryptodev_pmd.h > +++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h > @@ -191,13 +191,12 @@ typedef void (*cryptodev_info_get_t)(struct rte_cry= ptodev *dev, > * @param qp_id Queue Pair Index > * @param qp_conf Queue configuration structure > * @param socket_id Socket Index > - * @param session_pool Pointer to device session mempool > * > * @return Returns 0 on success. > */ > typedef int (*cryptodev_queue_pair_setup_t)(struct rte_cryptodev *dev, > uint16_t qp_id, const struct rte_cryptodev_qp_conf *qp_conf, > - int socket_id, struct rte_mempool *session_pool); > + int socket_id); >=20 > /** > * Release memory resources allocated by given queue pair. > @@ -478,20 +477,25 @@ RTE_INIT(init_ ##driver_id)\ >=20 > static inline void * > get_sym_session_private_data(const struct rte_cryptodev_sym_session *ses= s, > - uint8_t driver_id) { > - return sess->sess_private_data[driver_id]; > + uint8_t driver_id) > +{ > + if (driver_id < sess->nb_drivers) > + return sess->sess_data[driver_id].data; > + return NULL; > } >=20 > static inline void > set_sym_session_private_data(struct rte_cryptodev_sym_session *sess, > uint8_t driver_id, void *private_data) > { > - sess->sess_private_data[driver_id] =3D private_data; > + if (driver_id < sess->nb_drivers) > + sess->sess_data[driver_id].data =3D private_data; > } >=20 > static inline void * > get_asym_session_private_data(const struct rte_cryptodev_asym_session *s= ess, > - uint8_t driver_id) { > + uint8_t driver_id) > +{ > return sess->sess_private_data[driver_id]; > } >=20 > -- > 2.13.6