> > Hi Julien > > > > > Each cryptodev are indexed with its dev_id in the global > > rte_crypto_devices variable. nb_devs is incremented / decremented each > > time a cryptodev is created / deleted. The goal of nb_devs is to prevent > > the user to get an invalid dev_id. > > > > Let's imagine DPDK has configured N cryptodevs. If the cryptodev=1 is > > removed at runtime, the latest cryptodev N cannot be accessible, because > > nb_devs=N-1. > > > > In order to prevent this kind of behavior, let's remove the check with > > nb_devs and iterate in all the rte_crypto_devices elements: if data is > > not NULL, that means a valid cryptodev is available. > > > > Fixes: d11b0f30df88 ("cryptodev: introduce API and framework for crypto > > devices") > > Cc: sta...@dpdk.org > > > > Signed-off-by: Julien Meunier <julien.meun...@nokia.com> > > --- // snip//
> > @@ -560,7 +570,13 @@ rte_cryptodev_get_dev_id(const char *name) > > uint8_t > > rte_cryptodev_count(void) > > { > > - return cryptodev_globals.nb_devs; > > + uint8_t i, dev_count = 0; > > + > > + for (i = 0; i < RTE_CRYPTO_MAX_DEVS; i++) > > + if (cryptodev_globals.devs[i].data != NULL) > > + dev_count++; > > + > > + return dev_count; > > } > > Why do you want to remove the nb_devs? We can have it updated > (incremented/decremented) > While allocate/release of the device. > The point is, whenever somebody call rte_cryptodev_count() it will do a lookup > of valid data > pointer. Could you please do the requested change. This patch need to be integrated by this week. Thanks.