net/ena: change memory type
authorRafal Kozik <rk@semihalf.com>
Thu, 7 Jun 2018 09:43:19 +0000 (11:43 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 14 Jun 2018 17:27:50 +0000 (19:27 +0200)
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")
Cc: stable@dpdk.org
Signed-off-by: Rafal Kozik <rk@semihalf.com>
Acked-by: Michal Krawczyk <mk@semihalf.com>
drivers/net/ena/base/ena_plat_dpdk.h

index d30153e..22d7a9c 100644 (file)
@@ -248,15 +248,8 @@ extern uint32_t ena_alloc_cnt;
 
 #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,            \
-                               RTE_MEMZONE_IOVA_CONTIG);               \
-               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)