[v1] crypto/ccp: bug fixes for ccp device probe flow
Checks
Commit Message
- Fixed flow for probe and initialization of requested ccp devices
- Removed unnecessary code enumerating for all the PCI devices
available in the system.
- Removed ccp_pmd_init_done flag controlling probe and initialization
of only one CCP device even if other CCP devices available
Signed-off-by: Sunil Uttarwar <sunilprakashrao.uttarwar@amd.com>
---
drivers/crypto/ccp/ccp_dev.c | 28 ++++++++++------------------
drivers/crypto/ccp/rte_ccp_pmd.c | 7 -------
2 files changed, 10 insertions(+), 25 deletions(-)
Comments
> - Fixed flow for probe and initialization of requested ccp devices
> - Removed unnecessary code enumerating for all the PCI devices
> available in the system.
> - Removed ccp_pmd_init_done flag controlling probe and initialization
> of only one CCP device even if other CCP devices available
>
> Signed-off-by: Sunil Uttarwar <sunilprakashrao.uttarwar@amd.com>
Hi Sunil,
Kindly work with David for the patch that was not merged and rebase this patch as needed.
Marking this patch as changes requested.
Regards,
Akhil
On Mon, Feb 27, 2023 at 7:29 PM Akhil Goyal <gakhil@marvell.com> wrote:
>
> > - Fixed flow for probe and initialization of requested ccp devices
> > - Removed unnecessary code enumerating for all the PCI devices
> > available in the system.
> > - Removed ccp_pmd_init_done flag controlling probe and initialization
> > of only one CCP device even if other CCP devices available
> >
> > Signed-off-by: Sunil Uttarwar <sunilprakashrao.uttarwar@amd.com>
> Hi Sunil,
>
> Kindly work with David for the patch that was not merged and rebase this patch as needed.
>
> Marking this patch as changes requested.
Sorry, I kept on postponing work on this patch of mine... thanks for
keeping on pinging me Akhil :-).
I sent a v3 which should address Sunil comment.
@@ -683,13 +683,11 @@ ccp_probe_devices(struct rte_pci_device *pci_dev,
{
int dev_cnt = 0;
int ccp_type = 0;
- struct dirent *d;
DIR *dir;
int ret = 0;
int module_idx = 0;
- uint16_t domain;
- uint8_t bus, devid, function;
char dirname[PATH_MAX];
+ char name[RTE_CRYPTODEV_NAME_MAX_LEN];
module_idx = ccp_check_pci_uio_module();
if (module_idx < 0)
@@ -700,21 +698,15 @@ ccp_probe_devices(struct rte_pci_device *pci_dev,
dir = opendir(SYSFS_PCI_DEVICES);
if (dir == NULL)
return -1;
- while ((d = readdir(dir)) != NULL) {
- if (d->d_name[0] == '.')
- continue;
- if (ccp_parse_pci_addr_format(d->d_name, sizeof(d->d_name),
- &domain, &bus, &devid, &function) != 0)
- continue;
- snprintf(dirname, sizeof(dirname), "%s/%s",
- SYSFS_PCI_DEVICES, d->d_name);
- if (is_ccp_device(dirname, ccp_id, &ccp_type)) {
- printf("CCP : Detected CCP device with ID = 0x%x\n",
- ccp_id[ccp_type].device_id);
- ret = ccp_probe_device(ccp_type, pci_dev);
- if (ret == 0)
- dev_cnt++;
- }
+ rte_pci_device_name(&pci_dev->addr, name, sizeof(name));
+ snprintf(dirname, sizeof(dirname), "%s/%s",
+ SYSFS_PCI_DEVICES, name);
+ if (is_ccp_device(dirname, ccp_id, &ccp_type)) {
+ printf("CCP : Detected CCP device with ID = 0x%x\n",
+ ccp_id[ccp_type].device_id);
+ ret = ccp_probe_device(ccp_type, pci_dev);
+ if (ret == 0)
+ dev_cnt++;
}
closedir(dir);
return dev_cnt;
@@ -19,7 +19,6 @@
/**
* Global static parameter used to find if CCP device is already initialized.
*/
-static unsigned int ccp_pmd_init_done;
uint8_t ccp_cryptodev_driver_id;
uint8_t cryptodev_cnt;
extern void *sha_ctx;
@@ -199,7 +198,6 @@ cryptodev_ccp_remove(struct rte_pci_device *pci_dev)
if (dev == NULL)
return -ENODEV;
- ccp_pmd_init_done = 0;
rte_free(sha_ctx);
RTE_LOG(INFO, PMD, "Closing ccp device %s on numa socket %u\n",
@@ -288,10 +286,6 @@ cryptodev_ccp_probe(struct rte_pci_driver *pci_drv __rte_unused,
};
sha_ctx = (void *)rte_malloc(NULL, SHA512_DIGEST_SIZE, 64);
- if (ccp_pmd_init_done) {
- RTE_LOG(INFO, PMD, "CCP PMD already initialized\n");
- return -EFAULT;
- }
rte_pci_device_name(&pci_dev->addr, name, sizeof(name));
if (name[0] == '\0')
return -EINVAL;
@@ -310,7 +304,6 @@ cryptodev_ccp_probe(struct rte_pci_driver *pci_drv __rte_unused,
rc = cryptodev_ccp_create(name, pci_dev, &init_params, pci_drv);
if (rc)
return rc;
- ccp_pmd_init_done = 1;
return 0;
}