aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Rojek <ar@semihalf.com>2022-01-21 18:55:36 +0000
committerMarcin Wojtas <mw@FreeBSD.org>2022-01-21 18:57:04 +0000
commit2530eb1fa01bf28fbcfcdda58bd41e055dcb2e4a (patch)
treee2ca722985c7b80989ad96b009a20d8ae547c3b0
parent41160c140e31c8ee0d7de4b2f7b9857e6cad57d0 (diff)
downloadsrc-2530eb1fa01bf28fbcfcdda58bd41e055dcb2e4a.tar.gz
src-2530eb1fa01bf28fbcfcdda58bd41e055dcb2e4a.zip
ena-com: add NUMA allocations macrosvendor/ena-com/2.5.0
Add implementation for the ENA_MEM_ALLOC_NODE and ENA_MEM_ALLOC_COHERENT_NODE_* macros. Also the signature of ena_dma_alloc() function was updated, for which the implementation will be updated in ENA driver's patch. Submitted by: Artur Rojek <ar@semihalf.com> Submitted by: Dawid Gorecki <dgr@semihalf.com> Submitted by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc.
-rw-r--r--ena_plat.h25
1 files changed, 20 insertions, 5 deletions
diff --git a/ena_plat.h b/ena_plat.h
index f92a3754ff8c..9287532b8476 100644
--- a/ena_plat.h
+++ b/ena_plat.h
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/condvar.h>
+#include <sys/domainset.h>
#include <sys/endian.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
@@ -170,6 +171,8 @@ static inline long PTR_ERR(const void *ptr)
#define ENA_COM_TIMER_EXPIRED ETIMEDOUT
#define ENA_COM_EIO EIO
+#define ENA_NODE_ANY (-1)
+
#define ENA_MSLEEP(x) pause_sbt("ena", SBT_1MS * (x), SBT_1MS, 0)
#define ENA_USLEEP(x) pause_sbt("ena", SBT_1US * (x), SBT_1US, 0)
#define ENA_UDELAY(x) DELAY(x)
@@ -277,7 +280,7 @@ typedef struct ifnet ena_netdev;
void ena_dmamap_callback(void *arg, bus_dma_segment_t *segs, int nseg,
int error);
int ena_dma_alloc(device_t dmadev, bus_size_t size, ena_mem_handle_t *dma,
- int mapflags, bus_size_t alignment);
+ int mapflags, bus_size_t alignment, int domain);
static inline uint32_t
ena_reg_read32(struct ena_bus *bus, bus_size_t offset)
@@ -299,16 +302,27 @@ ena_reg_read32(struct ena_bus *bus, bus_size_t offset)
} while (0)
#define ENA_MEM_ALLOC(dmadev, size) malloc(size, M_DEVBUF, M_NOWAIT | M_ZERO)
-#define ENA_MEM_ALLOC_NODE(dmadev, size, virt, node, dev_node) (virt = NULL)
+
+#define ENA_MEM_ALLOC_NODE(dmadev, size, virt, node, dev_node) \
+ do { \
+ (virt) = malloc_domainset((size), M_DEVBUF, \
+ (node) < 0 ? DOMAINSET_RR() : DOMAINSET_PREF(node), \
+ M_NOWAIT | M_ZERO); \
+ (void)(dev_node); \
+ } while (0)
+
#define ENA_MEM_FREE(dmadev, ptr, size) \
do { \
(void)(size); \
free(ptr, M_DEVBUF); \
} while (0)
#define ENA_MEM_ALLOC_COHERENT_NODE_ALIGNED(dmadev, size, virt, phys, \
- handle, node, dev_node, alignment) \
+ dma, node, dev_node, alignment) \
do { \
- ((virt) = NULL); \
+ ena_dma_alloc((dmadev), (size), &(dma), 0, (alignment), \
+ (node)); \
+ (virt) = (void *)(dma).vaddr; \
+ (phys) = (dma).paddr; \
(void)(dev_node); \
} while (0)
@@ -320,7 +334,8 @@ ena_reg_read32(struct ena_bus *bus, bus_size_t offset)
#define ENA_MEM_ALLOC_COHERENT_ALIGNED(dmadev, size, virt, phys, dma, \
alignment) \
do { \
- ena_dma_alloc((dmadev), (size), &(dma), 0, alignment); \
+ ena_dma_alloc((dmadev), (size), &(dma), 0, (alignment), \
+ ENA_NODE_ANY); \
(virt) = (void *)(dma).vaddr; \
(phys) = (dma).paddr; \
} while (0)