DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v1] crypto/ccp:  bug fixes for ccp device probe flow
@ 2022-11-24 13:56 Sunil Uttarwar
  2023-02-27 18:29 ` [EXT] " Akhil Goyal
  2023-03-06 12:58 ` [PATCH v2] " Sunil Uttarwar
  0 siblings, 2 replies; 6+ messages in thread
From: Sunil Uttarwar @ 2022-11-24 13:56 UTC (permalink / raw)
  To: dev; +Cc: selwin.sebastian, Sunil Uttarwar

- 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(-)

diff --git a/drivers/crypto/ccp/ccp_dev.c b/drivers/crypto/ccp/ccp_dev.c
index 424ead82c3..9e3c2d6a63 100644
--- a/drivers/crypto/ccp/ccp_dev.c
+++ b/drivers/crypto/ccp/ccp_dev.c
@@ -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;
diff --git a/drivers/crypto/ccp/rte_ccp_pmd.c b/drivers/crypto/ccp/rte_ccp_pmd.c
index 221a0a5235..ea77d79efc 100644
--- a/drivers/crypto/ccp/rte_ccp_pmd.c
+++ b/drivers/crypto/ccp/rte_ccp_pmd.c
@@ -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;
 }
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-03-14 10:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-24 13:56 [PATCH v1] crypto/ccp: bug fixes for ccp device probe flow Sunil Uttarwar
2023-02-27 18:29 ` [EXT] " Akhil Goyal
2023-03-02 11:53   ` David Marchand
2023-03-06 12:58 ` [PATCH v2] " Sunil Uttarwar
2023-03-11 18:47   ` [EXT] " Akhil Goyal
2023-03-14 10:49     ` Akhil Goyal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).