Skip to contentSkip to conversation

crypto/ccp: moving vdev to PCI driver

PATCH Superseded [email protected] 1 participant 3 messages Jul 16, 2021

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto/ccp: moving vdev to PCI driver

From: Amaranath Somalapuram <[email protected]>

drop all the code duplicating the PCI bus driver
develped for Enable IOMMU in vdev.

---
 drivers/crypto/ccp/ccp_dev.c     |  67 ++-----------
 drivers/crypto/ccp/ccp_dev.h     |   3 +-
 drivers/crypto/ccp/rte_ccp_pmd.c | 156 +++++++------------------------
 3 files changed, 41 insertions(+), 185 deletions(-)
drivers/crypto/ccp/ccp_dev.c +6 -61
index ee6882b8a4..be2cefbec9 100644
@@ -604,6 +604,7 @@ ccp_add_device(struct ccp_device *dev, int type)
 	}
 
 	TAILQ_INSERT_TAIL(&ccp_list, dev, next);
+
 	return 0;
 }
 
@@ -650,73 +651,17 @@ is_ccp_device(const char *dirname,
 }
 
 static int
-ccp_probe_device(const char *dirname, uint16_t domain,
-		 uint8_t bus, uint8_t devid,
-		 uint8_t function, int ccp_type)
+ccp_probe_device(int ccp_type, struct rte_pci_device *pci_dev)
 {
 	struct ccp_device *ccp_dev = NULL;
-	struct rte_pci_device *pci;
-	char filename[PATH_MAX];
-	unsigned long tmp;
 	int uio_fd = -1;
 
 	ccp_dev = rte_zmalloc("ccp_device", sizeof(*ccp_dev),
 			      RTE_CACHE_LINE_SIZE);
 	if (ccp_dev == NULL)
 		goto fail;
-	pci = &(ccp_dev->pci);
-
-	pci->addr.domain = domain;
-	pci->addr.bus = bus;
-	pci->addr.devid = devid;
-	pci->addr.function = function;
-
-	/* get vendor id */
-	snprintf(filename, sizeof(filename), "%s/vendor", dirname);
-	if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
-		goto fail;
-	pci->id.vendor_id = (uint16_t)tmp;
-
-	/* get device id */
-	snprintf(filename, sizeof(filename), "%s/device", dirname);
-	if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
-		goto fail;
-	pci->id.device_id = (uint16_t)tmp;
-
-	/* get subsystem_vendor id */
-	snprintf(filename, sizeof(filename), "%s/subsystem_vendor",
-			dirname);
-	if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
-		goto fail;
-	pci->id.subsystem_vendor_id = (uint16_t)tmp;
-
-	/* get subsystem_device id */
-	snprintf(filename, sizeof(filename), "%s/subsystem_device",
-			dirname);
-	if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
-		goto fail;
-	pci->id.subsystem_device_id = (uint16_t)tmp;
-
-	/* get class_id */
-	snprintf(filename, sizeof(filename), "%s/class",
-			dirname);
-	if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
-		goto fail;
-	/* the least 24 bits are valid: class, subclass, program interface */
-	pci->id.class_id = (uint32_t)tmp & RTE_CLASS_ANY_ID;
-
-	/* parse resources */
-	snprintf(filename, sizeof(filename), "%s/resource", dirname);
-	if (ccp_pci_parse_sysfs_resource(filename, pci) < 0)
-		goto fail;
-	if (iommu_mode == 2)
-		pci->kdrv = RTE_PCI_KDRV_VFIO;
-	else if (iommu_mode == 0)
-		pci->kdrv = RTE_PCI_KDRV_IGB_UIO;
-	else if (iommu_mode == 1)
-		pci->kdrv = RTE_PCI_KDRV_UIO_GENERIC;
 
-	rte_pci_map_device(pci);
+	ccp_dev->pci = *pci_dev;
 
 	/* device is valid, add in list */
 	if (ccp_add_device(ccp_dev, ccp_type)) {
@@ -735,7 +680,8 @@ ccp_probe_device(const char *dirname, uint16_t domain,
 }
 
 int
-ccp_probe_devices(const struct rte_pci_id *ccp_id)
+ccp_probe_devices(struct rte_pci_device *pci_dev,
+		const struct rte_pci_id *ccp_id)
 {
 	int dev_cnt = 0;
 	int ccp_type = 0;
@@ -767,8 +713,7 @@ ccp_probe_devices(const struct rte_pci_id *ccp_id)
 		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(dirname, domain, bus, devid,
-					       function, ccp_type);
+			ret = ccp_probe_device(ccp_type, pci_dev);
 			if (ret == 0)
 				dev_cnt++;
 		}
drivers/crypto/ccp/ccp_dev.h +2 -1
index 37e04218ce..ca5145c278 100644
@@ -473,7 +473,8 @@ int ccp_dev_start(struct rte_cryptodev *dev);
  * @param ccp_id rte_pci_id list for supported CCP devices
  * @return no. of successfully initialized CCP devices
  */
-int ccp_probe_devices(const struct rte_pci_id *ccp_id);
+int ccp_probe_devices(struct rte_pci_device *pci_dev,
+		const struct rte_pci_id *ccp_id);
 
 /**
  * allocate a ccp command queue
drivers/crypto/ccp/rte_ccp_pmd.c +33 -123

247 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/1 crypto/ccp: moving vdev to PCI driver

From: Amaranath Somalapuram <[email protected]>

drop all the code duplicating the PCI bus driver
develped for Enable IOMMU in vdev.

---
 drivers/crypto/ccp/ccp_dev.c     |  66 +------------
 drivers/crypto/ccp/ccp_dev.h     |   3 +-
 drivers/crypto/ccp/rte_ccp_pmd.c | 158 +++++++------------------------
 3 files changed, 41 insertions(+), 186 deletions(-)
drivers/crypto/ccp/ccp_dev.c +5 -61
index ee6882b8a4..0eb1b0328e 100644
@@ -650,73 +650,17 @@ is_ccp_device(const char *dirname,
 }
 
 static int
-ccp_probe_device(const char *dirname, uint16_t domain,
-		 uint8_t bus, uint8_t devid,
-		 uint8_t function, int ccp_type)
+ccp_probe_device(int ccp_type, struct rte_pci_device *pci_dev)
 {
 	struct ccp_device *ccp_dev = NULL;
-	struct rte_pci_device *pci;
-	char filename[PATH_MAX];
-	unsigned long tmp;
 	int uio_fd = -1;
 
 	ccp_dev = rte_zmalloc("ccp_device", sizeof(*ccp_dev),
 			      RTE_CACHE_LINE_SIZE);
 	if (ccp_dev == NULL)
 		goto fail;
-	pci = &(ccp_dev->pci);
-
-	pci->addr.domain = domain;
-	pci->addr.bus = bus;
-	pci->addr.devid = devid;
-	pci->addr.function = function;
-
-	/* get vendor id */
-	snprintf(filename, sizeof(filename), "%s/vendor", dirname);
-	if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
-		goto fail;
-	pci->id.vendor_id = (uint16_t)tmp;
-
-	/* get device id */
-	snprintf(filename, sizeof(filename), "%s/device", dirname);
-	if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
-		goto fail;
-	pci->id.device_id = (uint16_t)tmp;
-
-	/* get subsystem_vendor id */
-	snprintf(filename, sizeof(filename), "%s/subsystem_vendor",
-			dirname);
-	if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
-		goto fail;
-	pci->id.subsystem_vendor_id = (uint16_t)tmp;
-
-	/* get subsystem_device id */
-	snprintf(filename, sizeof(filename), "%s/subsystem_device",
-			dirname);
-	if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
-		goto fail;
-	pci->id.subsystem_device_id = (uint16_t)tmp;
-
-	/* get class_id */
-	snprintf(filename, sizeof(filename), "%s/class",
-			dirname);
-	if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
-		goto fail;
-	/* the least 24 bits are valid: class, subclass, program interface */
-	pci->id.class_id = (uint32_t)tmp & RTE_CLASS_ANY_ID;
-
-	/* parse resources */
-	snprintf(filename, sizeof(filename), "%s/resource", dirname);
-	if (ccp_pci_parse_sysfs_resource(filename, pci) < 0)
-		goto fail;
-	if (iommu_mode == 2)
-		pci->kdrv = RTE_PCI_KDRV_VFIO;
-	else if (iommu_mode == 0)
-		pci->kdrv = RTE_PCI_KDRV_IGB_UIO;
-	else if (iommu_mode == 1)
-		pci->kdrv = RTE_PCI_KDRV_UIO_GENERIC;
 
-	rte_pci_map_device(pci);
+	ccp_dev->pci = *pci_dev;
 
 	/* device is valid, add in list */
 	if (ccp_add_device(ccp_dev, ccp_type)) {
@@ -735,7 +679,8 @@ ccp_probe_device(const char *dirname, uint16_t domain,
 }
 
 int
-ccp_probe_devices(const struct rte_pci_id *ccp_id)
+ccp_probe_devices(struct rte_pci_device *pci_dev,
+		const struct rte_pci_id *ccp_id)
 {
 	int dev_cnt = 0;
 	int ccp_type = 0;
@@ -767,8 +712,7 @@ ccp_probe_devices(const struct rte_pci_id *ccp_id)
 		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(dirname, domain, bus, devid,
-					       function, ccp_type);
+			ret = ccp_probe_device(ccp_type, pci_dev);
 			if (ret == 0)
 				dev_cnt++;
 		}
drivers/crypto/ccp/ccp_dev.h +2 -1
index 37e04218ce..ca5145c278 100644
@@ -473,7 +473,8 @@ int ccp_dev_start(struct rte_cryptodev *dev);
  * @param ccp_id rte_pci_id list for supported CCP devices
  * @return no. of successfully initialized CCP devices
  */
-int ccp_probe_devices(const struct rte_pci_id *ccp_id);
+int ccp_probe_devices(struct rte_pci_device *pci_dev,
+		const struct rte_pci_id *ccp_id);
 
 /**
  * allocate a ccp command queue
drivers/crypto/ccp/rte_ccp_pmd.c +34 -124

248 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

PATCH v3 1/1 crypto/ccp: moving vdev to PCI driver

From: Amaranath Somalapuram <[email protected]>

drop all the code duplicating the PCI bus driver
develped for Enable IOMMU in vdev.

---
 drivers/crypto/ccp/ccp_dev.c     |  66 +------------
 drivers/crypto/ccp/ccp_dev.h     |   3 +-
 drivers/crypto/ccp/rte_ccp_pmd.c | 158 +++++++------------------------
 3 files changed, 41 insertions(+), 186 deletions(-)
drivers/crypto/ccp/ccp_dev.c +5 -61
index ee6882b8a4..0eb1b0328e 100644
@@ -650,73 +650,17 @@ is_ccp_device(const char *dirname,
 }
 
 static int
-ccp_probe_device(const char *dirname, uint16_t domain,
-		 uint8_t bus, uint8_t devid,
-		 uint8_t function, int ccp_type)
+ccp_probe_device(int ccp_type, struct rte_pci_device *pci_dev)
 {
 	struct ccp_device *ccp_dev = NULL;
-	struct rte_pci_device *pci;
-	char filename[PATH_MAX];
-	unsigned long tmp;
 	int uio_fd = -1;
 
 	ccp_dev = rte_zmalloc("ccp_device", sizeof(*ccp_dev),
 			      RTE_CACHE_LINE_SIZE);
 	if (ccp_dev == NULL)
 		goto fail;
-	pci = &(ccp_dev->pci);
-
-	pci->addr.domain = domain;
-	pci->addr.bus = bus;
-	pci->addr.devid = devid;
-	pci->addr.function = function;
-
-	/* get vendor id */
-	snprintf(filename, sizeof(filename), "%s/vendor", dirname);
-	if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
-		goto fail;
-	pci->id.vendor_id = (uint16_t)tmp;
-
-	/* get device id */
-	snprintf(filename, sizeof(filename), "%s/device", dirname);
-	if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
-		goto fail;
-	pci->id.device_id = (uint16_t)tmp;
-
-	/* get subsystem_vendor id */
-	snprintf(filename, sizeof(filename), "%s/subsystem_vendor",
-			dirname);
-	if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
-		goto fail;
-	pci->id.subsystem_vendor_id = (uint16_t)tmp;
-
-	/* get subsystem_device id */
-	snprintf(filename, sizeof(filename), "%s/subsystem_device",
-			dirname);
-	if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
-		goto fail;
-	pci->id.subsystem_device_id = (uint16_t)tmp;
-
-	/* get class_id */
-	snprintf(filename, sizeof(filename), "%s/class",
-			dirname);
-	if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
-		goto fail;
-	/* the least 24 bits are valid: class, subclass, program interface */
-	pci->id.class_id = (uint32_t)tmp & RTE_CLASS_ANY_ID;
-
-	/* parse resources */
-	snprintf(filename, sizeof(filename), "%s/resource", dirname);
-	if (ccp_pci_parse_sysfs_resource(filename, pci) < 0)
-		goto fail;
-	if (iommu_mode == 2)
-		pci->kdrv = RTE_PCI_KDRV_VFIO;
-	else if (iommu_mode == 0)
-		pci->kdrv = RTE_PCI_KDRV_IGB_UIO;
-	else if (iommu_mode == 1)
-		pci->kdrv = RTE_PCI_KDRV_UIO_GENERIC;
 
-	rte_pci_map_device(pci);
+	ccp_dev->pci = *pci_dev;
 
 	/* device is valid, add in list */
 	if (ccp_add_device(ccp_dev, ccp_type)) {
@@ -735,7 +679,8 @@ ccp_probe_device(const char *dirname, uint16_t domain,
 }
 
 int
-ccp_probe_devices(const struct rte_pci_id *ccp_id)
+ccp_probe_devices(struct rte_pci_device *pci_dev,
+		const struct rte_pci_id *ccp_id)
 {
 	int dev_cnt = 0;
 	int ccp_type = 0;
@@ -767,8 +712,7 @@ ccp_probe_devices(const struct rte_pci_id *ccp_id)
 		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(dirname, domain, bus, devid,
-					       function, ccp_type);
+			ret = ccp_probe_device(ccp_type, pci_dev);
 			if (ret == 0)
 				dev_cnt++;
 		}
drivers/crypto/ccp/ccp_dev.h +2 -1
index 37e04218ce..ca5145c278 100644
@@ -473,7 +473,8 @@ int ccp_dev_start(struct rte_cryptodev *dev);
  * @param ccp_id rte_pci_id list for supported CCP devices
  * @return no. of successfully initialized CCP devices
  */
-int ccp_probe_devices(const struct rte_pci_id *ccp_id);
+int ccp_probe_devices(struct rte_pci_device *pci_dev,
+		const struct rte_pci_id *ccp_id);
 
 /**
  * allocate a ccp command queue
drivers/crypto/ccp/rte_ccp_pmd.c +34 -124

248 lines not on this page · raw message

Signature · 1 line
2.25.1