From 32e1beb19c7e8366ff6ad10d17769c6d0bdcc20a Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Fri, 21 Jan 2022 19:52:39 +0100 Subject: [PATCH 1/3] ena-com: remove redundant declaration of ena_log_level. GCC6 raises a -Wredundant-decl error due to duplicate declarations in ena_fbsd_log.h and ena_plat.h. Sponsored by: Chelsio Communications --- ena_plat.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/ena_plat.h b/ena_plat.h index b3182124839..274f795950c 100644 --- a/ena_plat.h +++ b/ena_plat.h @@ -98,8 +98,6 @@ extern struct ena_bus_space ebs; #define DEFAULT_ALLOC_ALIGNMENT 8 #define ENA_CDESC_RING_SIZE_ALIGNMENT (1 << 12) /* 4K */ -extern int ena_log_level; - #define container_of(ptr, type, member) \ ({ \ const __typeof(((type *)0)->member) *__p = (ptr); \ From 41160c140e31c8ee0d7de4b2f7b9857e6cad57d0 Mon Sep 17 00:00:00 2001 From: Michal Krawczyk Date: Fri, 21 Jan 2022 19:53:40 +0100 Subject: [PATCH 2/3] ena-com: remove CSUM_OFFLOAD from the plat file CSUM_OFFLOAD is a constant which is used only by the core driver code. Because of that it shouldn't be defined in the platform file, as it's not the platform specific code which is used only by the ena_com layer. Submitted by: Dawid Gorecki Submitted by: Michal Krawczyk Obtained from: Semihalf Sponsored by: Amazon, Inc. --- ena_plat.h | 1 - 1 file changed, 1 deletion(-) diff --git a/ena_plat.h b/ena_plat.h index 274f795950c..f92a3754ff8 100644 --- a/ena_plat.h +++ b/ena_plat.h @@ -366,7 +366,6 @@ ena_reg_read32(struct ena_bus *bus, bus_size_t offset) #define time_after(a,b) ((long)((unsigned long)(b) - (unsigned long)(a)) < 0) #define VLAN_HLEN sizeof(struct ether_vlan_header) -#define CSUM_OFFLOAD (CSUM_IP|CSUM_TCP|CSUM_UDP) #define prefetch(x) (void)(x) #define prefetchw(x) (void)(x) From 2530eb1fa01bf28fbcfcdda58bd41e055dcb2e4a Mon Sep 17 00:00:00 2001 From: Artur Rojek Date: Fri, 21 Jan 2022 19:55:36 +0100 Subject: [PATCH 3/3] ena-com: add NUMA allocations macros 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 Submitted by: Dawid Gorecki Submitted by: Michal Krawczyk Obtained from: Semihalf Sponsored by: Amazon, Inc. --- ena_plat.h | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/ena_plat.h b/ena_plat.h index f92a3754ff8..9287532b847 100644 --- a/ena_plat.h +++ b/ena_plat.h @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -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)