From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 84FCDA0C41; Tue, 11 May 2021 08:47:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B935641143; Tue, 11 May 2021 08:46:29 +0200 (CEST) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by mails.dpdk.org (Postfix) with ESMTP id 2E7BC41131 for ; Tue, 11 May 2021 08:46:25 +0200 (CEST) Received: by mail-lf1-f47.google.com with SMTP id m11so10607155lfg.3 for ; Mon, 10 May 2021 23:46:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R2BPzNOlqsMnmqR95sxzbWtPtXDh74knm/Lqz6A19Zc=; b=EISqZXSHn1K7DHsHdZMpxPLA0Vkqu2fwpBcgm5VYPhNOqOrvDjOir+36My/5n8W/J3 od8Sd2zXNwO/35gSGDQiBgVVKimLmshbqEHAzcuBECBTBA0actA/3AsbJ1LzcL21tl1z TRbktRCqhEeviFUcAHNxmrnu/qf+40/oLNN9Tzdsx9ko8bgUSN+kKlTzPCxIbNNG2uME tvb21nSnQhKcJfVsky0/OU0pA/BjU3m8h9tgcC7LPA8pnhJVstD0s2jKfoxcPk19Q9eX N8oxmS7U+zVaeYlljTT86xCuUFatfNgtSw9un1acfVftz2oWx3WbUUx5pGUJAyPbEKZ6 NVYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R2BPzNOlqsMnmqR95sxzbWtPtXDh74knm/Lqz6A19Zc=; b=dGd/CbcLzuTB/5FEpPEKLIkXeX8IV/Ae/tbjZpqP1Teoz2xEdePKVoFLdAEwV75lyd S2ciJI11CsuPhuTHIJSbAjxey3sI4+Dnp+VpN4qOC45TZd9QppfbkuNEhWNGps+gOOKO 2kFImAAaYHZPtJR9iQ8Q8pns2udby1HJmflJO1sEYKC8myC8RJK2BH9VOCB96QNgpRB/ cT4mn5kDBeZtTlNITxASA8ERtOL3KKqp5U0x0QV4n3yFXM4VCiUvktSE56AyLb0G7pec WcwHSy49QkQqwzVaLtadjqhYaKz3MPUsUAx0mzvz5weZPu74gztKmRMqexJGoxpvkl0d jHIQ== X-Gm-Message-State: AOAM5336q/pgf5I5/VCK/5x2CNoUQ1/kxiqaOyjgJRSMvQ8/TFlw2Rfa 0ZGc+TDHMIHLEkZd3mM9fRDvZQ== X-Google-Smtp-Source: ABdhPJznqHfJV70xSFmaKu8FFNbuzkmLCDhPL0CyZtlZ3PjXcRbsLrBZr2Mjo1IDQn2skCqbktR80g== X-Received: by 2002:a05:6512:3056:: with SMTP id b22mr19175164lfb.526.1620715584773; Mon, 10 May 2021 23:46:24 -0700 (PDT) Received: from DESKTOP-U5LNN3J.localdomain (89-79-189-199.dynamic.chello.pl. [89.79.189.199]) by smtp.gmail.com with ESMTPSA id v20sm2496776lfd.92.2021.05.10.23.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 May 2021 23:46:24 -0700 (PDT) From: Michal Krawczyk To: ferruh.yigit@intel.com Cc: dev@dpdk.org, ndagan@amazon.com, gtzalik@amazon.com, igorch@amazon.com, upstream@semihalf.com, Amit Bernstein , Shay Agroskin , Michal Krawczyk Date: Tue, 11 May 2021 08:45:45 +0200 Message-Id: <20210511064554.10656-11-mk@semihalf.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210511064554.10656-1-mk@semihalf.com> References: <87e65a42-4ae5-1a81-8f8e-74759fc14999@intel.com> <20210511064554.10656-1-mk@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 10/19] net/ena/base: adjust changes to lastest ena-com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Amit Bernstein 1. As memzone uses unique names, changed alloc coherent macro to use 64 bit size atomic variable to increase the memzone name space 2. "handle" param name change to be consistent with other macros 3. Variable definition displacement 4. Backslash alignment to column 80 Signed-off-by: Amit Bernstein Reviewed-by: Igor Chauskin Reviewed-by: Shay Agroskin Reviewed-by: Michal Krawczyk --- v4: * Fix multiple checkpatch warnings. drivers/net/ena/base/ena_plat_dpdk.h | 256 +++++++++++++-------------- drivers/net/ena/ena_ethdev.c | 2 +- 2 files changed, 122 insertions(+), 136 deletions(-) diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h index 9d1426da0b..13264d021b 100644 --- a/drivers/net/ena/base/ena_plat_dpdk.h +++ b/drivers/net/ena/base/ena_plat_dpdk.h @@ -34,10 +34,12 @@ typedef uint8_t u8; typedef struct rte_eth_dev ena_netdev; typedef uint64_t dma_addr_t; + #ifndef ETIME #define ETIME ETIMEDOUT #endif +#define ENA_PRIu64 PRIu64 #define ena_atomic32_t rte_atomic32_t #define ena_mem_handle_t const struct rte_memzone * @@ -76,7 +78,7 @@ typedef uint64_t dma_addr_t; #define __iomem #define US_PER_S 1000000 -#define ENA_GET_SYSTEM_USECS() \ +#define ENA_GET_SYSTEM_USECS() \ (rte_get_timer_cycles() * US_PER_S / rte_get_timer_hz()) extern int ena_logtype_com; @@ -95,20 +97,20 @@ extern int ena_logtype_com; #define BIT(nr) (1UL << (nr)) #define BITS_PER_LONG (__SIZEOF_LONG__ * 8) #define GENMASK(h, l) (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) -#define GENMASK_ULL(h, l) (((~0ULL) - (1ULL << (l)) + 1) & \ +#define GENMASK_ULL(h, l) (((~0ULL) - (1ULL << (l)) + 1) & \ (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) #ifdef RTE_LIBRTE_ENA_COM_DEBUG -#define ena_trc_log(dev, level, fmt, arg...) \ - ( \ - ENA_TOUCH(dev), \ - rte_log(RTE_LOG_ ## level, ena_logtype_com, \ - "[ENA_COM: %s]" fmt, __func__, ##arg) \ +#define ena_trc_log(dev, level, fmt, arg...) \ + ( \ + ENA_TOUCH(dev), \ + rte_log(RTE_LOG_ ## level, ena_logtype_com, \ + "[ENA_COM: %s]" fmt, __func__, ##arg) \ ) #define ena_trc_dbg(dev, format, arg...) ena_trc_log(dev, DEBUG, format, ##arg) #define ena_trc_info(dev, format, arg...) ena_trc_log(dev, INFO, format, ##arg) -#define ena_trc_warn(dev, format, arg...) \ +#define ena_trc_warn(dev, format, arg...) \ ena_trc_log(dev, WARNING, format, ##arg) #define ena_trc_err(dev, format, arg...) ena_trc_log(dev, ERR, format, ##arg) #else @@ -118,51 +120,51 @@ extern int ena_logtype_com; #define ena_trc_err(dev, format, arg...) ENA_TOUCH(dev) #endif /* RTE_LIBRTE_ENA_COM_DEBUG */ -#define ENA_WARN(cond, dev, format, arg...) \ - do { \ - if (unlikely(cond)) { \ - ena_trc_err(dev, \ - "Warn failed on %s:%s:%d:" format, \ - __FILE__, __func__, __LINE__, ##arg); \ - } \ +#define ENA_WARN(cond, dev, format, arg...) \ + do { \ + if (unlikely(cond)) { \ + ena_trc_err(dev, \ + "Warn failed on %s:%s:%d:" format, \ + __FILE__, __func__, __LINE__, ##arg); \ + } \ } while (0) /* Spinlock related methods */ #define ena_spinlock_t rte_spinlock_t -#define ENA_SPINLOCK_INIT(spinlock) rte_spinlock_init(&spinlock) -#define ENA_SPINLOCK_LOCK(spinlock, flags) \ - ({(void)flags; rte_spinlock_lock(&spinlock); }) -#define ENA_SPINLOCK_UNLOCK(spinlock, flags) \ +#define ENA_SPINLOCK_INIT(spinlock) rte_spinlock_init(&(spinlock)) +#define ENA_SPINLOCK_LOCK(spinlock, flags) \ + ({(void)flags; rte_spinlock_lock(&(spinlock)); }) +#define ENA_SPINLOCK_UNLOCK(spinlock, flags) \ ({(void)flags; rte_spinlock_unlock(&(spinlock)); }) -#define ENA_SPINLOCK_DESTROY(spinlock) ((void)spinlock) +#define ENA_SPINLOCK_DESTROY(spinlock) ((void)(spinlock)) -#define q_waitqueue_t \ - struct { \ - pthread_cond_t cond; \ - pthread_mutex_t mutex; \ +#define q_waitqueue_t \ + struct { \ + pthread_cond_t cond; \ + pthread_mutex_t mutex; \ } #define ena_wait_queue_t q_waitqueue_t -#define ENA_WAIT_EVENT_INIT(waitqueue) \ - do { \ - pthread_mutex_init(&(waitqueue).mutex, NULL); \ - pthread_cond_init(&(waitqueue).cond, NULL); \ +#define ENA_WAIT_EVENT_INIT(waitqueue) \ + do { \ + pthread_mutex_init(&(waitqueue).mutex, NULL); \ + pthread_cond_init(&(waitqueue).cond, NULL); \ } while (0) -#define ENA_WAIT_EVENT_WAIT(waitevent, timeout) \ - do { \ - struct timespec wait; \ - struct timeval now; \ - unsigned long timeout_us; \ - gettimeofday(&now, NULL); \ - wait.tv_sec = now.tv_sec + timeout / 1000000UL; \ - timeout_us = timeout % 1000000UL; \ - wait.tv_nsec = (now.tv_usec + timeout_us) * 1000UL; \ - pthread_mutex_lock(&waitevent.mutex); \ - pthread_cond_timedwait(&waitevent.cond, \ - &waitevent.mutex, &wait); \ - pthread_mutex_unlock(&waitevent.mutex); \ +#define ENA_WAIT_EVENT_WAIT(waitevent, timeout) \ + do { \ + struct timespec wait; \ + struct timeval now; \ + unsigned long timeout_us; \ + gettimeofday(&now, NULL); \ + wait.tv_sec = now.tv_sec + (timeout) / 1000000UL; \ + timeout_us = (timeout) % 1000000UL; \ + wait.tv_nsec = (now.tv_usec + timeout_us) * 1000UL; \ + pthread_mutex_lock(&(waitevent).mutex); \ + pthread_cond_timedwait(&(waitevent).cond, \ + &(waitevent).mutex, &wait); \ + pthread_mutex_unlock(&(waitevent).mutex); \ } while (0) #define ENA_WAIT_EVENT_SIGNAL(waitevent) pthread_cond_signal(&waitevent.cond) /* pthread condition doesn't need to be rearmed after usage */ @@ -174,104 +176,90 @@ extern int ena_logtype_com; #define ena_time_t uint64_t #define ENA_TIME_EXPIRE(timeout) (timeout < rte_get_timer_cycles()) -#define ENA_GET_SYSTEM_TIMEOUT(timeout_us) \ - (timeout_us * rte_get_timer_hz() / 1000000 + rte_get_timer_cycles()) +#define ENA_GET_SYSTEM_TIMEOUT(timeout_us) \ + ((timeout_us) * rte_get_timer_hz() / 1000000 + rte_get_timer_cycles()) /* * Each rte_memzone should have unique name. * To satisfy it, count number of allocations and add it to name. */ -extern rte_atomic32_t ena_alloc_cnt; - -#define ENA_MEM_ALLOC_COHERENT_ALIGNED( \ - dmadev, size, virt, phys, handle, alignment) \ - do { \ - const struct rte_memzone *mz = NULL; \ - ENA_TOUCH(dmadev); ENA_TOUCH(handle); \ - if (size > 0) { \ - char z_name[RTE_MEMZONE_NAMESIZE]; \ - snprintf(z_name, sizeof(z_name), \ - "ena_alloc_%d", \ - rte_atomic32_add_return(&ena_alloc_cnt, 1)); \ - mz = rte_memzone_reserve_aligned(z_name, size, \ - SOCKET_ID_ANY, \ - RTE_MEMZONE_IOVA_CONTIG, \ - alignment); \ - handle = mz; \ - } \ - if (mz == NULL) { \ - virt = NULL; \ - phys = 0; \ - } else { \ - memset(mz->addr, 0, size); \ - virt = mz->addr; \ - phys = mz->iova; \ - } \ +extern rte_atomic64_t ena_alloc_cnt; + +#define ENA_MEM_ALLOC_COHERENT_ALIGNED( \ + dmadev, size, virt, phys, mem_handle, alignment) \ + do { \ + const struct rte_memzone *mz = NULL; \ + ENA_TOUCH(dmadev); \ + if ((size) > 0) { \ + char z_name[RTE_MEMZONE_NAMESIZE]; \ + snprintf(z_name, sizeof(z_name), \ + "ena_alloc_%" PRIi64 "", \ + rte_atomic64_add_return(&ena_alloc_cnt, 1)); \ + mz = rte_memzone_reserve_aligned(z_name, (size), \ + SOCKET_ID_ANY, RTE_MEMZONE_IOVA_CONTIG,\ + alignment); \ + mem_handle = mz; \ + } \ + if (mz == NULL) { \ + virt = NULL; \ + phys = 0; \ + } else { \ + memset(mz->addr, 0, (size)); \ + virt = mz->addr; \ + phys = mz->iova; \ + } \ } while (0) -#define ENA_MEM_ALLOC_COHERENT(dmadev, size, virt, phys, handle) \ - ENA_MEM_ALLOC_COHERENT_ALIGNED( \ - dmadev, \ - size, \ - virt, \ - phys, \ - handle, \ - RTE_CACHE_LINE_SIZE) -#define ENA_MEM_FREE_COHERENT(dmadev, size, virt, phys, handle) \ - ({ ENA_TOUCH(size); ENA_TOUCH(phys); \ - ENA_TOUCH(dmadev); \ - rte_memzone_free(handle); }) - -#define ENA_MEM_ALLOC_COHERENT_NODE_ALIGNED( \ - dmadev, size, virt, phys, mem_handle, node, dev_node, alignment) \ - do { \ - const struct rte_memzone *mz = NULL; \ - ENA_TOUCH(dmadev); ENA_TOUCH(dev_node); \ - if (size > 0) { \ - char z_name[RTE_MEMZONE_NAMESIZE]; \ - snprintf(z_name, sizeof(z_name), \ - "ena_alloc_%d", \ - rte_atomic32_add_return(&ena_alloc_cnt, 1)); \ - mz = rte_memzone_reserve_aligned(z_name, size, node, \ - RTE_MEMZONE_IOVA_CONTIG, alignment); \ - mem_handle = mz; \ - } \ - if (mz == NULL) { \ - virt = NULL; \ - phys = 0; \ - } else { \ - memset(mz->addr, 0, size); \ - virt = mz->addr; \ - phys = mz->iova; \ - } \ +#define ENA_MEM_ALLOC_COHERENT(dmadev, size, virt, phys, mem_handle) \ + ENA_MEM_ALLOC_COHERENT_ALIGNED(dmadev, size, virt, phys, \ + mem_handle, RTE_CACHE_LINE_SIZE) +#define ENA_MEM_FREE_COHERENT(dmadev, size, virt, phys, mem_handle) \ + ({ ENA_TOUCH(size); ENA_TOUCH(phys); ENA_TOUCH(dmadev); \ + rte_memzone_free(mem_handle); }) + +#define ENA_MEM_ALLOC_COHERENT_NODE_ALIGNED( \ + dmadev, size, virt, phys, mem_handle, node, dev_node, alignment) \ + do { \ + const struct rte_memzone *mz = NULL; \ + ENA_TOUCH(dmadev); ENA_TOUCH(dev_node); \ + if ((size) > 0) { \ + char z_name[RTE_MEMZONE_NAMESIZE]; \ + snprintf(z_name, sizeof(z_name), \ + "ena_alloc_%" PRIi64 "", \ + rte_atomic64_add_return(&ena_alloc_cnt, 1)); \ + mz = rte_memzone_reserve_aligned(z_name, (size), \ + node, RTE_MEMZONE_IOVA_CONTIG, alignment); \ + mem_handle = mz; \ + } \ + if (mz == NULL) { \ + virt = NULL; \ + phys = 0; \ + } else { \ + memset(mz->addr, 0, (size)); \ + virt = mz->addr; \ + phys = mz->iova; \ + } \ } while (0) -#define ENA_MEM_ALLOC_COHERENT_NODE( \ - dmadev, size, virt, phys, mem_handle, node, dev_node) \ - ENA_MEM_ALLOC_COHERENT_NODE_ALIGNED( \ - dmadev, \ - size, \ - virt, \ - phys, \ - mem_handle, \ - node, \ - dev_node, \ - RTE_CACHE_LINE_SIZE) -#define ENA_MEM_ALLOC_NODE(dmadev, size, virt, node, dev_node) \ - do { \ - ENA_TOUCH(dmadev); ENA_TOUCH(dev_node); \ - virt = rte_zmalloc_socket(NULL, size, 0, node); \ +#define ENA_MEM_ALLOC_COHERENT_NODE( \ + dmadev, size, virt, phys, mem_handle, node, dev_node) \ + ENA_MEM_ALLOC_COHERENT_NODE_ALIGNED(dmadev, size, virt, phys, \ + mem_handle, node, dev_node, RTE_CACHE_LINE_SIZE) +#define ENA_MEM_ALLOC_NODE(dmadev, size, virt, node, dev_node) \ + do { \ + ENA_TOUCH(dmadev); ENA_TOUCH(dev_node); \ + virt = rte_zmalloc_socket(NULL, size, 0, node); \ } while (0) #define ENA_MEM_ALLOC(dmadev, size) rte_zmalloc(NULL, size, 1) -#define ENA_MEM_FREE(dmadev, ptr, size) \ +#define ENA_MEM_FREE(dmadev, ptr, size) \ ({ ENA_TOUCH(dmadev); ENA_TOUCH(size); rte_free(ptr); }) #define ENA_DB_SYNC(mem_handle) ((void)mem_handle) -#define ENA_REG_WRITE32(bus, value, reg) \ +#define ENA_REG_WRITE32(bus, value, reg) \ ({ (void)(bus); rte_write32((value), (reg)); }) -#define ENA_REG_WRITE32_RELAXED(bus, value, reg) \ +#define ENA_REG_WRITE32_RELAXED(bus, value, reg) \ ({ (void)(bus); rte_write32_relaxed((value), (reg)); }) -#define ENA_REG_READ32(bus, reg) \ +#define ENA_REG_READ32(bus, reg) \ ({ (void)(bus); rte_read32_relaxed((reg)); }) #define ATOMIC32_INC(i32_ptr) rte_atomic32_inc(i32_ptr) @@ -297,8 +285,8 @@ extern rte_atomic32_t ena_alloc_cnt; #define upper_32_bits(x) ((uint32_t)(((x) >> 16) >> 16)) #define ENA_TIME_EXPIRE(timeout) (timeout < rte_get_timer_cycles()) -#define ENA_GET_SYSTEM_TIMEOUT(timeout_us) \ - (timeout_us * rte_get_timer_hz() / 1000000 + rte_get_timer_cycles()) +#define ENA_GET_SYSTEM_TIMEOUT(timeout_us) \ + ((timeout_us) * rte_get_timer_hz() / 1000000 + rte_get_timer_cycles()) #define ENA_WAIT_EVENTS_DESTROY(admin_queue) ((void)(admin_queue)) #ifndef READ_ONCE @@ -310,14 +298,14 @@ extern rte_atomic32_t ena_alloc_cnt; #define READ_ONCE32(var) READ_ONCE(var) /* The size must be 8 byte align */ -#define ENA_MEMCPY_TO_DEVICE_64(dst, src, size) \ - do { \ - int count, i; \ - uint64_t *to = (uint64_t *)(dst); \ - const uint64_t *from = (const uint64_t *)(src); \ - count = (size) / 8; \ - for (i = 0; i < count; i++, from++, to++) \ - rte_write64_relaxed(*from, to); \ +#define ENA_MEMCPY_TO_DEVICE_64(dst, src, size) \ + do { \ + int count, i; \ + uint64_t *to = (uint64_t *)(dst); \ + const uint64_t *from = (const uint64_t *)(src); \ + count = (size) / 8; \ + for (i = 0; i < count; i++, from++, to++) \ + rte_write64_relaxed(*from, to); \ } while(0) #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) @@ -330,7 +318,5 @@ void ena_rss_key_fill(void *key, size_t size); #define ENA_INTR_INITIAL_TX_INTERVAL_USECS_PLAT 0 -#define ENA_PRIu64 PRIu64 - #include "ena_includes.h" #endif /* DPDK_ENA_COM_ENA_PLAT_DPDK_H_ */ diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c index f1ff4dad36..3c9102cd19 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -85,7 +85,7 @@ struct ena_stats { * Each rte_memzone should have unique name. * To satisfy it, count number of allocation and add it to name. */ -rte_atomic32_t ena_alloc_cnt; +rte_atomic64_t ena_alloc_cnt; static const struct ena_stats ena_stats_global_strings[] = { ENA_STAT_GLOBAL_ENTRY(wd_expired), -- 2.25.1