Skip to contentSkip to conversation

crypto/ccp: use contiguous allocation for DMA memory

PATCH In review Ravi Kumar 3 participants 3 messages Apr 17, 2018

Subsystems (2)
lore
Share & tools
lore

Ravi Kumar

author
#0 lore raw

PATCH 1/1 crypto/ccp: use contiguous allocation for DMA memory

rte_eal_get_physmem_layout() is obsolete now. This patch fix the broken API usage and allocates DMA memory with RTE_MEMZONE_IOVA_CONTIG memzone flag.

---
 drivers/crypto/ccp/ccp_dev.c | 45 +++++++++++++++++++-------------------------
 1 file changed, 19 insertions(+), 26 deletions(-)
drivers/crypto/ccp/ccp_dev.c +19 -26
index 55cfcdd..80fe6a4 100644
@@ -88,36 +88,29 @@ ccp_queue_dma_zone_reserve(const char *queue_name,
 			   int socket_id)
 {
 	const struct rte_memzone *mz;
-	unsigned int memzone_flags = 0;
-	const struct rte_memseg *ms;
 
 	mz = rte_memzone_lookup(queue_name);
-	if (mz != 0)
-		return mz;
-
-	ms = rte_eal_get_physmem_layout();
-	switch (ms[0].hugepage_sz) {
-	case(RTE_PGSIZE_2M):
-		memzone_flags = RTE_MEMZONE_2MB;
-		break;
-	case(RTE_PGSIZE_1G):
-		memzone_flags = RTE_MEMZONE_1GB;
-		break;
-	case(RTE_PGSIZE_16M):
-		memzone_flags = RTE_MEMZONE_16MB;
-		break;
-	case(RTE_PGSIZE_16G):
-		memzone_flags = RTE_MEMZONE_16GB;
-		break;
-	default:
-		memzone_flags = RTE_MEMZONE_SIZE_HINT_ONLY;
+	if (mz != 0) {
+		if (((size_t)queue_size <= mz->len) &&
+		    ((socket_id == SOCKET_ID_ANY) ||
+		     (socket_id == mz->socket_id))) {
+			CCP_LOG_INFO("re-use memzone already "
+				     "allocated for %s", queue_name);
+			return mz;
+		}
+		CCP_LOG_ERR("Incompatible memzone already "
+			    "allocated %s, size %u, socket %d. "
+			    "Requested size %u, socket %u",
+			    queue_name, (uint32_t)mz->len,
+			    mz->socket_id, queue_size, socket_id);
+		return NULL;
 	}
 
-	return rte_memzone_reserve_aligned(queue_name,
-					   queue_size,
-					   socket_id,
-					   memzone_flags,
-					   queue_size);
+	CCP_LOG_INFO("Allocate memzone for %s, size %u on socket %u",
+		     queue_name, queue_size, socket_id);
+
+	return rte_memzone_reserve_aligned(queue_name, queue_size,
+			socket_id, RTE_MEMZONE_IOVA_CONTIG, queue_size);
 }
 
 /* bitmap support apis */
Signature · 1 line
2.7.4
#2 lore raw
In reply to Ravi Kumar
Quoted 10 lines

-----Original Message-----
From: Ravi Kumar [mailto:[email protected]]
Sent: Tuesday, April 17, 2018 11:32 AM
To: [email protected]
Cc: De Lara Guarch, Pablo <[email protected]>; [email protected]
Subject: [PATCH v1] crypto/ccp: use contiguous allocation for DMA memory

Quoted 5 lines

rte_eal_get_physmem_layout() is obsolete now.
This patch fix the broken API usage and allocates DMA memory with RTE_MEMZONE_IOVA_CONTIG memzone flag.

Squashed into second commit of the AMD CCP patchset and applied to dpdk-next-crypto.

Thanks for the quick patch!
Pablo