DPDK patches and discussions
 help / color / mirror / Atom feed
From: Sunil Uttarwar <sunilprakashrao.uttarwar@amd.com>
To: <dev@dpdk.org>
Cc: <selwin.sebastian@amd.com>,
	Sunil Uttarwar <sunilprakashrao.uttarwar@amd.com>
Subject: [PATCH v1] crypto/ccp:  bug fixes for ccp device probe flow
Date: Thu, 24 Nov 2022 19:26:45 +0530	[thread overview]
Message-ID: <20221124135645.5955-1-sunilprakashrao.uttarwar@amd.com> (raw)

- 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


             reply	other threads:[~2022-11-24 13:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-24 13:56 Sunil Uttarwar [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221124135645.5955-1-sunilprakashrao.uttarwar@amd.com \
    --to=sunilprakashrao.uttarwar@amd.com \
    --cc=dev@dpdk.org \
    --cc=selwin.sebastian@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).