[dpdk-stable] [17.11 3/3] net/ena: change memory type

Rafal Kozik rk at semihalf.com
Fri Jul 27 12:39:06 CEST 2018


[ backported from upstream commit 9f32c7e7e6ce58ab772913f54f8328c1c0186a17 ]

ENA_MEM_ALLOC_NODE not need to use contiguous physical memory.
Also using memset without checking if allocation succeed can cause
segmentation fault.

To avoid both issue use rte_zmalloc_socket.

Fixes: 3d3edc265fc8 ("net/ena: make coherent memory allocation NUMA-aware")

Signed-off-by: Rafal Kozik <rk at semihalf.com>
Acked-by: Michal Krawczyk <mk at semihalf.com>
---
 drivers/net/ena/base/ena_plat_dpdk.h | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
index 362741a..8363fb4 100644
--- a/drivers/net/ena/base/ena_plat_dpdk.h
+++ b/drivers/net/ena/base/ena_plat_dpdk.h
@@ -224,14 +224,8 @@ typedef uint64_t dma_addr_t;
 
 #define ENA_MEM_ALLOC_NODE(dmadev, size, virt, node, dev_node) \
 	do {								\
-		const struct rte_memzone *mz;				\
-		char z_name[RTE_MEMZONE_NAMESIZE];			\
 		ENA_TOUCH(dmadev); ENA_TOUCH(dev_node);			\
-		snprintf(z_name, sizeof(z_name),			\
-				"ena_alloc_%d", ena_alloc_cnt++);	\
-		mz = rte_memzone_reserve(z_name, size, node, 0); \
-		memset(mz->addr, 0, size);				\
-		virt = mz->addr;					\
+		virt = rte_zmalloc_socket(NULL, size, 0, node);		\
 	} while (0)
 
 #define ENA_MEM_ALLOC(dmadev, size) rte_zmalloc(NULL, size, 1)
-- 
2.7.4



More information about the stable mailing list