Skip to contentSkip to conversation

net/ena: update ENA PMD to v2.3.0

PATCH Superseded Michal Krawczyk 4 participants 121 messages Apr 30, 2021 – May 12, 2021 Network drivers Page 1 of 2

lore
Share & tools
lore
#0 lore raw

cover net/ena: update ENA PMD to v2.3.0

Hi,

this version updates the driver to version 2.3.0, which fixes multiple bugs, contains part of the work on making the ENA PMD fully MP aware, and also updates HAL to the latest version.

More detailed list of changes:
* memcpy mapping to the dpdk-optimized version.
* ena_com (HAL) update to the latest version.
* Bug fixes for the the large LLQ headers and devargs parsing.
* Mbuf RSS hash presence indication.
* Bug fix for the default ring size.
* Various fixes for the SMP mode.

Amit Bernstein (1):
net/ena/base: adjust changes to lastest ena-com

Igor Chauskin (2):
net/ena: switch memcpy to dpdk-optimized version net/ena: fix parsing of large_llq_hdr argument

Michal Krawczyk (12):
net/ena/base: unify arg names for the functions net/ena/base: add dev arg to the logging macros net/ena/base: typos, style and comments improvements net/ena/base: fix issues from the static code scan net/ena/base: destroy multiple "wait events" net/ena/base: remove indir table from ENA feat ctx net/ena/base: remove mutable RSS from the host info net/ena/base: update generation date and commit net/ena/base: use rte_prefetch0_write net/ena: terminate devargs allowed keys with NULL net/ena: indicate Rx RSS hash presence net/ena: update version to v2.3.0

Stanislaw Kardach (7):
net/ena: remove endian swap functions net/ena: handle spurious wakeups in ENA_WAIT_EVENT net/ena: support SMP for mz alloc counter net/ena: move default RSS key to shared mem net/ena: make ethdev references smp safe net/ena: disable dev_ops not supported in SMP net/ena: report default ring size

 doc/guides/rel_notes/release_21_05.rst        |  13 +
 drivers/net/ena/base/ena_com.c                | 379 +++++++++---------
 drivers/net/ena/base/ena_com.h                |  24 +-
 .../net/ena/base/ena_defs/ena_admin_defs.h    |  98 ++---
 drivers/net/ena/base/ena_defs/ena_gen_info.h  |   4 +-
 drivers/net/ena/base/ena_eth_com.c            |  94 +++--
 drivers/net/ena/base/ena_eth_com.h            |  17 +-
 drivers/net/ena/base/ena_plat_dpdk.h          | 321 ++++++++-------
 drivers/net/ena/ena_ethdev.c                  | 156 ++++---
 drivers/net/ena/ena_ethdev.h                  |  14 +-
 drivers/net/ena/ena_platform.h                |  12 -
 11 files changed, 633 insertions(+), 499 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/22 net/ena: switch memcpy to dpdk-optimized version

From: Igor Chauskin <[email protected]>

memcpy is now mapped to rte_memcpy macro.

Fixes 9ba7981ec992 ("ena: add communication layer for DPDK")
---
 drivers/net/ena/base/ena_plat_dpdk.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ena/base/ena_plat_dpdk.h +3 -1
index a1d749f83f..cc3fa2fe81 100644
@@ -25,6 +25,7 @@
 #include <rte_spinlock.h>
 
 #include <sys/time.h>
+#include <rte_memcpy.h>
 
 typedef uint64_t u64;
 typedef uint32_t u32;
@@ -62,7 +63,8 @@ typedef uint64_t dma_addr_t;
 #define ENA_UDELAY(x) rte_delay_us_block(x)
 
 #define ENA_TOUCH(x) ((void)(x))
-#define memcpy_toio memcpy
+#undef memcpy
+#define memcpy rte_memcpy
 #define wmb rte_wmb
 #define rmb rte_rmb
 #define mb rte_mb
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/22 net/ena/base: unify arg names for the functions

In reply to Michal Krawczyk

Instead of using 'queue' for struct ena_com_admin_queue and 'dev' for struct ena_com_dev variables, use more descriptive 'admin_queue' and 'ena_dev'.

This also unifies the names of variables of the type struct ena_com_dev in the driver.

---
 drivers/net/ena/base/ena_com.c | 74 +++++++++++++++++-----------------
 drivers/net/ena/base/ena_com.h |  2 +-
 2 files changed, 38 insertions(+), 38 deletions(-)
drivers/net/ena/base/ena_com.c +37 -37
index aae68721fb..f7258254a5 100644
@@ -80,12 +80,12 @@ static int ena_com_mem_addr_set(struct ena_com_dev *ena_dev,
 	return 0;
 }
 
-static int ena_com_admin_init_sq(struct ena_com_admin_queue *queue)
+static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue)
 {
-	struct ena_com_admin_sq *sq = &queue->sq;
-	u16 size = ADMIN_SQ_SIZE(queue->q_depth);
+	struct ena_com_admin_sq *sq = &admin_queue->sq;
+	u16 size = ADMIN_SQ_SIZE(admin_queue->q_depth);
 
-	ENA_MEM_ALLOC_COHERENT(queue->q_dmadev, size, sq->entries, sq->dma_addr,
+	ENA_MEM_ALLOC_COHERENT(admin_queue->q_dmadev, size, sq->entries, sq->dma_addr,
 			       sq->mem_handle);
 
 	if (!sq->entries) {
@@ -102,12 +102,12 @@ static int ena_com_admin_init_sq(struct ena_com_admin_queue *queue)
 	return 0;
 }
 
-static int ena_com_admin_init_cq(struct ena_com_admin_queue *queue)
+static int ena_com_admin_init_cq(struct ena_com_admin_queue *admin_queue)
 {
-	struct ena_com_admin_cq *cq = &queue->cq;
-	u16 size = ADMIN_CQ_SIZE(queue->q_depth);
+	struct ena_com_admin_cq *cq = &admin_queue->cq;
+	u16 size = ADMIN_CQ_SIZE(admin_queue->q_depth);
 
-	ENA_MEM_ALLOC_COHERENT(queue->q_dmadev, size, cq->entries, cq->dma_addr,
+	ENA_MEM_ALLOC_COHERENT(admin_queue->q_dmadev, size, cq->entries, cq->dma_addr,
 			       cq->mem_handle);
 
 	if (!cq->entries)  {
@@ -121,16 +121,16 @@ static int ena_com_admin_init_cq(struct ena_com_admin_queue *queue)
 	return 0;
 }
 
-static int ena_com_admin_init_aenq(struct ena_com_dev *dev,
+static int ena_com_admin_init_aenq(struct ena_com_dev *ena_dev,
 				   struct ena_aenq_handlers *aenq_handlers)
 {
-	struct ena_com_aenq *aenq = &dev->aenq;
+	struct ena_com_aenq *aenq = &ena_dev->aenq;
 	u32 addr_low, addr_high, aenq_caps;
 	u16 size;
 
-	dev->aenq.q_depth = ENA_ASYNC_QUEUE_DEPTH;
+	ena_dev->aenq.q_depth = ENA_ASYNC_QUEUE_DEPTH;
 	size = ADMIN_AENQ_SIZE(ENA_ASYNC_QUEUE_DEPTH);
-	ENA_MEM_ALLOC_COHERENT(dev->dmadev, size,
+	ENA_MEM_ALLOC_COHERENT(ena_dev->dmadev, size,
 			aenq->entries,
 			aenq->dma_addr,
 			aenq->mem_handle);
@@ -146,15 +146,15 @@ static int ena_com_admin_init_aenq(struct ena_com_dev *dev,
 	addr_low = ENA_DMA_ADDR_TO_UINT32_LOW(aenq->dma_addr);
 	addr_high = ENA_DMA_ADDR_TO_UINT32_HIGH(aenq->dma_addr);
 
-	ENA_REG_WRITE32(dev->bus, addr_low, dev->reg_bar + ENA_REGS_AENQ_BASE_LO_OFF);
-	ENA_REG_WRITE32(dev->bus, addr_high, dev->reg_bar + ENA_REGS_AENQ_BASE_HI_OFF);
+	ENA_REG_WRITE32(ena_dev->bus, addr_low, ena_dev->reg_bar + ENA_REGS_AENQ_BASE_LO_OFF);
+	ENA_REG_WRITE32(ena_dev->bus, addr_high, ena_dev->reg_bar + ENA_REGS_AENQ_BASE_HI_OFF);
 
 	aenq_caps = 0;
-	aenq_caps |= dev->aenq.q_depth & ENA_REGS_AENQ_CAPS_AENQ_DEPTH_MASK;
+	aenq_caps |= ena_dev->aenq.q_depth & ENA_REGS_AENQ_CAPS_AENQ_DEPTH_MASK;
 	aenq_caps |= (sizeof(struct ena_admin_aenq_entry) <<
 		ENA_REGS_AENQ_CAPS_AENQ_ENTRY_SIZE_SHIFT) &
 		ENA_REGS_AENQ_CAPS_AENQ_ENTRY_SIZE_MASK;
-	ENA_REG_WRITE32(dev->bus, aenq_caps, dev->reg_bar + ENA_REGS_AENQ_CAPS_OFF);
+	ENA_REG_WRITE32(ena_dev->bus, aenq_caps, ena_dev->reg_bar + ENA_REGS_AENQ_CAPS_OFF);
 
 	if (unlikely(!aenq_handlers)) {
 		ena_trc_err("aenq handlers pointer is NULL\n");
@@ -173,31 +173,31 @@ static void comp_ctxt_release(struct ena_com_admin_queue *queue,
 	ATOMIC32_DEC(&queue->outstanding_cmds);
 }
 
-static struct ena_comp_ctx *get_comp_ctxt(struct ena_com_admin_queue *queue,
+static struct ena_comp_ctx *get_comp_ctxt(struct ena_com_admin_queue *admin_queue,
 					  u16 command_id, bool capture)
 {
-	if (unlikely(command_id >= queue->q_depth)) {
+	if (unlikely(command_id >= admin_queue->q_depth)) {
 		ena_trc_err("command id is larger than the queue size. cmd_id: %u queue size %d\n",
-			    command_id, queue->q_depth);
+			    command_id, admin_queue->q_depth);
 		return NULL;
 	}
 
-	if (unlikely(!queue->comp_ctx)) {
+	if (unlikely(!admin_queue->comp_ctx)) {
 		ena_trc_err("Completion context is NULL\n");
 		return NULL;
 	}
 
-	if (unlikely(queue->comp_ctx[command_id].occupied && capture)) {
+	if (unlikely(admin_queue->comp_ctx[command_id].occupied && capture)) {
 		ena_trc_err("Completion context is occupied\n");
 		return NULL;
 	}
 
 	if (capture) {
-		ATOMIC32_INC(&queue->outstanding_cmds);
-		queue->comp_ctx[command_id].occupied = true;
+		ATOMIC32_INC(&admin_queue->outstanding_cmds);
+		admin_queue->comp_ctx[command_id].occupied = true;
 	}
 
-	return &queue->comp_ctx[command_id];
+	return &admin_queue->comp_ctx[command_id];
 }
 
 static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queue *admin_queue,
@@ -260,20 +260,20 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queu
 	return comp_ctx;
 }
 
-static int ena_com_init_comp_ctxt(struct ena_com_admin_queue *queue)
+static int ena_com_init_comp_ctxt(struct ena_com_admin_queue *admin_queue)
 {
-	size_t size = queue->q_depth * sizeof(struct ena_comp_ctx);
+	size_t size = admin_queue->q_depth * sizeof(struct ena_comp_ctx);
 	struct ena_comp_ctx *comp_ctx;
 	u16 i;
 
-	queue->comp_ctx = ENA_MEM_ALLOC(queue->q_dmadev, size);
-	if (unlikely(!queue->comp_ctx)) {
+	admin_queue->comp_ctx = ENA_MEM_ALLOC(admin_queue->q_dmadev, size);
+	if (unlikely(!admin_queue->comp_ctx)) {
 		ena_trc_err("memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
-	for (i = 0; i < queue->q_depth; i++) {
-		comp_ctx = get_comp_ctxt(queue, i, false);
+	for (i = 0; i < admin_queue->q_depth; i++) {
+		comp_ctx = get_comp_ctxt(admin_queue, i, false);
 		if (comp_ctx)
 			ENA_WAIT_EVENT_INIT(comp_ctx->wait_event);
 	}
@@ -2049,10 +2049,10 @@ void ena_com_admin_q_comp_intr_handler(struct ena_com_dev *ena_dev)
 /* ena_handle_specific_aenq_event:
  * return the handler that is relevant to the specific event group
  */
-static ena_aenq_handler ena_com_get_specific_aenq_cb(struct ena_com_dev *dev,
+static ena_aenq_handler ena_com_get_specific_aenq_cb(struct ena_com_dev *ena_dev,
 						     u16 group)
 {
-	struct ena_aenq_handlers *aenq_handlers = dev->aenq.aenq_handlers;
+	struct ena_aenq_handlers *aenq_handlers = ena_dev->aenq.aenq_handlers;
 
 	if ((group < ENA_MAX_HANDLERS) && aenq_handlers->handlers[group])
 		return aenq_handlers->handlers[group];
@@ -2064,11 +2064,11 @@ static ena_aenq_handler ena_com_get_specific_aenq_cb(struct ena_com_dev *dev,
  * handles the aenq incoming events.
  * pop events from the queue and apply the specific handler
  */
-void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data)
+void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data)
 {
 	struct ena_admin_aenq_entry *aenq_e;
 	struct ena_admin_aenq_common_desc *aenq_common;
-	struct ena_com_aenq *aenq  = &dev->aenq;
+	struct ena_com_aenq *aenq  = &ena_dev->aenq;
 	u64 timestamp;
 	ena_aenq_handler handler_cb;
 	u16 masked_head, processed = 0;
@@ -2096,7 +2096,7 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data)
 			    timestamp);
 
 		/* Handle specific event*/
-		handler_cb = ena_com_get_specific_aenq_cb(dev,
+		handler_cb = ena_com_get_specific_aenq_cb(ena_dev,
 							  aenq_common->group);
 		handler_cb(data, aenq_e); /* call the actual event handler*/
 
@@ -2121,8 +2121,8 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data)
 
 	/* write the aenq doorbell after all AENQ descriptors were read */
 	mb();
-	ENA_REG_WRITE32_RELAXED(dev->bus, (u32)aenq->head,
-				dev->reg_bar + ENA_REGS_AENQ_HEAD_DB_OFF);
+	ENA_REG_WRITE32_RELAXED(ena_dev->bus, (u32)aenq->head,
+				ena_dev->reg_bar + ENA_REGS_AENQ_HEAD_DB_OFF);
 	mmiowb();
 }
 
drivers/net/ena/base/ena_com.h +1 -1
index 64d8f247cb..e9601b1a8e 100644
@@ -522,7 +522,7 @@ void ena_com_admin_q_comp_intr_handler(struct ena_com_dev *ena_dev);
  * This method goes over the async event notification queue and calls the proper
  * aenq handler.
  */
-void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data);
+void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data);
 
 /* ena_com_abort_admin_commands - Abort all the outstanding admin commands.
  * @ena_dev: ENA communication layer struct
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/22 net/ena/base: add dev arg to the logging macros

In reply to Michal Krawczyk

Some platforms may make use of the device argument to make the logs more verbose and specific for the appropriate device.

As it's not used by the ENA DPDK PMD for the logging, the type is just defined, but never used.

It may be reconsidered to change this in the future by adding port ID to the message logs, but as for now the logging behavior won't change.

---
 drivers/net/ena/base/ena_com.c       | 238 ++++++++++++++-------------
 drivers/net/ena/base/ena_com.h       |  21 +++
 drivers/net/ena/base/ena_eth_com.c   |  78 ++++++---
 drivers/net/ena/base/ena_eth_com.h   |  17 +-
 drivers/net/ena/base/ena_plat_dpdk.h |  44 ++---
 5 files changed, 236 insertions(+), 162 deletions(-)
drivers/net/ena/base/ena_com.c +128 -110
index f7258254a5..9931819bbb 100644
@@ -70,7 +70,7 @@ static int ena_com_mem_addr_set(struct ena_com_dev *ena_dev,
 				       dma_addr_t addr)
 {
 	if ((addr & GENMASK_ULL(ena_dev->dma_addr_bits - 1, 0)) != addr) {
-		ena_trc_err("dma address has more bits that the device supports\n");
+		ena_trc_err(ena_dev, "DMA address has more bits than the device supports\n");
 		return ENA_COM_INVAL;
 	}
 
@@ -82,6 +82,7 @@ static int ena_com_mem_addr_set(struct ena_com_dev *ena_dev,
 
 static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue)
 {
+	struct ena_com_dev *ena_dev = admin_queue->ena_dev;
 	struct ena_com_admin_sq *sq = &admin_queue->sq;
 	u16 size = ADMIN_SQ_SIZE(admin_queue->q_depth);
 
@@ -89,7 +90,7 @@ static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue)
 			       sq->mem_handle);
 
 	if (!sq->entries) {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -104,6 +105,7 @@ static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue)
 
 static int ena_com_admin_init_cq(struct ena_com_admin_queue *admin_queue)
 {
+	struct ena_com_dev *ena_dev = admin_queue->ena_dev;
 	struct ena_com_admin_cq *cq = &admin_queue->cq;
 	u16 size = ADMIN_CQ_SIZE(admin_queue->q_depth);
 
@@ -111,7 +113,7 @@ static int ena_com_admin_init_cq(struct ena_com_admin_queue *admin_queue)
 			       cq->mem_handle);
 
 	if (!cq->entries)  {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -136,7 +138,7 @@ static int ena_com_admin_init_aenq(struct ena_com_dev *ena_dev,
 			aenq->mem_handle);
 
 	if (!aenq->entries) {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -157,7 +159,7 @@ static int ena_com_admin_init_aenq(struct ena_com_dev *ena_dev,
 	ENA_REG_WRITE32(ena_dev->bus, aenq_caps, ena_dev->reg_bar + ENA_REGS_AENQ_CAPS_OFF);
 
 	if (unlikely(!aenq_handlers)) {
-		ena_trc_err("aenq handlers pointer is NULL\n");
+		ena_trc_err(ena_dev, "AENQ handlers pointer is NULL\n");
 		return ENA_COM_INVAL;
 	}
 
@@ -177,18 +179,21 @@ static struct ena_comp_ctx *get_comp_ctxt(struct ena_com_admin_queue *admin_queu
 					  u16 command_id, bool capture)
 {
 	if (unlikely(command_id >= admin_queue->q_depth)) {
-		ena_trc_err("command id is larger than the queue size. cmd_id: %u queue size %d\n",
+		ena_trc_err(admin_queue->ena_dev,
+			    "Command id is larger than the queue size. cmd_id: %u queue size %d\n",
 			    command_id, admin_queue->q_depth);
 		return NULL;
 	}
 
 	if (unlikely(!admin_queue->comp_ctx)) {
-		ena_trc_err("Completion context is NULL\n");
+		ena_trc_err(admin_queue->ena_dev,
+			    "Completion context is NULL\n");
 		return NULL;
 	}
 
 	if (unlikely(admin_queue->comp_ctx[command_id].occupied && capture)) {
-		ena_trc_err("Completion context is occupied\n");
+		ena_trc_err(admin_queue->ena_dev,
+			    "Completion context is occupied\n");
 		return NULL;
 	}
 
@@ -218,7 +223,7 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queu
 	/* In case of queue FULL */
 	cnt = (u16)ATOMIC32_READ(&admin_queue->outstanding_cmds);
 	if (cnt >= admin_queue->q_depth) {
-		ena_trc_dbg("admin queue is full.\n");
+		ena_trc_dbg(admin_queue->ena_dev, "Admin queue is full.\n");
 		admin_queue->stats.out_of_space++;
 		return ERR_PTR(ENA_COM_NO_SPACE);
 	}
@@ -262,13 +267,14 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queu
 
 static int ena_com_init_comp_ctxt(struct ena_com_admin_queue *admin_queue)
 {
+	struct ena_com_dev *ena_dev = admin_queue->ena_dev;
 	size_t size = admin_queue->q_depth * sizeof(struct ena_comp_ctx);
 	struct ena_comp_ctx *comp_ctx;
 	u16 i;
 
 	admin_queue->comp_ctx = ENA_MEM_ALLOC(admin_queue->q_dmadev, size);
 	if (unlikely(!admin_queue->comp_ctx)) {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -341,7 +347,7 @@ static int ena_com_init_io_sq(struct ena_com_dev *ena_dev,
 		}
 
 		if (!io_sq->desc_addr.virt_addr) {
-			ena_trc_err("memory allocation failed\n");
+			ena_trc_err(ena_dev, "Memory allocation failed\n");
 			return ENA_COM_NO_MEM;
 		}
 	}
@@ -366,7 +372,7 @@ static int ena_com_init_io_sq(struct ena_com_dev *ena_dev,
 			io_sq->bounce_buf_ctrl.base_buffer = ENA_MEM_ALLOC(ena_dev->dmadev, size);
 
 		if (!io_sq->bounce_buf_ctrl.base_buffer) {
-			ena_trc_err("bounce buffer memory allocation failed\n");
+			ena_trc_err(ena_dev, "Bounce buffer memory allocation failed\n");
 			return ENA_COM_NO_MEM;
 		}
 
@@ -431,7 +437,7 @@ static int ena_com_init_io_cq(struct ena_com_dev *ena_dev,
 	}
 
 	if (!io_cq->cdesc_addr.virt_addr) {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -452,7 +458,8 @@ static void ena_com_handle_single_admin_completion(struct ena_com_admin_queue *a
 
 	comp_ctx = get_comp_ctxt(admin_queue, cmd_id, false);
 	if (unlikely(!comp_ctx)) {
-		ena_trc_err("comp_ctx is NULL. Changing the admin queue running state\n");
+		ena_trc_err(admin_queue->ena_dev,
+			    "comp_ctx is NULL. Changing the admin queue running state\n");
 		admin_queue->running_state = false;
 		return;
 	}
@@ -504,10 +511,12 @@ static void ena_com_handle_admin_completion(struct ena_com_admin_queue *admin_qu
 	admin_queue->stats.completed_cmd += comp_num;
 }
 
-static int ena_com_comp_status_to_errno(u8 comp_status)
+static int ena_com_comp_status_to_errno(struct ena_com_admin_queue *admin_queue,
+					u8 comp_status)
 {
 	if (unlikely(comp_status != 0))
-		ena_trc_err("admin command failed[%u]\n", comp_status);
+		ena_trc_err(admin_queue->ena_dev,
+			    "Admin command failed[%u]\n", comp_status);
 
 	switch (comp_status) {
 	case ENA_ADMIN_SUCCESS:
@@ -554,7 +563,8 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
 			break;
 
 		if (ENA_TIME_EXPIRE(timeout)) {
-			ena_trc_err("Wait for completion (polling) timeout\n");
+			ena_trc_err(admin_queue->ena_dev,
+				    "Wait for completion (polling) timeout\n");
 			/* ENA didn't have any completion */
 			ENA_SPINLOCK_LOCK(admin_queue->q_lock, flags);
 			admin_queue->stats.no_completion++;
@@ -570,7 +580,7 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
 	}
 
 	if (unlikely(comp_ctx->status == ENA_CMD_ABORTED)) {
-		ena_trc_err("Command was aborted\n");
+		ena_trc_err(admin_queue->ena_dev, "Command was aborted\n");
 		ENA_SPINLOCK_LOCK(admin_queue->q_lock, flags);
 		admin_queue->stats.aborted_cmd++;
 		ENA_SPINLOCK_UNLOCK(admin_queue->q_lock, flags);
@@ -579,9 +589,10 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
 	}
 
 	ENA_WARN(comp_ctx->status != ENA_CMD_COMPLETED,
-		 "Invalid comp status %d\n", comp_ctx->status);
+		 admin_queue->ena_dev, "Invalid comp status %d\n",
+		 comp_ctx->status);
 
-	ret = ena_com_comp_status_to_errno(comp_ctx->comp_status);
+	ret = ena_com_comp_status_to_errno(admin_queue, comp_ctx->comp_status);
 err:
 	comp_ctxt_release(admin_queue, comp_ctx);
 	return ret;
@@ -623,7 +634,7 @@ static int ena_com_set_llq(struct ena_com_dev *ena_dev)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to set LLQ configurations: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to set LLQ configurations: %d\n", ret);
 
 	return ret;
 }
@@ -645,7 +656,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 		llq_info->header_location_ctrl =
 			llq_default_cfg->llq_header_location;
 	} else {
-		ena_trc_err("Invalid header location control, supported: 0x%x\n",
+		ena_trc_err(ena_dev, "Invalid header location control, supported: 0x%x\n",
 			    supported_feat);
 		return -EINVAL;
 	}
@@ -660,12 +671,12 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 			} else if (supported_feat & ENA_ADMIN_SINGLE_DESC_PER_ENTRY) {
 				llq_info->desc_stride_ctrl = ENA_ADMIN_SINGLE_DESC_PER_ENTRY;
 			} else {
-				ena_trc_err("Invalid desc_stride_ctrl, supported: 0x%x\n",
+				ena_trc_err(ena_dev, "Invalid desc_stride_ctrl, supported: 0x%x\n",
 					    supported_feat);
 				return -EINVAL;
 			}
 
-			ena_trc_err("Default llq stride ctrl is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
+			ena_trc_err(ena_dev, "Default llq stride ctrl is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
 				    llq_default_cfg->llq_stride_ctrl,
 				    supported_feat,
 				    llq_info->desc_stride_ctrl);
@@ -689,11 +700,12 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 			llq_info->desc_list_entry_size_ctrl = ENA_ADMIN_LIST_ENTRY_SIZE_256B;
 			llq_info->desc_list_entry_size = 256;
 		} else {
-			ena_trc_err("Invalid entry_size_ctrl, supported: 0x%x\n", supported_feat);
+			ena_trc_err(ena_dev, "Invalid entry_size_ctrl, supported: 0x%x\n",
+				    supported_feat);
 			return -EINVAL;
 		}
 
-		ena_trc_err("Default llq ring entry size is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
+		ena_trc_err(ena_dev, "Default llq ring entry size is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
 			    llq_default_cfg->llq_ring_entry_size,
 			    supported_feat,
 			    llq_info->desc_list_entry_size);
@@ -702,7 +714,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 		/* The desc list entry size should be whole multiply of 8
 		 * This requirement comes from __iowrite64_copy()
 		 */
-		ena_trc_err("illegal entry size %d\n",
+		ena_trc_err(ena_dev, "Illegal entry size %d\n",
 			    llq_info->desc_list_entry_size);
 		return -EINVAL;
 	}
@@ -726,12 +738,12 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 		} else if (supported_feat & ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_8) {
 			llq_info->descs_num_before_header = ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_8;
 		} else {
-			ena_trc_err("Invalid descs_num_before_header, supported: 0x%x\n",
+			ena_trc_err(ena_dev, "Invalid descs_num_before_header, supported: 0x%x\n",
 				    supported_feat);
 			return -EINVAL;
 		}
 
-		ena_trc_err("Default llq num descs before header is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
+		ena_trc_err(ena_dev, "Default llq num descs before header is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
 			    llq_default_cfg->llq_num_decs_before_header,
 			    supported_feat,
 			    llq_info->descs_num_before_header);
@@ -750,7 +762,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 
 	rc = ena_com_set_llq(ena_dev);
 	if (rc)
-		ena_trc_err("Cannot set LLQ configuration: %d\n", rc);
+		ena_trc_err(ena_dev, "Cannot set LLQ configuration: %d\n", rc);
 
 	return rc;
 }
@@ -776,13 +788,15 @@ static int ena_com_wait_and_process_admin_cq_interrupts(struct ena_comp_ctx *com
 		ENA_SPINLOCK_UNLOCK(admin_queue->q_lock, flags);
 
 		if (comp_ctx->status == ENA_CMD_COMPLETED) {
-			ena_trc_err("The ena device sent a completion but the driver didn't receive a MSI-X interrupt (cmd %d), autopolling mode is %s\n",
+			ena_trc_err(admin_queue->ena_dev,
+				    "The ena device sent a completion but the driver didn't receive a MSI-X interrupt (cmd %d), autopolling mode is %s\n",
 				    comp_ctx->cmd_opcode, admin_queue->auto_polling ? "ON" : "OFF");
 			/* Check if fallback to polling is enabled */
 			if (admin_queue->auto_polling)
 				admin_queue->polling = true;
 		} else {
-			ena_trc_err("The ena device didn't send a completion for the admin cmd %d status %d\n",
+			ena_trc_err(admin_queue->ena_dev,
+				    "The ena device didn't send a completion for the admin cmd %d status %d\n",
 				    comp_ctx->cmd_opcode, comp_ctx->status);
 		}
 		/* Check if shifted to polling mode.
@@ -796,7 +810,7 @@ static int ena_com_wait_and_process_admin_cq_interrupts(struct ena_comp_ctx *com
 		}
 	}
 
-	ret = ena_com_comp_status_to_errno(comp_ctx->comp_status);
+	ret = ena_com_comp_status_to_errno(admin_queue, comp_ctx->comp_status);
 err:
 	comp_ctxt_release(admin_queue, comp_ctx);
 	return ret;
@@ -844,7 +858,7 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev *ena_dev, u16 offset)
 	}
 
 	if (unlikely(i == timeout)) {
-		ena_trc_err("reading reg failed for timeout. expected: req id[%hu] offset[%hu] actual: req id[%hu] offset[%hu]\n",
+		ena_trc_err(ena_dev, "Reading reg failed for timeout. expected: req id[%hu] offset[%hu] actual: req id[%hu] offset[%hu]\n",
 			    mmio_read->seq_num,
 			    offset,
 			    read_resp->req_id,
@@ -854,7 +868,7 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev *ena_dev, u16 offset)
 	}
 
 	if (read_resp->reg_off != offset) {
-		ena_trc_err("Read failure: wrong offset provided\n");
+		ena_trc_err(ena_dev, "Read failure: wrong offset provided\n");
 		ret = ENA_MMIO_READ_TIMEOUT;
 	} else {
 		ret = read_resp->reg_val;
@@ -913,7 +927,7 @@ static int ena_com_destroy_io_sq(struct ena_com_dev *ena_dev,
 					    sizeof(destroy_resp));
 
 	if (unlikely(ret && (ret != ENA_COM_NO_DEVICE)))
-		ena_trc_err("failed to destroy io sq error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to destroy io sq error: %d\n", ret);
 
 	return ret;
 }
@@ -969,7 +983,7 @@ static int wait_for_reset_state(struct ena_com_dev *ena_dev, u32 timeout,
 		val = ena_com_reg_bar_read32(ena_dev, ENA_REGS_DEV_STS_OFF);
 
 		if (unlikely(val == ENA_MMIO_READ_TIMEOUT)) {
-			ena_trc_err("Reg read timeout occurred\n");
+			ena_trc_err(ena_dev, "Reg read timeout occurred\n");
 			return ENA_COM_TIMER_EXPIRED;
 		}
 
@@ -1009,7 +1023,7 @@ static int ena_com_get_feature_ex(struct ena_com_dev *ena_dev,
 	int ret;
 
 	if (!ena_com_check_supported_feature_id(ena_dev, feature_id)) {
-		ena_trc_dbg("Feature %d isn't supported\n", feature_id);
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n", feature_id);
 		return ENA_COM_UNSUPPORTED;
 	}
 
@@ -1028,7 +1042,7 @@ static int ena_com_get_feature_ex(struct ena_com_dev *ena_dev,
 				   &get_cmd.control_buffer.address,
 				   control_buf_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -1045,7 +1059,7 @@ static int ena_com_get_feature_ex(struct ena_com_dev *ena_dev,
 					    sizeof(*get_resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to submit get_feature command %d error: %d\n",
+		ena_trc_err(ena_dev, "Failed to submit get_feature command %d error: %d\n",
 			    feature_id, ret);
 
 	return ret;
@@ -1157,7 +1171,7 @@ static int ena_com_indirect_table_allocate(struct ena_com_dev *ena_dev,
 
 	if ((get_resp.u.ind_table.min_size > log_size) ||
 	    (get_resp.u.ind_table.max_size < log_size)) {
-		ena_trc_err("indirect table size doesn't fit. requested size: %d while min is:%d and max %d\n",
+		ena_trc_err(ena_dev, "Indirect table size doesn't fit. requested size: %d while min is:%d and max %d\n",
 			    1 << log_size,
 			    1 << get_resp.u.ind_table.min_size,
 			    1 << get_resp.u.ind_table.max_size);
@@ -1261,7 +1275,7 @@ static int ena_com_create_io_sq(struct ena_com_dev *ena_dev,
 					   &create_cmd.sq_ba,
 					   io_sq->desc_addr.phys_addr);
 		if (unlikely(ret)) {
-			ena_trc_err("memory address set failed\n");
+			ena_trc_err(ena_dev, "Memory address set failed\n");
 			return ret;
 		}
 	}
@@ -1272,7 +1286,7 @@ static int ena_com_create_io_sq(struct ena_com_dev *ena_dev,
 					    (struct ena_admin_acq_entry *)&cmd_completion,
 					    sizeof(cmd_completion));
 	if (unlikely(ret)) {
-		ena_trc_err("Failed to create IO SQ. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to create IO SQ. error: %d\n", ret);
 		return ret;
 	}
 
@@ -1290,7 +1304,7 @@ static int ena_com_create_io_sq(struct ena_com_dev *ena_dev,
 			cmd_completion.llq_descriptors_offset);
 	}
 
-	ena_trc_dbg("created sq[%u], depth[%u]\n", io_sq->idx, io_sq->q_depth);
+	ena_trc_dbg(ena_dev, "Created sq[%u], depth[%u]\n", io_sq->idx, io_sq->q_depth);
 
 	return ret;
 }
@@ -1324,7 +1338,7 @@ static void ena_com_update_intr_delay_resolution(struct ena_com_dev *ena_dev,
 	u16 prev_intr_delay_resolution = ena_dev->intr_delay_resolution;
 
 	if (unlikely(!intr_delay_resolution)) {
-		ena_trc_err("Illegal intr_delay_resolution provided. Going to use default 1 usec resolution\n");
+		ena_trc_err(ena_dev, "Illegal intr_delay_resolution provided. Going to use default 1 usec resolution\n");
 		intr_delay_resolution = ENA_DEFAULT_INTR_DELAY_RESOLUTION;
 	}
 
@@ -1360,10 +1374,12 @@ int ena_com_execute_admin_command(struct ena_com_admin_queue *admin_queue,
 					    comp, comp_size);
 	if (IS_ERR(comp_ctx)) {
 		if (comp_ctx == ERR_PTR(ENA_COM_NO_DEVICE))
-			ena_trc_dbg("Failed to submit command [%ld]\n",
+			ena_trc_dbg(admin_queue->ena_dev,
+				    "Failed to submit command [%ld]\n",
 				    PTR_ERR(comp_ctx));
 		else
-			ena_trc_err("Failed to submit command [%ld]\n",
+			ena_trc_err(admin_queue->ena_dev,
+				    "Failed to submit command [%ld]\n",
 				    PTR_ERR(comp_ctx));
 
 		return PTR_ERR(comp_ctx);
@@ -1372,11 +1388,11 @@ int ena_com_execute_admin_command(struct ena_com_admin_queue *admin_queue,
 	ret = ena_com_wait_and_process_admin_cq(comp_ctx, admin_queue);
 	if (unlikely(ret)) {
 		if (admin_queue->running_state)
-			ena_trc_err("Failed to process command. ret = %d\n",
-				    ret);
+			ena_trc_err(admin_queue->ena_dev,
+				    "Failed to process command. ret = %d\n", ret);
 		else
-			ena_trc_dbg("Failed to process command. ret = %d\n",
-				    ret);
+			ena_trc_dbg(admin_queue->ena_dev,
+				    "Failed to process command. ret = %d\n", ret);
 	}
 	return ret;
 }
@@ -1405,7 +1421,7 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev,
 				   &create_cmd.cq_ba,
 				   io_cq->cdesc_addr.phys_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -1415,7 +1431,7 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev,
 					    (struct ena_admin_acq_entry *)&cmd_completion,
 					    sizeof(cmd_completion));
 	if (unlikely(ret)) {
-		ena_trc_err("Failed to create IO CQ. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to create IO CQ. error: %d\n", ret);
 		return ret;
 	}
 
@@ -1434,7 +1450,7 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev,
 			(u32 __iomem *)((uintptr_t)ena_dev->reg_bar +
 			cmd_completion.numa_node_register_offset);
 
-	ena_trc_dbg("created cq[%u], depth[%u]\n", io_cq->idx, io_cq->q_depth);
+	ena_trc_dbg(ena_dev, "Created cq[%u], depth[%u]\n", io_cq->idx, io_cq->q_depth);
 
 	return ret;
 }
@@ -1444,7 +1460,7 @@ int ena_com_get_io_handlers(struct ena_com_dev *ena_dev, u16 qid,
 			    struct ena_com_io_cq **io_cq)
 {
 	if (qid >= ENA_TOTAL_NUM_QUEUES) {
-		ena_trc_err("Invalid queue number %d but the max is %d\n",
+		ena_trc_err(ena_dev, "Invalid queue number %d but the max is %d\n",
 			    qid, ENA_TOTAL_NUM_QUEUES);
 		return ENA_COM_INVAL;
 	}
@@ -1510,7 +1526,7 @@ int ena_com_destroy_io_cq(struct ena_com_dev *ena_dev,
 					    sizeof(destroy_resp));
 
 	if (unlikely(ret && (ret != ENA_COM_NO_DEVICE)))
-		ena_trc_err("Failed to destroy IO CQ. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to destroy IO CQ. error: %d\n", ret);
 
 	return ret;
 }
@@ -1534,7 +1550,7 @@ void ena_com_admin_aenq_enable(struct ena_com_dev *ena_dev)
 {
 	u16 depth = ena_dev->aenq.q_depth;
 
-	ENA_WARN(ena_dev->aenq.head != depth, "Invalid AENQ state\n");
+	ENA_WARN(ena_dev->aenq.head != depth, ena_dev, "Invalid AENQ state\n");
 
 	/* Init head_db to mark that all entries in the queue
 	 * are initially available
@@ -1552,12 +1568,12 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_dev, u32 groups_flag)
 
 	ret = ena_com_get_feature(ena_dev, &get_resp, ENA_ADMIN_AENQ_CONFIG, 0);
 	if (ret) {
-		ena_trc_info("Can't get aenq configuration\n");
+		ena_trc_info(ena_dev, "Can't get aenq configuration\n");
 		return ret;
 	}
 
 	if ((get_resp.u.aenq.supported_groups & groups_flag) != groups_flag) {
-		ena_trc_warn("Trying to set unsupported aenq events. supported flag: 0x%x asked flag: 0x%x\n",
+		ena_trc_warn(ena_dev, "Trying to set unsupported aenq events. supported flag: 0x%x asked flag: 0x%x\n",
 			     get_resp.u.aenq.supported_groups,
 			     groups_flag);
 		return ENA_COM_UNSUPPORTED;
@@ -1578,7 +1594,7 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_dev, u32 groups_flag)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to config AENQ ret: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to config AENQ ret: %d\n", ret);
 
 	return ret;
 }
@@ -1589,17 +1605,17 @@ int ena_com_get_dma_width(struct ena_com_dev *ena_dev)
 	int width;
 
 	if (unlikely(caps == ENA_MMIO_READ_TIMEOUT)) {
-		ena_trc_err("Reg read timeout occurred\n");
+		ena_trc_err(ena_dev, "Reg read timeout occurred\n");
 		return ENA_COM_TIMER_EXPIRED;
 	}
 
 	width = (caps & ENA_REGS_CAPS_DMA_ADDR_WIDTH_MASK) >>
 		ENA_REGS_CAPS_DMA_ADDR_WIDTH_SHIFT;
 
-	ena_trc_dbg("ENA dma width: %d\n", width);
+	ena_trc_dbg(ena_dev, "ENA dma width: %d\n", width);
 
 	if ((width < 32) || width > ENA_MAX_PHYS_ADDR_SIZE_BITS) {
-		ena_trc_err("DMA width illegal value: %d\n", width);
+		ena_trc_err(ena_dev, "DMA width illegal value: %d\n", width);
 		return ENA_COM_INVAL;
 	}
 
@@ -1623,16 +1639,16 @@ int ena_com_validate_version(struct ena_com_dev *ena_dev)
 
 	if (unlikely((ver == ENA_MMIO_READ_TIMEOUT) ||
 		     (ctrl_ver == ENA_MMIO_READ_TIMEOUT))) {
-		ena_trc_err("Reg read timeout occurred\n");
+		ena_trc_err(ena_dev, "Reg read timeout occurred\n");
 		return ENA_COM_TIMER_EXPIRED;
 	}
 
-	ena_trc_info("ena device version: %d.%d\n",
+	ena_trc_info(ena_dev, "ENA device version: %d.%d\n",
 		     (ver & ENA_REGS_VERSION_MAJOR_VERSION_MASK) >>
 		     ENA_REGS_VERSION_MAJOR_VERSION_SHIFT,
 		     ver & ENA_REGS_VERSION_MINOR_VERSION_MASK);
 
-	ena_trc_info("ena controller version: %d.%d.%d implementation version %d\n",
+	ena_trc_info(ena_dev, "ENA controller version: %d.%d.%d implementation version %d\n",
 		     (ctrl_ver & ENA_REGS_CONTROLLER_VERSION_MAJOR_VERSION_MASK)
 		     >> ENA_REGS_CONTROLLER_VERSION_MAJOR_VERSION_SHIFT,
 		     (ctrl_ver & ENA_REGS_CONTROLLER_VERSION_MINOR_VERSION_MASK)
@@ -1648,7 +1664,7 @@ int ena_com_validate_version(struct ena_com_dev *ena_dev)
 
 	/* Validate the ctrl version without the implementation ID */
 	if (ctrl_ver_masked < MIN_ENA_CTRL_VER) {
-		ena_trc_err("ENA ctrl version is lower than the minimal ctrl version the driver supports\n");
+		ena_trc_err(ena_dev, "ENA ctrl version is lower than the minimal ctrl version the driver supports\n");
 		return -1;
 	}
 
@@ -1786,12 +1802,12 @@ int ena_com_admin_init(struct ena_com_dev *ena_dev,
 	dev_sts = ena_com_reg_bar_read32(ena_dev, ENA_REGS_DEV_STS_OFF);
 
 	if (unlikely(dev_sts == ENA_MMIO_READ_TIMEOUT)) {
-		ena_trc_err("Reg read timeout occurred\n");
+		ena_trc_err(ena_dev, "Reg read timeout occurred\n");
 		return ENA_COM_TIMER_EXPIRED;
 	}
 
 	if (!(dev_sts & ENA_REGS_DEV_STS_READY_MASK)) {
-		ena_trc_err("Device isn't ready, abort com init\n");
+		ena_trc_err(ena_dev, "Device isn't ready, abort com init\n");
 		return ENA_COM_NO_DEVICE;
 	}
 
@@ -1869,7 +1885,7 @@ int ena_com_create_io_queue(struct ena_com_dev *ena_dev,
 	int ret;
 
 	if (ctx->qid >= ENA_TOTAL_NUM_QUEUES) {
-		ena_trc_err("Qid (%d) is bigger than max num of queues (%d)\n",
+		ena_trc_err(ena_dev, "Qid (%d) is bigger than max num of queues (%d)\n",
 			    ctx->qid, ENA_TOTAL_NUM_QUEUES);
 		return ENA_COM_INVAL;
 	}
@@ -1928,7 +1944,7 @@ void ena_com_destroy_io_queue(struct ena_com_dev *ena_dev, u16 qid)
 	struct ena_com_io_cq *io_cq;
 
 	if (qid >= ENA_TOTAL_NUM_QUEUES) {
-		ena_trc_err("Qid (%d) is bigger than max num of queues (%d)\n",
+		ena_trc_err(ena_dev, "Qid (%d) is bigger than max num of queues (%d)\n",
 			    qid, ENA_TOTAL_NUM_QUEUES);
 		return;
 	}
@@ -2090,7 +2106,7 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data)
 		timestamp = (u64)aenq_common->timestamp_low |
 			((u64)aenq_common->timestamp_high << 32);
 		ENA_TOUCH(timestamp); /* In case debug is disabled */
-		ena_trc_dbg("AENQ! Group[%x] Syndrom[%x] timestamp: [%" ENA_PRIu64 "s]\n",
+		ena_trc_dbg(ena_dev, "AENQ! Group[%x] Syndrom[%x] timestamp: [%" ENA_PRIu64 "s]\n",
 			    aenq_common->group,
 			    aenq_common->syndrom,
 			    timestamp);
@@ -2137,19 +2153,19 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev,
 
 	if (unlikely((stat == ENA_MMIO_READ_TIMEOUT) ||
 		     (cap == ENA_MMIO_READ_TIMEOUT))) {
-		ena_trc_err("Reg read32 timeout occurred\n");
+		ena_trc_err(ena_dev, "Reg read32 timeout occurred\n");
 		return ENA_COM_TIMER_EXPIRED;
 	}
 
 	if ((stat & ENA_REGS_DEV_STS_READY_MASK) == 0) {
-		ena_trc_err("Device isn't ready, can't reset device\n");
+		ena_trc_err(ena_dev, "Device isn't ready, can't reset device\n");
 		return ENA_COM_INVAL;
 	}
 
 	timeout = (cap & ENA_REGS_CAPS_RESET_TIMEOUT_MASK) >>
 			ENA_REGS_CAPS_RESET_TIMEOUT_SHIFT;
 	if (timeout == 0) {
-		ena_trc_err("Invalid timeout value\n");
+		ena_trc_err(ena_dev, "Invalid timeout value\n");
 		return ENA_COM_INVAL;
 	}
 
@@ -2165,7 +2181,7 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev,
 	rc = wait_for_reset_state(ena_dev, timeout,
 				  ENA_REGS_DEV_STS_RESET_IN_PROGRESS_MASK);
 	if (rc != 0) {
-		ena_trc_err("Reset indication didn't turn on\n");
+		ena_trc_err(ena_dev, "Reset indication didn't turn on\n");
 		return rc;
 	}
 
@@ -2173,7 +2189,7 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev,
 	ENA_REG_WRITE32(ena_dev->bus, 0, ena_dev->reg_bar + ENA_REGS_DEV_CTL_OFF);
 	rc = wait_for_reset_state(ena_dev, timeout, 0);
 	if (rc != 0) {
-		ena_trc_err("Reset indication didn't turn off\n");
+		ena_trc_err(ena_dev, "Reset indication didn't turn off\n");
 		return rc;
 	}
 
@@ -2210,7 +2226,7 @@ static int ena_get_dev_stats(struct ena_com_dev *ena_dev,
 					     sizeof(*get_resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to get stats. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to get stats. error: %d\n", ret);
 
 	return ret;
 }
@@ -2253,7 +2269,7 @@ int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu)
 	int ret;
 
 	if (!ena_com_check_supported_feature_id(ena_dev, ENA_ADMIN_MTU)) {
-		ena_trc_dbg("Feature %d isn't supported\n", ENA_ADMIN_MTU);
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n", ENA_ADMIN_MTU);
 		return ENA_COM_UNSUPPORTED;
 	}
 
@@ -2272,7 +2288,7 @@ int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to set mtu %d. error: %d\n", mtu, ret);
+		ena_trc_err(ena_dev, "Failed to set mtu %d. error: %d\n", mtu, ret);
 
 	return ret;
 }
@@ -2286,7 +2302,7 @@ int ena_com_get_offload_settings(struct ena_com_dev *ena_dev,
 	ret = ena_com_get_feature(ena_dev, &resp,
 				  ENA_ADMIN_STATELESS_OFFLOAD_CONFIG, 0);
 	if (unlikely(ret)) {
-		ena_trc_err("Failed to get offload capabilities %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to get offload capabilities %d\n", ret);
 		return ret;
 	}
 
@@ -2306,7 +2322,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
 
 	if (!ena_com_check_supported_feature_id(ena_dev,
 						ENA_ADMIN_RSS_HASH_FUNCTION)) {
-		ena_trc_dbg("Feature %d isn't supported\n",
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
 			    ENA_ADMIN_RSS_HASH_FUNCTION);
 		return ENA_COM_UNSUPPORTED;
 	}
@@ -2318,7 +2334,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
 		return ret;
 
 	if (!(get_resp.u.flow_hash_func.supported_func & BIT(rss->hash_func))) {
-		ena_trc_err("Func hash %d isn't supported by device, abort\n",
+		ena_trc_err(ena_dev, "Func hash %d isn't supported by device, abort\n",
 			    rss->hash_func);
 		return ENA_COM_UNSUPPORTED;
 	}
@@ -2336,7 +2352,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
 				   &cmd.control_buffer.address,
 				   rss->hash_key_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -2348,7 +2364,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
 					    (struct ena_admin_acq_entry *)&resp,
 					    sizeof(resp));
 	if (unlikely(ret)) {
-		ena_trc_err("Failed to set hash function %d. error: %d\n",
+		ena_trc_err(ena_dev, "Failed to set hash function %d. error: %d\n",
 			    rss->hash_func, ret);
 		return ENA_COM_INVAL;
 	}
@@ -2380,7 +2396,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
 		return rc;
 
 	if (!(BIT(func) & get_resp.u.flow_hash_func.supported_func)) {
-		ena_trc_err("Flow hash function %d isn't supported\n", func);
+		ena_trc_err(ena_dev, "Flow hash function %d isn't supported\n", func);
 		return ENA_COM_UNSUPPORTED;
 	}
 
@@ -2388,7 +2404,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
 	case ENA_ADMIN_TOEPLITZ:
 		if (key) {
 			if (key_len != sizeof(hash_key->key)) {
-				ena_trc_err("key len (%hu) doesn't equal the supported size (%zu)\n",
+				ena_trc_err(ena_dev, "key len (%hu) doesn't equal the supported size (%zu)\n",
 					     key_len, sizeof(hash_key->key));
 				return ENA_COM_INVAL;
 			}
@@ -2401,7 +2417,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
 		rss->hash_init_val = init_val;
 		break;
 	default:
-		ena_trc_err("Invalid hash function (%d)\n", func);
+		ena_trc_err(ena_dev, "Invalid hash function (%d)\n", func);
 		return ENA_COM_INVAL;
 	}
 
@@ -2486,7 +2502,7 @@ int ena_com_set_hash_ctrl(struct ena_com_dev *ena_dev)
 
 	if (!ena_com_check_supported_feature_id(ena_dev,
 						ENA_ADMIN_RSS_HASH_INPUT)) {
-		ena_trc_dbg("Feature %d isn't supported\n",
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
 			    ENA_ADMIN_RSS_HASH_INPUT);
 		return ENA_COM_UNSUPPORTED;
 	}
@@ -2505,7 +2521,7 @@ int ena_com_set_hash_ctrl(struct ena_com_dev *ena_dev)
 				   &cmd.control_buffer.address,
 				   rss->hash_ctrl_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 	cmd.control_buffer.length = sizeof(*hash_ctrl);
@@ -2516,7 +2532,7 @@ int ena_com_set_hash_ctrl(struct ena_com_dev *ena_dev)
 					    (struct ena_admin_acq_entry *)&resp,
 					    sizeof(resp));
 	if (unlikely(ret))
-		ena_trc_err("Failed to set hash input. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to set hash input. error: %d\n", ret);
 
 	return ret;
 }
@@ -2566,7 +2582,7 @@ int ena_com_set_default_hash_ctrl(struct ena_com_dev *ena_dev)
 		available_fields = hash_ctrl->selected_fields[i].fields &
 				hash_ctrl->supported_fields[i].fields;
 		if (available_fields != hash_ctrl->selected_fields[i].fields) {
-			ena_trc_err("hash control doesn't support all the desire configuration. proto %x supported %x selected %x\n",
+			ena_trc_err(ena_dev, "Hash control doesn't support all the desire configuration. proto %x supported %x selected %x\n",
 				    i, hash_ctrl->supported_fields[i].fields,
 				    hash_ctrl->selected_fields[i].fields);
 			return ENA_COM_UNSUPPORTED;
@@ -2592,7 +2608,7 @@ int ena_com_fill_hash_ctrl(struct ena_com_dev *ena_dev,
 	int rc;
 
 	if (proto >= ENA_ADMIN_RSS_PROTO_NUM) {
-		ena_trc_err("Invalid proto num (%u)\n", proto);
+		ena_trc_err(ena_dev, "Invalid proto num (%u)\n", proto);
 		return ENA_COM_INVAL;
 	}
 
@@ -2604,7 +2620,7 @@ int ena_com_fill_hash_ctrl(struct ena_com_dev *ena_dev,
 	/* Make sure all the fields are supported */
 	supported_fields = hash_ctrl->supported_fields[proto].fields;
 	if ((hash_fields & supported_fields) != hash_fields) {
-		ena_trc_err("proto %d doesn't support the required fields %x. supports only: %x\n",
+		ena_trc_err(ena_dev, "Proto %d doesn't support the required fields %x. supports only: %x\n",
 			    proto, hash_fields, supported_fields);
 	}
 
@@ -2645,14 +2661,14 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 
 	if (!ena_com_check_supported_feature_id(ena_dev,
 						ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG)) {
-		ena_trc_dbg("Feature %d isn't supported\n",
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
 			    ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG);
 		return ENA_COM_UNSUPPORTED;
 	}
 
 	ret = ena_com_ind_tbl_convert_to_device(ena_dev);
 	if (ret) {
-		ena_trc_err("Failed to convert host indirection table to device table\n");
+		ena_trc_err(ena_dev, "Failed to convert host indirection table to device table\n");
 		return ret;
 	}
 
@@ -2669,7 +2685,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 				   &cmd.control_buffer.address,
 				   rss->rss_ind_tbl_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -2683,7 +2699,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to set indirect table. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to set indirect table. error: %d\n", ret);
 
 	return ret;
 }
@@ -2848,7 +2864,7 @@ int ena_com_set_host_attributes(struct ena_com_dev *ena_dev)
 				   &cmd.u.host_attr.debug_ba,
 				   host_attr->debug_area_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -2856,7 +2872,7 @@ int ena_com_set_host_attributes(struct ena_com_dev *ena_dev)
 				   &cmd.u.host_attr.os_info_ba,
 				   host_attr->host_info_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -2869,7 +2885,7 @@ int ena_com_set_host_attributes(struct ena_com_dev *ena_dev)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to set host attributes: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to set host attributes: %d\n", ret);
 
 	return ret;
 }
@@ -2881,12 +2897,13 @@ bool ena_com_interrupt_moderation_supported(struct ena_com_dev *ena_dev)
 						  ENA_ADMIN_INTERRUPT_MODERATION);
 }
 
-static int ena_com_update_nonadaptive_moderation_interval(u32 coalesce_usecs,
+static int ena_com_update_nonadaptive_moderation_interval(struct ena_com_dev *ena_dev,
+							  u32 coalesce_usecs,
 							  u32 intr_delay_resolution,
 							  u32 *intr_moder_interval)
 {
 	if (!intr_delay_resolution) {
-		ena_trc_err("Illegal interrupt delay granularity value\n");
+		ena_trc_err(ena_dev, "Illegal interrupt delay granularity value\n");
 		return ENA_COM_FAULT;
 	}
 
@@ -2895,11 +2912,11 @@ static int ena_com_update_nonadaptive_moderation_interval(u32 coalesce_usecs,
 	return 0;
 }
 
-
 int ena_com_update_nonadaptive_moderation_interval_tx(struct ena_com_dev *ena_dev,
 						      u32 tx_coalesce_usecs)
 {
-	return ena_com_update_nonadaptive_moderation_interval(tx_coalesce_usecs,
+	return ena_com_update_nonadaptive_moderation_interval(ena_dev,
+							      tx_coalesce_usecs,
 							      ena_dev->intr_delay_resolution,
 							      &ena_dev->intr_moder_tx_interval);
 }
@@ -2907,7 +2924,8 @@ int ena_com_update_nonadaptive_moderation_interval_tx(struct ena_com_dev *ena_de
 int ena_com_update_nonadaptive_moderation_interval_rx(struct ena_com_dev *ena_dev,
 						      u32 rx_coalesce_usecs)
 {
-	return ena_com_update_nonadaptive_moderation_interval(rx_coalesce_usecs,
+	return ena_com_update_nonadaptive_moderation_interval(ena_dev,
+							      rx_coalesce_usecs,
 							      ena_dev->intr_delay_resolution,
 							      &ena_dev->intr_moder_rx_interval);
 }
@@ -2923,12 +2941,12 @@ int ena_com_init_interrupt_moderation(struct ena_com_dev *ena_dev)
 
 	if (rc) {
 		if (rc == ENA_COM_UNSUPPORTED) {
-			ena_trc_dbg("Feature %d isn't supported\n",
+			ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
 				    ENA_ADMIN_INTERRUPT_MODERATION);
 			rc = 0;
 		} else {
-			ena_trc_err("Failed to get interrupt moderation admin cmd. rc: %d\n",
-				    rc);
+			ena_trc_err(ena_dev,
+				    "Failed to get interrupt moderation admin cmd. rc: %d\n", rc);
 		}
 
 		/* no moderation supported, disable adaptive support */
@@ -2976,7 +2994,7 @@ int ena_com_config_dev_mode(struct ena_com_dev *ena_dev,
 		(llq_info->descs_num_before_header * sizeof(struct ena_eth_io_tx_desc));
 
 	if (unlikely(ena_dev->tx_max_header_size == 0)) {
-		ena_trc_err("the size of the LLQ entry is smaller than needed\n");
+		ena_trc_err(ena_dev, "The size of the LLQ entry is smaller than needed\n");
 		return -EINVAL;
 	}
 
drivers/net/ena/base/ena_com.h +21 -0
index e9601b1a8e..cd116e90e6 100644
@@ -300,6 +300,7 @@ struct ena_com_dev {
 	void __iomem *mem_bar;
 	void *dmadev;
 	void *bus;
+	ena_netdev *net_device;
 
 	enum ena_admin_placement_policy_type tx_mem_queue_type;
 	u32 tx_max_header_size;
@@ -944,6 +945,26 @@ int ena_com_config_dev_mode(struct ena_com_dev *ena_dev,
 			    struct ena_admin_feature_llq_desc *llq_features,
 			    struct ena_llq_configurations *llq_default_config);
 
+/* ena_com_io_sq_to_ena_dev - Extract ena_com_dev using contained field io_sq.
+ * @io_sq: IO submit queue struct
+ *
+ * @return - ena_com_dev struct extracted from io_sq
+ */
+static inline struct ena_com_dev *ena_com_io_sq_to_ena_dev(struct ena_com_io_sq *io_sq)
+{
+	return container_of(io_sq, struct ena_com_dev, io_sq_queues[io_sq->qid]);
+}
+
+/* ena_com_io_cq_to_ena_dev - Extract ena_com_dev using contained field io_cq.
+ * @io_sq: IO submit queue struct
+ *
+ * @return - ena_com_dev struct extracted from io_sq
+ */
+static inline struct ena_com_dev *ena_com_io_cq_to_ena_dev(struct ena_com_io_cq *io_cq)
+{
+	return container_of(io_cq, struct ena_com_dev, io_cq_queues[io_cq->qid]);
+}
+
 static inline bool ena_com_get_adaptive_moderation_enabled(struct ena_com_dev *ena_dev)
 {
 	return ena_dev->adaptive_coalescing;
drivers/net/ena/base/ena_eth_com.c +52 -26

220 lines not on this page · raw message

drivers/net/ena/base/ena_eth_com.h +11 -6
index 7dda16cd9f..0cfd18882e 100644
@@ -143,7 +143,8 @@ static inline bool ena_com_is_doorbell_needed(struct ena_com_io_sq *io_sq,
 						   llq_info->descs_per_entry);
 	}
 
-	ena_trc_dbg("queue: %d num_descs: %d num_entries_needed: %d\n",
+	ena_trc_dbg(ena_com_io_sq_to_ena_dev(io_sq),
+		    "Queue: %d num_descs: %d num_entries_needed: %d\n",
 		    io_sq->qid, num_descs, num_entries_needed);
 
 	return num_entries_needed > io_sq->entries_in_tx_burst_left;
@@ -154,14 +155,16 @@ static inline int ena_com_write_sq_doorbell(struct ena_com_io_sq *io_sq)
 	u16 max_entries_in_tx_burst = io_sq->llq_info.max_entries_in_tx_burst;
 	u16 tail = io_sq->tail;
 
-	ena_trc_dbg("write submission queue doorbell for queue: %d tail: %d\n",
+	ena_trc_dbg(ena_com_io_sq_to_ena_dev(io_sq),
+		    "Write submission queue doorbell for queue: %d tail: %d\n",
 		    io_sq->qid, tail);
 
 	ENA_REG_WRITE32(io_sq->bus, tail, io_sq->db_addr);
 
 	if (is_llq_max_tx_burst_exists(io_sq)) {
-		ena_trc_dbg("reset available entries in tx burst for queue %d to %d\n",
-			     io_sq->qid, max_entries_in_tx_burst);
+		ena_trc_dbg(ena_com_io_sq_to_ena_dev(io_sq),
+			    "Reset available entries in tx burst for queue %d to %d\n",
+			    io_sq->qid, max_entries_in_tx_burst);
 		io_sq->entries_in_tx_burst_left = max_entries_in_tx_burst;
 	}
 
@@ -179,7 +182,8 @@ static inline int ena_com_update_dev_comp_head(struct ena_com_io_cq *io_cq)
 		need_update = unreported_comp > (io_cq->q_depth / ENA_COMP_HEAD_THRESH);
 
 		if (unlikely(need_update)) {
-			ena_trc_dbg("Write completion queue doorbell for queue %d: head: %d\n",
+			ena_trc_dbg(ena_com_io_cq_to_ena_dev(io_cq),
+				    "Write completion queue doorbell for queue %d: head: %d\n",
 				    io_cq->qid, head);
 			ENA_REG_WRITE32(io_cq->bus, head, io_cq->cq_head_db_reg);
 			io_cq->last_head_update = head;
@@ -243,7 +247,8 @@ static inline int ena_com_tx_comp_req_id_get(struct ena_com_io_cq *io_cq,
 
 	*req_id = READ_ONCE16(cdesc->req_id);
 	if (unlikely(*req_id >= io_cq->q_depth)) {
-		ena_trc_err("Invalid req id %d\n", cdesc->req_id);
+		ena_trc_err(ena_com_io_cq_to_ena_dev(io_cq),
+			    "Invalid req id %d\n", cdesc->req_id);
 		return ENA_COM_INVAL;
 	}
 
drivers/net/ena/base/ena_plat_dpdk.h +24 -20

59 lines not on this page · raw message

Signature · 1 line
2.25.1
#4 lore raw

PATCH 4/22 net/ena/base: typos, style and comments improvements

In reply to Michal Krawczyk

List of changes:
* Comment style was adjusted for the functions
* The keys_num at "struct ena_admin_feature_rss_flow_hash_control" was renamed to the key_parts to better describe it's meaning
* The RSS indirection table was called "REDIRECTION" -> changed to INDIRECTION
* Change AENQ field "syndrom" -> "syndrome"
* Calculate number of the RSS key parts or whole key by ussing the common way: sizeof of the first element of the RSS key
* Add description of the "enum ena_admin_aq_feature_id"
* Rename "map_rx_buf_bidirectional" field as "rx_buf_mirroring"
* Other minor style fixes (remove extra spaces, add missing line break, improve indentation)
* Remove unused macros ENA_ADMIN_EXTRA_PROPERTIES_*
* Restructure the "if {} else if {} else" conditional statement for setting up the meta descriptor

Fixes 99ecfbf845b3 ("ena: import communication layer")
Fixes b68309be44c0 ("net/ena/base: update communication layer for the ENAv2")
Fixes b2b02edeb0d6 ("net/ena/base: upgrade HAL for new HW features")
---
 drivers/net/ena/base/ena_com.c                | 26 +++---
 .../net/ena/base/ena_defs/ena_admin_defs.h    | 85 +++++++++----------
 drivers/net/ena/base/ena_eth_com.c            | 16 ++--
 drivers/net/ena/ena_ethdev.c                  |  4 +-
 4 files changed, 66 insertions(+), 65 deletions(-)
drivers/net/ena/base/ena_com.c +14 -12
index 9931819bbb..9dc9f280c4 100644
@@ -598,7 +598,7 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
 	return ret;
 }
 
-/**
+/*
  * Set the LLQ configurations of the firmware
  *
  * The driver provides only the enabled feature values to the device,
@@ -1092,7 +1092,7 @@ static void ena_com_hash_key_fill_default_key(struct ena_com_dev *ena_dev)
 	/* The key buffer is stored in the device in an array of
 	 * uint32 elements.
 	 */
-	hash_key->keys_num = ENA_ADMIN_RSS_KEY_PARTS;
+	hash_key->key_parts = ENA_ADMIN_RSS_KEY_PARTS;
 }
 
 static int ena_com_hash_key_allocate(struct ena_com_dev *ena_dev)
@@ -1165,7 +1165,7 @@ static int ena_com_indirect_table_allocate(struct ena_com_dev *ena_dev,
 	int ret;
 
 	ret = ena_com_get_feature(ena_dev, &get_resp,
-				  ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG, 0);
+				  ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG, 0);
 	if (unlikely(ret))
 		return ret;
 
@@ -1977,6 +1977,7 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev,
 
 	memcpy(&get_feat_ctx->dev_attr, &get_resp.u.dev_attr,
 	       sizeof(get_resp.u.dev_attr));
+
 	ena_dev->supported_features = get_resp.u.dev_attr.supported_features;
 
 	if (ena_dev->supported_features & BIT(ENA_ADMIN_MAX_QUEUES_EXT)) {
@@ -2044,7 +2045,7 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev,
 		return rc;
 
 	rc = ena_com_get_feature(ena_dev, &get_resp,
-				 ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG, 0);
+				 ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG, 0);
 	if (!rc)
 		memcpy(&get_feat_ctx->ind_table, &get_resp.u.ind_table,
 		       sizeof(get_resp.u.ind_table));
@@ -2106,9 +2107,9 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data)
 		timestamp = (u64)aenq_common->timestamp_low |
 			((u64)aenq_common->timestamp_high << 32);
 		ENA_TOUCH(timestamp); /* In case debug is disabled */
-		ena_trc_dbg(ena_dev, "AENQ! Group[%x] Syndrom[%x] timestamp: [%" ENA_PRIu64 "s]\n",
+		ena_trc_dbg(ena_dev, "AENQ! Group[%x] Syndrome[%x] timestamp: [%" ENA_PRIu64 "s]\n",
 			    aenq_common->group,
-			    aenq_common->syndrom,
+			    aenq_common->syndrome,
 			    timestamp);
 
 		/* Handle specific event*/
@@ -2410,7 +2411,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
 			}
 			memcpy(hash_key->key, key, key_len);
 			rss->hash_init_val = init_val;
-			hash_key->keys_num = key_len / sizeof(u32);
+			hash_key->key_parts = key_len / sizeof(hash_key->key[0]);
 		}
 		break;
 	case ENA_ADMIN_CRC32:
@@ -2465,7 +2466,8 @@ int ena_com_get_hash_key(struct ena_com_dev *ena_dev, u8 *key)
 		ena_dev->rss.hash_key;
 
 	if (key)
-		memcpy(key, hash_key->key, (size_t)(hash_key->keys_num) << 2);
+		memcpy(key, hash_key->key,
+		       (size_t)(hash_key->key_parts) * sizeof(hash_key->key[0]));
 
 	return 0;
 }
@@ -2660,9 +2662,9 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 	int ret;
 
 	if (!ena_com_check_supported_feature_id(ena_dev,
-						ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG)) {
+						ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG)) {
 		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
-			    ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG);
+			    ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG);
 		return ENA_COM_UNSUPPORTED;
 	}
 
@@ -2677,7 +2679,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 	cmd.aq_common_descriptor.opcode = ENA_ADMIN_SET_FEATURE;
 	cmd.aq_common_descriptor.flags =
 		ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_INDIRECT_MASK;
-	cmd.feat_common.feature_id = ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG;
+	cmd.feat_common.feature_id = ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG;
 	cmd.u.ind_table.size = rss->tbl_log_size;
 	cmd.u.ind_table.inline_index = 0xFFFFFFFF;
 
@@ -2715,7 +2717,7 @@ int ena_com_indirect_table_get(struct ena_com_dev *ena_dev, u32 *ind_tbl)
 		sizeof(struct ena_admin_rss_ind_table_entry);
 
 	rc = ena_com_get_feature_ex(ena_dev, &get_resp,
-				    ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG,
+				    ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG,
 				    rss->rss_ind_tbl_dma_addr,
 				    tbl_size, 0);
 	if (unlikely(rc))
drivers/net/ena/base/ena_defs/ena_admin_defs.h +41 -44

224 lines not on this page · raw message

drivers/net/ena/base/ena_eth_com.c +9 -7
index 701e6721e3..92a9a10a9e 100644
@@ -331,16 +331,18 @@ static int ena_com_create_and_store_tx_meta_desc(struct ena_com_io_sq *io_sq,
 
 		*have_meta = true;
 		return ena_com_create_meta(io_sq, ena_meta);
-	} else if (ena_com_meta_desc_changed(io_sq, ena_tx_ctx)) {
+	}
+
+	if (ena_com_meta_desc_changed(io_sq, ena_tx_ctx)) {
 		*have_meta = true;
 		/* Cache the meta desc */
 		memcpy(&io_sq->cached_tx_meta, ena_meta,
 		       sizeof(struct ena_com_tx_meta));
 		return ena_com_create_meta(io_sq, ena_meta);
-	} else {
-		*have_meta = false;
-		return ENA_COM_OK;
 	}
+
+	*have_meta = false;
+	return ENA_COM_OK;
 }
 
 static void ena_com_rx_set_flags(struct ena_com_io_cq *io_cq,
@@ -626,9 +628,9 @@ int ena_com_add_single_rx_desc(struct ena_com_io_sq *io_sq,
 	desc->length = ena_buf->len;
 
 	desc->ctrl = ENA_ETH_IO_RX_DESC_FIRST_MASK |
-		ENA_ETH_IO_RX_DESC_LAST_MASK |
-		(io_sq->phase & ENA_ETH_IO_RX_DESC_PHASE_MASK) |
-		ENA_ETH_IO_RX_DESC_COMP_REQ_MASK;
+		     ENA_ETH_IO_RX_DESC_LAST_MASK |
+		     ENA_ETH_IO_RX_DESC_COMP_REQ_MASK |
+		     (io_sq->phase & ENA_ETH_IO_RX_DESC_PHASE_MASK);
 
 	desc->req_id = req_id;
 
drivers/net/ena/ena_ethdev.c +2 -2
index f60e843b7f..f1ff4dad36 100644
@@ -2973,7 +2973,7 @@ static void ena_notification(void *data,
 			aenq_e->aenq_common_desc.group,
 			ENA_ADMIN_NOTIFICATION);
 
-	switch (aenq_e->aenq_common_desc.syndrom) {
+	switch (aenq_e->aenq_common_desc.syndrome) {
 	case ENA_ADMIN_UPDATE_HINTS:
 		hints = (struct ena_admin_ena_hw_hints *)
 			(&aenq_e->inline_data_w4);
@@ -2981,7 +2981,7 @@ static void ena_notification(void *data,
 		break;
 	default:
 		PMD_DRV_LOG(ERR, "Invalid aenq notification link state %d\n",
-			aenq_e->aenq_common_desc.syndrom);
+			aenq_e->aenq_common_desc.syndrome);
 	}
 }
 
Signature · 1 line
2.25.1
#5 lore raw

PATCH 5/22 net/ena/base: fix issues from the static code scan

In reply to Michal Krawczyk

To silence error messages from the static code analysis, make the type conversions explicit where they're intended.

Also fix the type for the DMA width value.

Fixes 99ecfbf845b3 ("ena: import communication layer")
---
 drivers/net/ena/base/ena_com.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ena/base/ena_com.c +5 -5
index 9dc9f280c4..0cdeb1a2d9 100644
@@ -1382,7 +1382,7 @@ int ena_com_execute_admin_command(struct ena_com_admin_queue *admin_queue,
 				    "Failed to submit command [%ld]\n",
 				    PTR_ERR(comp_ctx));
 
-		return PTR_ERR(comp_ctx);
+		return (int)PTR_ERR(comp_ctx);
 	}
 
 	ret = ena_com_wait_and_process_admin_cq(comp_ctx, admin_queue);
@@ -1602,7 +1602,7 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_dev, u32 groups_flag)
 int ena_com_get_dma_width(struct ena_com_dev *ena_dev)
 {
 	u32 caps = ena_com_reg_bar_read32(ena_dev, ENA_REGS_CAPS_OFF);
-	int width;
+	u32 width;
 
 	if (unlikely(caps == ENA_MMIO_READ_TIMEOUT)) {
 		ena_trc_err(ena_dev, "Reg read timeout occurred\n");
@@ -2280,7 +2280,7 @@ int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu)
 	cmd.aq_common_descriptor.opcode = ENA_ADMIN_SET_FEATURE;
 	cmd.aq_common_descriptor.flags = 0;
 	cmd.feat_common.feature_id = ENA_ADMIN_MTU;
-	cmd.u.mtu.mtu = mtu;
+	cmd.u.mtu.mtu = (u32)mtu;
 
 	ret = ena_com_execute_admin_command(admin_queue,
 					    (struct ena_admin_aq_entry *)&cmd,
@@ -2691,7 +2691,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 		return ret;
 	}
 
-	cmd.control_buffer.length = (1ULL << rss->tbl_log_size) *
+	cmd.control_buffer.length = (u32)(1ULL << rss->tbl_log_size) *
 		sizeof(struct ena_admin_rss_ind_table_entry);
 
 	ret = ena_com_execute_admin_command(admin_queue,
@@ -2713,7 +2713,7 @@ int ena_com_indirect_table_get(struct ena_com_dev *ena_dev, u32 *ind_tbl)
 	u32 tbl_size;
 	int i, rc;
 
-	tbl_size = (1ULL << rss->tbl_log_size) *
+	tbl_size = (u32)(1ULL << rss->tbl_log_size) *
 		sizeof(struct ena_admin_rss_ind_table_entry);
 
 	rc = ena_com_get_feature_ex(ena_dev, &get_resp,
Signature · 1 line
2.25.1
#6 lore raw

PATCH 6/22 net/ena/base: destroy multiple "wait events"

In reply to Michal Krawczyk

Although the ENA DPDK PMD doesn't have to perform any actions for destroying the wait event, some other platforms have to.

The macro "ENA_WAIT_EVENT_DESTROY" was renamed to "ENA_WAIT_EVENTS_DESTROY" and also whole implementation responsible for that was moved to a separate function for better readability.

Fixes 3adcba9a8987 ("net/ena: update HAL to the newer version")
---
 drivers/net/ena/base/ena_com.c       | 24 +++++++++++++++++-------
 drivers/net/ena/base/ena_plat_dpdk.h |  4 ++--
 2 files changed, 19 insertions(+), 9 deletions(-)
drivers/net/ena/base/ena_com.c +17 -7
index 0cdeb1a2d9..d025c9cee1 100644
@@ -1671,6 +1671,22 @@ int ena_com_validate_version(struct ena_com_dev *ena_dev)
 	return 0;
 }
 
+static void
+ena_com_free_ena_admin_queue_comp_ctx(struct ena_com_dev *ena_dev,
+				      struct ena_com_admin_queue *admin_queue)
+
+{
+	if (!admin_queue->comp_ctx)
+		return;
+
+	ENA_WAIT_EVENTS_DESTROY(admin_queue);
+	ENA_MEM_FREE(ena_dev->dmadev,
+		     admin_queue->comp_ctx,
+		     (admin_queue->q_depth * sizeof(struct ena_comp_ctx)));
+
+	admin_queue->comp_ctx = NULL;
+}
+
 void ena_com_admin_destroy(struct ena_com_dev *ena_dev)
 {
 	struct ena_com_admin_queue *admin_queue = &ena_dev->admin_queue;
@@ -1679,14 +1695,8 @@ void ena_com_admin_destroy(struct ena_com_dev *ena_dev)
 	struct ena_com_aenq *aenq = &ena_dev->aenq;
 	u16 size;
 
-	if (admin_queue->comp_ctx) {
-		ENA_WAIT_EVENT_DESTROY(admin_queue->comp_ctx->wait_event);
-		ENA_MEM_FREE(ena_dev->dmadev,
-			     admin_queue->comp_ctx,
-			     (admin_queue->q_depth * sizeof(struct ena_comp_ctx)));
-	}
+	ena_com_free_ena_admin_queue_comp_ctx(ena_dev, admin_queue);
 
-	admin_queue->comp_ctx = NULL;
 	size = ADMIN_SQ_SIZE(admin_queue->q_depth);
 	if (sq->entries)
 		ENA_MEM_FREE_COHERENT(ena_dev->dmadev, size, sq->entries,
drivers/net/ena/base/ena_plat_dpdk.h +2 -2
index 9d69190c83..bfc0a658ef 100644
@@ -163,7 +163,7 @@ extern int ena_logtype_com;
 #define ENA_WAIT_EVENT_SIGNAL(waitevent) pthread_cond_signal(&waitevent.cond)
 /* pthread condition doesn't need to be rearmed after usage */
 #define ENA_WAIT_EVENT_CLEAR(...)
-#define ENA_WAIT_EVENT_DESTROY(waitqueue) ((void)(waitqueue))
+#define ENA_WAIT_EVENT_DESTROY(admin_queue) ((void)(admin_queue))
 
 #define ena_wait_event_t ena_wait_queue_t
 #define ENA_MIGHT_SLEEP()
@@ -295,7 +295,7 @@ extern rte_atomic32_t ena_alloc_cnt;
 #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_WAIT_EVENT_DESTROY(waitqueue) ((void)(waitqueue))
+#define ENA_WAIT_EVENTS_DESTROY(waitqueue) ((void)(waitqueue))
 
 #ifndef READ_ONCE
 #define READ_ONCE(var) (*((volatile typeof(var) *)(&(var))))
Signature · 1 line
2.25.1
#7 lore raw

PATCH 7/22 net/ena/base: remove indir table from ENA feat ctx

In reply to Michal Krawczyk

The RSS indirection table shouldn't be included as a part of the device features context.

If the driver has to acquire it, it can be done using the separate API whenever the RSS configuration is needed.

---
 drivers/net/ena/base/ena_com.c | 11 -----------
 drivers/net/ena/base/ena_com.h |  1 -
 2 files changed, 12 deletions(-)
drivers/net/ena/base/ena_com.c +0 -11
index d025c9cee1..5ca36ab6d9 100644
@@ -2054,17 +2054,6 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev,
 	else
 		return rc;
 
-	rc = ena_com_get_feature(ena_dev, &get_resp,
-				 ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG, 0);
-	if (!rc)
-		memcpy(&get_feat_ctx->ind_table, &get_resp.u.ind_table,
-		       sizeof(get_resp.u.ind_table));
-	else if (rc == ENA_COM_UNSUPPORTED)
-		memset(&get_feat_ctx->ind_table, 0x0,
-		       sizeof(get_feat_ctx->ind_table));
-	else
-		return rc;
-
 	return 0;
 }
 
drivers/net/ena/base/ena_com.h +0 -1
index cd116e90e6..ca84e2e8bc 100644
@@ -338,7 +338,6 @@ struct ena_com_dev_get_features_ctx {
 	struct ena_admin_feature_offload_desc offload;
 	struct ena_admin_ena_hw_hints hw_hints;
 	struct ena_admin_feature_llq_desc llq;
-	struct ena_admin_feature_rss_ind_table ind_table;
 };
 
 struct ena_com_create_io_ctx {
Signature · 1 line
2.25.1
#8 lore raw

PATCH 8/22 net/ena/base: remove mutable RSS from the host info

In reply to Michal Krawczyk

This feature wasn't used by any of the drivers. Because of that, it was removed.

---
 drivers/net/ena/base/ena_defs/ena_admin_defs.h | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/net/ena/base/ena_defs/ena_admin_defs.h +1 -12
index 40c2db717c..56768e1a1b 100644
@@ -866,7 +866,7 @@ struct ena_admin_host_info {
 
 	uint16_t reserved;
 
-	/* 0 : mutable_rss_table_size
+	/* 0 : reserved
 	 * 1 : rx_offset
 	 * 2 : interrupt_moderation
 	 * 3 : rx_buf_mirroring
@@ -1189,7 +1189,6 @@ struct ena_admin_ena_mmio_req_read_less_resp {
 #define ENA_ADMIN_HOST_INFO_DEVICE_MASK                     GENMASK(7, 3)
 #define ENA_ADMIN_HOST_INFO_BUS_SHIFT                       8
 #define ENA_ADMIN_HOST_INFO_BUS_MASK                        GENMASK(15, 8)
-#define ENA_ADMIN_HOST_INFO_MUTABLE_RSS_TABLE_SIZE_MASK     BIT(0)
 #define ENA_ADMIN_HOST_INFO_RX_OFFSET_SHIFT                 1
 #define ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK                  BIT(1)
 #define ENA_ADMIN_HOST_INFO_INTERRUPT_MODERATION_SHIFT      2
@@ -1619,16 +1618,6 @@ static inline void set_ena_admin_host_info_bus(struct ena_admin_host_info *p, ui
 	p->bdf |= (val << ENA_ADMIN_HOST_INFO_BUS_SHIFT) & ENA_ADMIN_HOST_INFO_BUS_MASK;
 }
 
-static inline uint32_t get_ena_admin_host_info_mutable_rss_table_size(const struct ena_admin_host_info *p)
-{
-	return p->driver_supported_features & ENA_ADMIN_HOST_INFO_MUTABLE_RSS_TABLE_SIZE_MASK;
-}
-
-static inline void set_ena_admin_host_info_mutable_rss_table_size(struct ena_admin_host_info *p, uint32_t val)
-{
-	p->driver_supported_features |= val & ENA_ADMIN_HOST_INFO_MUTABLE_RSS_TABLE_SIZE_MASK;
-}
-
 static inline uint32_t get_ena_admin_host_info_rx_offset(const struct ena_admin_host_info *p)
 {
 	return (p->driver_supported_features & ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK) >> ENA_ADMIN_HOST_INFO_RX_OFFSET_SHIFT;
Signature · 1 line
2.25.1
#9 lore raw

PATCH 9/22 net/ena/base: update generation date and commit

In reply to Michal Krawczyk

The current ena_com version was generated on 18.09.2020.

---
 drivers/net/ena/base/ena_defs/ena_gen_info.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ena/base/ena_defs/ena_gen_info.h +2 -2
index 54bbfda11f..49895108d5 100644
@@ -2,5 +2,5 @@
  * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates.
  * All rights reserved.
  */
-#define	ENA_GEN_DATE	"Sun Apr 26 13:45:21 DST 2020"
-#define	ENA_GEN_COMMIT	"37aa7c3"
+#define	ENA_GEN_DATE	"Fri Sep 18 17:09:00 IDT 2020"
+#define	ENA_GEN_COMMIT	"0f80d82"
Signature · 1 line
2.25.1
#10 lore raw

PATCH 10/22 net/ena/base: use rte_prefetch0_write

In reply to Michal Krawczyk

As in the v20.11 rte_prefetch0_write API was added, it should be used in the platform file for the definition of the macro prefetchw, instead of using simply prefetch0.

---
 drivers/net/ena/base/ena_plat_dpdk.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ena/base/ena_plat_dpdk.h +1 -1
index bfc0a658ef..1eec4f0c72 100644
@@ -287,7 +287,7 @@ extern rte_atomic32_t ena_alloc_cnt;
 #define might_sleep()
 
 #define prefetch(x) rte_prefetch0(x)
-#define prefetchw(x) prefetch(x)
+#define prefetchw(x) rte_prefetch0_write(x)
 
 #define lower_32_bits(x) ((uint32_t)(x))
 #define upper_32_bits(x) ((uint32_t)(((x) >> 16) >> 16))
Signature · 1 line
2.25.1
#11 lore raw

PATCH 11/22 net/ena/base: adjust changes to lastest ena-com

In reply to Michal Krawczyk

From: Amit Bernstein <[email protected]>

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

---
 drivers/net/ena/base/ena_plat_dpdk.h | 242 +++++++++++++--------------
 drivers/net/ena/ena_ethdev.c         |   2 +-
 2 files changed, 114 insertions(+), 130 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +113 -129
index 1eec4f0c72..2e40ea1bb4 100644
@@ -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 *
 
@@ -73,7 +75,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;
@@ -92,15 +94,15 @@ 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...)				\
+#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))		\
+		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)
@@ -114,51 +116,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)				\
+#define ENA_SPINLOCK_LOCK(spinlock, flags)				       \
 	({(void)flags; rte_spinlock_lock(&spinlock); })
-#define ENA_SPINLOCK_UNLOCK(spinlock, flags)				\
+#define ENA_SPINLOCK_UNLOCK(spinlock, flags)				       \
 	({(void)flags; rte_spinlock_unlock(&(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 */
@@ -170,104 +172,88 @@ 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)
@@ -293,7 +279,7 @@ 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)				\
+#define ENA_GET_SYSTEM_TIMEOUT(timeout_us)				       \
     (timeout_us * rte_get_timer_hz() / 1000000 + rte_get_timer_cycles())
 #define ENA_WAIT_EVENTS_DESTROY(waitqueue) ((void)(waitqueue))
 
@@ -306,14 +292,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))
@@ -326,7 +312,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_ */
drivers/net/ena/ena_ethdev.c +1 -1
index f1ff4dad36..3c9102cd19 100644
@@ -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),
Signature · 1 line
2.25.1
#12 lore raw

PATCH 12/22 net/ena: fix parsing of large_llq_hdr argument

In reply to Michal Krawczyk

From: Igor Chauskin <[email protected]>

The code incorrectly checked the return value of comparison when parsing the argument key name. The return value of strcmp should be compared to 0 to identify a match.

Fixes 8a7a73f26cc9 ("net/ena: support large LLQ headers")
---
 drivers/net/ena/ena_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ena/ena_ethdev.c +1 -1
index 3c9102cd19..cb8ad5c3d0 100644
@@ -2865,7 +2865,7 @@ static int ena_process_bool_devarg(const char *key,
 	}
 
 	/* Now, assign it to the proper adapter field. */
-	if (strcmp(key, ENA_DEVARG_LARGE_LLQ_HDR))
+	if (strcmp(key, ENA_DEVARG_LARGE_LLQ_HDR) == 0)
 		adapter->use_large_llq_hdr = bool_value;
 
 	return 0;
Signature · 1 line
2.25.1
#13 lore raw

PATCH 13/22 net/ena: terminate devargs allowed keys with NULL

In reply to Michal Krawczyk

As the documentation of rte_kvargs_parse() states, the valid_keys argument must be NULL terminated. Lack of this feature may cause segmentation fault if the passed devarg will be different then the supported value.

Fixes 8a7a73f26cc9 ("net/ena: support large LLQ headers")
---
 drivers/net/ena/ena_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ena/ena_ethdev.c +1 -0
index cb8ad5c3d0..6092288239 100644
@@ -2876,6 +2876,7 @@ static int ena_parse_devargs(struct ena_adapter *adapter,
 {
 	static const char * const allowed_args[] = {
 		ENA_DEVARG_LARGE_LLQ_HDR,
+		NULL,
 	};
 	struct rte_kvargs *kvlist;
 	int rc;
Signature · 1 line
2.25.1
#14 lore raw

PATCH 14/22 net/ena: indicate Rx RSS hash presence

In reply to Michal Krawczyk

To make it possible to the app to determine if the hash was calculated for the packet or not, the PKT_RX_RSS_HASH should be set in the mbuf's ol_flags.

As the PMD wasn't setting that, the application couldn't check if there is a hash in a proper way.

The hash is valid only if it's UDP or TCP and the IP packet wasn't fragmented.

Fixes e5df9f33db00 ("net/ena: fix passing RSS hash to mbuf")
---
 drivers/net/ena/ena_ethdev.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ena/ena_ethdev.c +7 -2
index 6092288239..5d107775f4 100644
@@ -51,6 +51,8 @@
 
 #define ENA_MIN_RING_DESC	128
 
+#define ENA_PTYPE_HAS_HASH	(RTE_PTYPE_L4_TCP | RTE_PTYPE_L4_UDP)
+
 enum ethtool_stringset {
 	ETH_SS_TEST             = 0,
 	ETH_SS_STATS,
@@ -314,6 +316,11 @@ static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
 		else
 			ol_flags |= PKT_RX_L4_CKSUM_GOOD;
 
+	if (likely((packet_type & ENA_PTYPE_HAS_HASH) && !ena_rx_ctx->frag)) {
+		ol_flags |= PKT_RX_RSS_HASH;
+		mbuf->hash.rss = ena_rx_ctx->hash;
+	}
+
 	mbuf->ol_flags = ol_flags;
 	mbuf->packet_type = packet_type;
 }
@@ -2245,8 +2252,6 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 			++rx_ring->rx_stats.bad_csum;
 		}
 
-		mbuf->hash.rss = ena_rx_ctx.hash;
-
 		rx_pkts[completed] = mbuf;
 		rx_ring->rx_stats.bytes += mbuf->pkt_len;
 	}
Signature · 1 line
2.25.1
#15 lore raw

PATCH 15/22 net/ena: remove endian swap functions

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

swap*_*_le() functions are not used anywhere and besides there are rte alternatives already present.

Fixes 1173fca25af9 ("ena: add polling-mode driver")
---
 drivers/net/ena/ena_platform.h | 12 ------------
 1 file changed, 12 deletions(-)
drivers/net/ena/ena_platform.h +0 -12
index d3e40e0e9e..748928b2d9 100644
@@ -6,18 +6,6 @@
 #ifndef __ENA_PLATFORM_H__
 #define __ENA_PLATFORM_H__
 
-#define swap16_to_le(x)		(x)
-
-#define swap32_to_le(x)		(x)
-
-#define swap64_to_le(x)		(x)
-
-#define swap16_from_le(x)       (x)
-
-#define swap32_from_le(x)	(x)
-
-#define swap64_from_le(x)	(x)
-
 #define ena_assert_msg(cond, msg)		\
 	do {					\
 		if (unlikely(!(cond))) {	\
Signature · 1 line
2.25.1
#16 lore raw

PATCH 16/22 net/ena: handle spurious wakeups in ENA_WAIT_EVENT

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

pthread_cond_timedwait() may spuriously wakeup according to POSIX. Therefore it is required to check whether predicate is actually true before finishing the waiting loop.

---
 drivers/net/ena/base/ena_plat_dpdk.h | 75 +++++++++++++++++-----------
 1 file changed, 47 insertions(+), 28 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +47 -28
index 2e40ea1bb4..2e2cd0736c 100644
@@ -74,6 +74,14 @@ typedef uint64_t dma_addr_t;
 #define mmiowb rte_io_wmb
 #define __iomem
 
+#ifndef READ_ONCE
+#define READ_ONCE(var) (*((volatile typeof(var) *)(&(var))))
+#endif
+
+#define READ_ONCE8(var) READ_ONCE(var)
+#define READ_ONCE16(var) READ_ONCE(var)
+#define READ_ONCE32(var) READ_ONCE(var)
+
 #define US_PER_S 1000000
 #define ENA_GET_SYSTEM_USECS()						       \
 	(rte_get_timer_cycles() * US_PER_S / rte_get_timer_hz())
@@ -134,40 +142,59 @@ extern int ena_logtype_com;
 	({(void)flags; rte_spinlock_unlock(&(spinlock)); })
 #define ENA_SPINLOCK_DESTROY(spinlock) ((void)spinlock)
 
-#define q_waitqueue_t							       \
-	struct {							       \
-		pthread_cond_t cond;					       \
-		pthread_mutex_t mutex;					       \
-	}
+typedef struct {
+	pthread_cond_t cond;
+	pthread_mutex_t mutex;
+	uint8_t flag;
+} ena_wait_event_t;
 
-#define ena_wait_queue_t q_waitqueue_t
-
-#define ENA_WAIT_EVENT_INIT(waitqueue)					       \
+#define ENA_WAIT_EVENT_INIT(waitevent)					       \
 	do {								       \
-		pthread_mutex_init(&(waitqueue).mutex, NULL);		       \
-		pthread_cond_init(&(waitqueue).cond, NULL);		       \
+		ena_wait_event_t *_we = &(waitevent);			       \
+		pthread_mutex_init(&_we->mutex, NULL);			       \
+		pthread_cond_init(&_we->cond, NULL);			       \
+		_we->flag = 0;						       \
 	} while (0)
 
 #define ENA_WAIT_EVENT_WAIT(waitevent, timeout)				       \
 	do {								       \
+		ena_wait_event_t *_we = &(waitevent);			       \
+		typeof(timeout) _tmo = (timeout);			       \
+		int ret = 0;						       \
 		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_sec = now.tv_sec + _tmo / 1000000UL;		       \
+		timeout_us = _tmo % 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);			       \
+		pthread_mutex_lock(&_we->mutex);			       \
+		while (ret == 0 && !_we->flag) {			       \
+			ret = pthread_cond_timedwait(&_we->cond,	       \
+				&_we->mutex, &wait);			       \
+		}							       \
+		/* Asserts only if not working on ena_wait_event_t */	       \
+		if (unlikely(ret != 0 && ret != ETIMEDOUT))		       \
+			rte_panic("Invalid wait event. pthread ret: %d\n",     \
+				  ret);					       \
+		else if (unlikely(ret == ETIMEDOUT))			       \
+			ena_trc_err(NULL,				       \
+				"Timeout waiting for " #waitevent "\n");       \
+		_we->flag = 0;						       \
+		pthread_mutex_unlock(&_we->mutex);			       \
+	} while (0)
+#define ENA_WAIT_EVENT_SIGNAL(waitevent)				       \
+	do {								       \
+		ena_wait_event_t *_we = &(waitevent);			       \
+		pthread_mutex_lock(&_we->mutex);			       \
+		_we->flag = 1;						       \
+		pthread_cond_signal(&_we->cond);			       \
+		pthread_mutex_unlock(&_we->mutex);			       \
 	} while (0)
-#define ENA_WAIT_EVENT_SIGNAL(waitevent) pthread_cond_signal(&waitevent.cond)
 /* pthread condition doesn't need to be rearmed after usage */
 #define ENA_WAIT_EVENT_CLEAR(...)
-#define ENA_WAIT_EVENT_DESTROY(admin_queue) ((void)(admin_queue))
+#define ENA_WAIT_EVENT_DESTROY(waitevent) ((void)(waitevent))
 
-#define ena_wait_event_t ena_wait_queue_t
 #define ENA_MIGHT_SLEEP()
 
 #define ena_time_t uint64_t
@@ -281,15 +308,7 @@ extern rte_atomic64_t ena_alloc_cnt;
 #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_WAIT_EVENTS_DESTROY(waitqueue) ((void)(waitqueue))
-
-#ifndef READ_ONCE
-#define READ_ONCE(var) (*((volatile typeof(var) *)(&(var))))
-#endif
-
-#define READ_ONCE8(var) READ_ONCE(var)
-#define READ_ONCE16(var) READ_ONCE(var)
-#define READ_ONCE32(var) READ_ONCE(var)
+#define ENA_WAIT_EVENTS_DESTROY(admin_queue) ((void)(admin_queue))
 
 /* The size must be 8 byte align */
 #define ENA_MEMCPY_TO_DEVICE_64(dst, src, size)				       \
Signature · 1 line
2.25.1
#17 lore raw

PATCH 17/22 net/ena: support SMP for mz alloc counter

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

Introduce a memory area for ENA driver shared between all the processes of a same prefix (memzone backed).
Move the memzone allocation counter for ENA_MEM_ALLOC_COHERENT there so that all processes may utilize it.

---
 drivers/net/ena/base/ena_plat_dpdk.h |  6 ++--
 drivers/net/ena/ena_ethdev.c         | 46 +++++++++++++++++++++++++++-
 drivers/net/ena/ena_ethdev.h         |  8 +++++
 3 files changed, 56 insertions(+), 4 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +3 -3
index 2e2cd0736c..1282c05f59 100644
@@ -206,7 +206,7 @@ typedef struct {
  * Each rte_memzone should have unique name.
  * To satisfy it, count number of allocations and add it to name.
  */
-extern rte_atomic64_t ena_alloc_cnt;
+extern rte_atomic64_t *ena_alloc_cnt;
 
 #define ENA_MEM_ALLOC_COHERENT_ALIGNED(					       \
 	dmadev, size, virt, phys, mem_handle, alignment)		       \
@@ -216,7 +216,7 @@ extern rte_atomic64_t ena_alloc_cnt;
 		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));   \
+				rte_atomic64_add_return(ena_alloc_cnt, 1));    \
 			mz = rte_memzone_reserve_aligned(z_name, size,	       \
 					SOCKET_ID_ANY, RTE_MEMZONE_IOVA_CONTIG,\
 					alignment);			       \
@@ -246,7 +246,7 @@ extern rte_atomic64_t ena_alloc_cnt;
 		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));   \
+				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;				       \
drivers/net/ena/ena_ethdev.c +45 -1

68 lines not on this page · raw message

drivers/net/ena/ena_ethdev.h +8 -0
index ae235897ee..e8858c6118 100644
@@ -207,6 +207,14 @@ struct ena_offloads {
 	bool rx_csum_supported;
 };
 
+/* Holds data shared between all instances of ENA PMD. */
+struct ena_shared_data {
+	/* Each rte_memzone should have unique name.
+	 * To satisfy it, count number of allocation and add it to name.
+	 */
+	rte_atomic64_t mz_alloc_cnt;
+};
+
 /* board specific private data structure */
 struct ena_adapter {
 	/* OS defined structs */
Signature · 1 line
2.25.1
#18 lore raw

PATCH 18/22 net/ena: move default RSS key to shared mem

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

Make sure the same random generated RSS key is available to all ENA PMD instances in all processes.

---
 drivers/net/ena/ena_ethdev.c | 16 +++++-----------
 drivers/net/ena/ena_ethdev.h |  1 +
 2 files changed, 6 insertions(+), 11 deletions(-)
drivers/net/ena/ena_ethdev.c +5 -11
index 0780e2fee2..5c365e1ab5 100644
@@ -276,19 +276,9 @@ static const struct eth_dev_ops ena_dev_ops = {
 
 void ena_rss_key_fill(void *key, size_t size)
 {
-	static bool key_generated;
-	static uint8_t default_key[ENA_HASH_KEY_SIZE];
-	size_t i;
-
 	RTE_ASSERT(size <= ENA_HASH_KEY_SIZE);
 
-	if (!key_generated) {
-		for (i = 0; i < ENA_HASH_KEY_SIZE; ++i)
-			default_key[i] = rte_rand() & 0xff;
-		key_generated = true;
-	}
-
-	rte_memcpy(key, default_key, size);
+	rte_memcpy(key, ena_shared_data->default_key, size);
 }
 
 static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
@@ -1758,7 +1748,11 @@ static uint32_t ena_calc_max_io_queue_num(struct ena_com_dev *ena_dev,
 
 static void ena_prepare_shared_data(struct ena_shared_data *shared_data)
 {
+	size_t i;
+
 	memset(shared_data, 0, sizeof(*shared_data));
+	for (i = 0; i < ENA_HASH_KEY_SIZE; ++i)
+		shared_data->default_key[i] = rte_rand() & 0xff;
 }
 
 static int ena_shared_data_init(void)
drivers/net/ena/ena_ethdev.h +1 -0
index e8858c6118..1f7383dce0 100644
@@ -209,6 +209,7 @@ struct ena_offloads {
 
 /* Holds data shared between all instances of ENA PMD. */
 struct ena_shared_data {
+	uint8_t default_key[ENA_HASH_KEY_SIZE];
 	/* Each rte_memzone should have unique name.
 	 * To satisfy it, count number of allocation and add it to name.
 	 */
Signature · 1 line
2.25.1
#19 lore raw

PATCH 19/22 net/ena: make ethdev references smp safe

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

rte_pci_device and rte_eth_dev are process-local structures. Therefore ena_adapter::pdev and ena_adapter::rte_dev cannot be used universally. Switch this to extracting those structures via rte_eth_devices indexing and remove pdev since it's not used outside of init.

---
 drivers/net/ena/ena_ethdev.c | 47 ++++++++++++++++++------------------
 drivers/net/ena/ena_ethdev.h |  5 ++--
 2 files changed, 25 insertions(+), 27 deletions(-)
drivers/net/ena/ena_ethdev.c +23 -24
index 5c365e1ab5..90ea40513a 100644
@@ -168,6 +168,7 @@ static const struct rte_pci_id pci_id_ena_map[] = {
 static struct ena_aenq_handlers aenq_handlers;
 
 static int ena_device_init(struct ena_com_dev *ena_dev,
+			   struct rte_pci_device *pdev,
 			   struct ena_com_dev_get_features_ctx *get_feat_ctx,
 			   bool *wd_state);
 static int ena_dev_configure(struct rte_eth_dev *dev);
@@ -451,11 +452,11 @@ static void ena_config_host_info(struct ena_com_dev *ena_dev)
 }
 
 /* This function calculates the number of xstats based on the current config */
-static unsigned int ena_xstats_calc_num(struct rte_eth_dev *dev)
+static unsigned int ena_xstats_calc_num(struct rte_eth_dev_data *data)
 {
 	return ENA_STATS_ARRAY_GLOBAL + ENA_STATS_ARRAY_ENI +
-		(dev->data->nb_tx_queues * ENA_STATS_ARRAY_TX) +
-		(dev->data->nb_rx_queues * ENA_STATS_ARRAY_RX);
+		(data->nb_tx_queues * ENA_STATS_ARRAY_TX) +
+		(data->nb_rx_queues * ENA_STATS_ARRAY_RX);
 }
 
 static void ena_config_debug_area(struct ena_adapter *adapter)
@@ -463,7 +464,7 @@ static void ena_config_debug_area(struct ena_adapter *adapter)
 	u32 debug_area_size;
 	int rc, ss_count;
 
-	ss_count = ena_xstats_calc_num(adapter->rte_dev);
+	ss_count = ena_xstats_calc_num(adapter->edev_data);
 
 	/* allocate 32 bytes for each string and 64bit for the value */
 	debug_area_size = ss_count * ETH_GSTRING_LEN + sizeof(u64) * ss_count;
@@ -587,7 +588,7 @@ static int ena_rss_reta_update(struct rte_eth_dev *dev,
 	}
 
 	PMD_DRV_LOG(DEBUG, "%s(): RSS configured %d entries  for port %d\n",
-		__func__, reta_size, adapter->rte_dev->data->port_id);
+		__func__, reta_size, dev->data->port_id);
 
 	return 0;
 }
@@ -631,7 +632,7 @@ static int ena_rss_reta_query(struct rte_eth_dev *dev,
 static int ena_rss_init_default(struct ena_adapter *adapter)
 {
 	struct ena_com_dev *ena_dev = &adapter->ena_dev;
-	uint16_t nb_rx_queues = adapter->rte_dev->data->nb_rx_queues;
+	uint16_t nb_rx_queues = adapter->edev_data->nb_rx_queues;
 	int rc, i;
 	u32 val;
 
@@ -669,8 +670,7 @@ static int ena_rss_init_default(struct ena_adapter *adapter)
 		PMD_DRV_LOG(ERR, "Cannot flush the indirect table\n");
 		goto err_fill_indir;
 	}
-	PMD_DRV_LOG(DEBUG, "RSS configured for port %d\n",
-		adapter->rte_dev->data->port_id);
+	PMD_DRV_LOG(DEBUG, "RSS configured for port %d\n", adapter->port_id);
 
 	return 0;
 
@@ -841,10 +841,10 @@ static uint32_t ena_get_mtu_conf(struct ena_adapter *adapter)
 {
 	uint32_t max_frame_len = adapter->max_mtu;
 
-	if (adapter->rte_eth_dev_data->dev_conf.rxmode.offloads &
+	if (adapter->edev_data->dev_conf.rxmode.offloads &
 	    DEV_RX_OFFLOAD_JUMBO_FRAME)
 		max_frame_len =
-			adapter->rte_eth_dev_data->dev_conf.rxmode.max_rx_pkt_len;
+			adapter->edev_data->dev_conf.rxmode.max_rx_pkt_len;
 
 	return max_frame_len;
 }
@@ -1064,8 +1064,8 @@ static int ena_start(struct rte_eth_dev *dev)
 	if (rc)
 		goto err_start_tx;
 
-	if (adapter->rte_dev->data->dev_conf.rxmode.mq_mode &
-	    ETH_MQ_RX_RSS_FLAG && adapter->rte_dev->data->nb_rx_queues > 0) {
+	if (adapter->edev_data->dev_conf.rxmode.mq_mode &
+	    ETH_MQ_RX_RSS_FLAG && adapter->edev_data->nb_rx_queues > 0) {
 		rc = ena_rss_init_default(adapter);
 		if (rc)
 			goto err_rss_init;
@@ -1505,6 +1505,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count)
 }
 
 static int ena_device_init(struct ena_com_dev *ena_dev,
+			   struct rte_pci_device *pdev,
 			   struct ena_com_dev_get_features_ctx *get_feat_ctx,
 			   bool *wd_state)
 {
@@ -1522,9 +1523,7 @@ static int ena_device_init(struct ena_com_dev *ena_dev,
 	/* The PCIe configuration space revision id indicate if mmio reg
 	 * read is disabled.
 	 */
-	readless_supported =
-		!(((struct rte_pci_device *)ena_dev->dmadev)->id.class_id
-			       & ENA_MMIO_DISABLE_REG_READ);
+	readless_supported = !(pdev->id.class_id & ENA_MMIO_DISABLE_REG_READ);
 	ena_com_set_mmio_read_mode(ena_dev, readless_supported);
 
 	/* reset device */
@@ -1634,7 +1633,7 @@ static void ena_timer_wd_callback(__rte_unused struct rte_timer *timer,
 				  void *arg)
 {
 	struct ena_adapter *adapter = arg;
-	struct rte_eth_dev *dev = adapter->rte_dev;
+	struct rte_eth_dev *dev = &rte_eth_devices[adapter->port_id];
 
 	check_for_missing_keep_alive(adapter);
 	check_for_admin_com_state(adapter);
@@ -1819,11 +1818,10 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	memset(adapter, 0, sizeof(struct ena_adapter));
 	ena_dev = &adapter->ena_dev;
 
-	adapter->rte_eth_dev_data = eth_dev->data;
-	adapter->rte_dev = eth_dev;
+	adapter->edev_data = eth_dev->data;
+	adapter->port_id = eth_dev->data->port_id;
 
 	pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
-	adapter->pdev = pci_dev;
 
 	PMD_INIT_LOG(INFO, "Initializing %x:%x:%x.%d",
 		     pci_dev->addr.domain,
@@ -1843,7 +1841,8 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	ena_dev->reg_bar = adapter->regs;
-	ena_dev->dmadev = adapter->pdev;
+	/* This is a dummy pointer for ena_com functions. */
+	ena_dev->dmadev = adapter;
 
 	adapter->id_number = adapters_found;
 
@@ -1857,7 +1856,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	/* device specific initialization routine */
-	rc = ena_device_init(ena_dev, &get_feat_ctx, &wd_state);
+	rc = ena_device_init(ena_dev, pci_dev, &get_feat_ctx, &wd_state);
 	if (rc) {
 		PMD_INIT_LOG(CRIT, "Failed to init ENA device");
 		goto err;
@@ -2716,7 +2715,7 @@ static int ena_xstats_get_names(struct rte_eth_dev *dev,
 				struct rte_eth_xstat_name *xstats_names,
 				unsigned int n)
 {
-	unsigned int xstats_count = ena_xstats_calc_num(dev);
+	unsigned int xstats_count = ena_xstats_calc_num(dev->data);
 	unsigned int stat, i, count = 0;
 
 	if (n < xstats_count || !xstats_names)
@@ -2765,7 +2764,7 @@ static int ena_xstats_get(struct rte_eth_dev *dev,
 			  unsigned int n)
 {
 	struct ena_adapter *adapter = dev->data->dev_private;
-	unsigned int xstats_count = ena_xstats_calc_num(dev);
+	unsigned int xstats_count = ena_xstats_calc_num(dev->data);
 	unsigned int stat, i, count = 0;
 	int stat_offset;
 	void *stats_begin;
@@ -2997,7 +2996,7 @@ static void ena_update_on_link_change(void *adapter_data,
 
 	adapter = adapter_data;
 	aenq_link_desc = (struct ena_admin_aenq_link_change_desc *)aenq_e;
-	eth_dev = adapter->rte_dev;
+	eth_dev = &rte_eth_devices[adapter->port_id];
 
 	status = get_ena_admin_aenq_link_change_desc_link_status(aenq_link_desc);
 	adapter->link_status = status;
drivers/net/ena/ena_ethdev.h +2 -3
index 1f7383dce0..32e92e1d6b 100644
@@ -219,9 +219,8 @@ struct ena_shared_data {
 /* board specific private data structure */
 struct ena_adapter {
 	/* OS defined structs */
-	struct rte_pci_device *pdev;
-	struct rte_eth_dev_data *rte_eth_dev_data;
-	struct rte_eth_dev *rte_dev;
+	struct rte_eth_dev_data *edev_data;
+	int port_id;
 
 	struct ena_com_dev ena_dev __rte_cache_aligned;
 
Signature · 1 line
2.25.1
#20 lore raw

PATCH 20/22 net/ena: disable dev_ops not supported in SMP

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

For dev_ops not supported in SMP, either return -EPERM or return without doing anything. In both cases log a warning.

---
 drivers/net/ena/ena_ethdev.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/net/ena/ena_ethdev.c +18 -0
index 90ea40513a..73e99e956a 100644
@@ -529,6 +529,12 @@ ena_dev_reset(struct rte_eth_dev *dev)
 {
 	int rc = 0;
 
+	/* Cannot release memory in secondary process */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		PMD_DRV_LOG(WARNING, "dev_reset not supported in secondary.\n");
+		return -EPERM;
+	}
+
 	ena_destroy_device(dev);
 	rc = eth_ena_dev_init(dev);
 	if (rc)
@@ -1052,6 +1058,12 @@ static int ena_start(struct rte_eth_dev *dev)
 	uint64_t ticks;
 	int rc = 0;
 
+	/* Cannot allocate memory in secondary process */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		PMD_DRV_LOG(WARNING, "dev_start not supported in secondary.\n");
+		return -EPERM;
+	}
+
 	rc = ena_check_valid_conf(adapter);
 	if (rc)
 		return rc;
@@ -1098,6 +1110,12 @@ static int ena_stop(struct rte_eth_dev *dev)
 	struct ena_com_dev *ena_dev = &adapter->ena_dev;
 	int rc;
 
+	/* Cannot free memory in secondary process */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		PMD_DRV_LOG(WARNING, "dev_stop not supported in secondary.\n");
+		return -EPERM;
+	}
+
 	rte_timer_stop_sync(&adapter->timer_wd);
 	ena_queue_stop_all(dev, ENA_RING_TYPE_TX);
 	ena_queue_stop_all(dev, ENA_RING_TYPE_RX);
Signature · 1 line
2.25.1
#21 lore raw

PATCH 21/22 net/ena: report default ring size

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

Remove invalid ring size alignment logic and add default rx and tx port ring sizes to the device info spec.

The logic in lines 1297 and 1371 is invalid. The RTE_ETH_DEV_FALLBACK_RX_RINGSIZE (and the TX counterpart) is a value that rte_eth_rx_queue_setup() will set if dev_info.default_rxportconf.ring_size is 0 and user provided 0 in nb_rx_desc argument. However the current code treats it as a hint for the PMD to change the ring size to internal defaults.

Additionally since the ENA_DEFAULT_RING_SIZE is defined, report it in the device capabilities so that both rte_ethdev code and the user can utilize it for device configuration.

Fixes ea93d37eb49d ("net/ena: add HW queues depth setup")
---
 drivers/net/ena/ena_ethdev.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/ena/ena_ethdev.c +3 -6
index 73e99e956a..c5d8e7d43e 100644
@@ -1294,9 +1294,6 @@ static int ena_tx_queue_setup(struct rte_eth_dev *dev,
 		return -EINVAL;
 	}
 
-	if (nb_desc == RTE_ETH_DEV_FALLBACK_TX_RINGSIZE)
-		nb_desc = adapter->max_tx_ring_size;
-
 	txq->port_id = dev->data->port_id;
 	txq->next_to_clean = 0;
 	txq->next_to_use = 0;
@@ -1368,9 +1365,6 @@ static int ena_rx_queue_setup(struct rte_eth_dev *dev,
 		return ENA_COM_FAULT;
 	}
 
-	if (nb_desc == RTE_ETH_DEV_FALLBACK_RX_RINGSIZE)
-		nb_desc = adapter->max_rx_ring_size;
-
 	if (!rte_is_power_of_2(nb_desc)) {
 		PMD_DRV_LOG(ERR,
 			"Unsupported size of RX queue: %d is not a power of 2.\n",
@@ -2130,6 +2124,9 @@ static int ena_infos_get(struct rte_eth_dev *dev,
 	dev_info->tx_desc_lim.nb_mtu_seg_max = RTE_MIN(ENA_PKT_MAX_BUFS,
 					adapter->max_tx_sgl_size);
 
+	dev_info->default_rxportconf.ring_size = ENA_DEFAULT_RING_SIZE;
+	dev_info->default_txportconf.ring_size = ENA_DEFAULT_RING_SIZE;
+
 	return 0;
 }
 
Signature · 1 line
2.25.1
#22 lore raw

PATCH 22/22 net/ena: update version to v2.3.0

In reply to Michal Krawczyk

This version update contains:
* memcpy mapping to the dpdk-optimized version.
* ena_com (HAL) update to the latest version.
* Bug fixes for the the large LLQ headers and devargs parsing.
* Mbuf RSS hash presence indication.
* Bug fix for the default ring size.
* Various fixes for SMP mode (although ENA is not fully MP aware, yet).

---
 doc/guides/rel_notes/release_21_05.rst | 13 +++++++++++++
 drivers/net/ena/ena_ethdev.c           |  4 ++--
 2 files changed, 15 insertions(+), 2 deletions(-)
doc/guides/rel_notes/release_21_05.rst +13 -0
index 0306f68a0a..79e25d9a40 100644
@@ -274,6 +274,19 @@ New Features
   * Added support for crypto adapter forward mode in octeontx2 event and crypto
     device driver.
 
+* **Updated Amazon ENA PMD.**
+
+  The new driver version (v2.3.0) introduces bug fixes and improvements,
+  including:
+
+  * Changed memcpy mapping to the dpdk-optimized version.
+  * Updated ena_com (HAL) to the latest version.
+  * Fixed bugs when requesting large LLQ headers using the devargs.
+  * Added indication of the RSS hash presence in the mbuf.
+  * Fixed bug when the default ring size was set.
+  * Add multiple fixes for the SMP mode (although ENA is not fully MP aware,
+    yet).
+
 
 Removed Items
 -------------
drivers/net/ena/ena_ethdev.c +2 -2
index c5d8e7d43e..e1e086f31e 100644
@@ -27,8 +27,8 @@
 #include <ena_eth_io_defs.h>
 
 #define DRV_MODULE_VER_MAJOR	2
-#define DRV_MODULE_VER_MINOR	2
-#define DRV_MODULE_VER_SUBMINOR	1
+#define DRV_MODULE_VER_MINOR	3
+#define DRV_MODULE_VER_SUBMINOR	0
 
 #define ENA_IO_TXQ_IDX(q)	(2 * (q))
 #define ENA_IO_RXQ_IDX(q)	(2 * (q) + 1)
Signature · 1 line
2.25.1
#23 lore raw

v2 cover net/ena: update ENA PMD to v2.3.0

In reply to Michal Krawczyk

Hi,

this version updates the driver to version 2.3.0, which fixes multiple bugs, contains part of the work on making the ENA PMD fully MP aware, and also updates HAL to the latest version.

More detailed list of changes:
* memcpy mapping to the dpdk-optimized version.
* ena_com (HAL) update to the latest version.
* Bug fixes for the the large LLQ headers and devargs parsing.
* Mbuf RSS hash presence indication.
* Bug fix for the default ring size.
* Various fixes for the SMP mode.

v2:
* Fix nested declaration of the rte_memcpy on arm64 architecture.

Amit Bernstein (1):
net/ena/base: adjust changes to lastest ena-com

Igor Chauskin (2):
net/ena: switch memcpy to dpdk-optimized version net/ena: fix parsing of large_llq_hdr argument

Michal Krawczyk (12):
net/ena/base: unify arg names for the functions net/ena/base: add dev arg to the logging macros net/ena/base: typos, style and comments improvements net/ena/base: fix issues from the static code scan net/ena/base: destroy multiple "wait events" net/ena/base: remove indir table from ENA feat ctx net/ena/base: remove mutable RSS from the host info net/ena/base: update generation date and commit net/ena/base: use rte_prefetch0_write net/ena: terminate devargs allowed keys with NULL net/ena: indicate Rx RSS hash presence net/ena: update version to v2.3.0

Stanislaw Kardach (7):
net/ena: remove endian swap functions net/ena: handle spurious wakeups in ENA_WAIT_EVENT net/ena: support SMP for mz alloc counter net/ena: move default RSS key to shared mem net/ena: make ethdev references smp safe net/ena: disable dev_ops not supported in SMP net/ena: report default ring size

 doc/guides/rel_notes/release_21_05.rst        |  13 +
 drivers/net/ena/base/ena_com.c                | 379 +++++++++---------
 drivers/net/ena/base/ena_com.h                |  24 +-
 .../net/ena/base/ena_defs/ena_admin_defs.h    |  98 ++---
 drivers/net/ena/base/ena_defs/ena_gen_info.h  |   4 +-
 drivers/net/ena/base/ena_eth_com.c            |  94 +++--
 drivers/net/ena/base/ena_eth_com.h            |  17 +-
 drivers/net/ena/base/ena_plat_dpdk.h          | 324 ++++++++-------
 drivers/net/ena/ena_ethdev.c                  | 156 ++++---
 drivers/net/ena/ena_ethdev.h                  |  14 +-
 drivers/net/ena/ena_platform.h                |  12 -
 11 files changed, 636 insertions(+), 499 deletions(-)
Signature · 1 line
2.25.1
#24 lore raw

PATCH v2 1/22 net/ena: switch memcpy to dpdk-optimized version

From: Igor Chauskin <[email protected]>

memcpy is now mapped to rte_memcpy macro on x86 architectures.

Fixes 9ba7981ec992 ("ena: add communication layer for DPDK")

---
v2:
* Fix nested declaration of the rte_memcpy on arm64 architecture.

 drivers/net/ena/base/ena_plat_dpdk.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ena/base/ena_plat_dpdk.h +6 -1
index a1d749f83f..ae68f860a5 100644
@@ -25,6 +25,7 @@
 #include <rte_spinlock.h>
 
 #include <sys/time.h>
+#include <rte_memcpy.h>
 
 typedef uint64_t u64;
 typedef uint32_t u32;
@@ -62,7 +63,11 @@ typedef uint64_t dma_addr_t;
 #define ENA_UDELAY(x) rte_delay_us_block(x)
 
 #define ENA_TOUCH(x) ((void)(x))
-#define memcpy_toio memcpy
+/* Avoid nested declaration on arm64, as it may define rte_memcpy as memcpy. */
+#if defined(RTE_ARCH_X86)
+#undef memcpy
+#define memcpy rte_memcpy
+#endif
 #define wmb rte_wmb
 #define rmb rte_rmb
 #define mb rte_mb
Signature · 1 line
2.25.1
#25 lore raw

PATCH v2 2/22 net/ena/base: unify arg names for the functions

In reply to Michal Krawczyk

Instead of using 'queue' for struct ena_com_admin_queue and 'dev' for struct ena_com_dev variables, use more descriptive 'admin_queue' and 'ena_dev'.

This also unifies the names of variables of the type struct ena_com_dev in the driver.

---
 drivers/net/ena/base/ena_com.c | 74 +++++++++++++++++-----------------
 drivers/net/ena/base/ena_com.h |  2 +-
 2 files changed, 38 insertions(+), 38 deletions(-)
drivers/net/ena/base/ena_com.c +37 -37
index aae68721fb..f7258254a5 100644
@@ -80,12 +80,12 @@ static int ena_com_mem_addr_set(struct ena_com_dev *ena_dev,
 	return 0;
 }
 
-static int ena_com_admin_init_sq(struct ena_com_admin_queue *queue)
+static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue)
 {
-	struct ena_com_admin_sq *sq = &queue->sq;
-	u16 size = ADMIN_SQ_SIZE(queue->q_depth);
+	struct ena_com_admin_sq *sq = &admin_queue->sq;
+	u16 size = ADMIN_SQ_SIZE(admin_queue->q_depth);
 
-	ENA_MEM_ALLOC_COHERENT(queue->q_dmadev, size, sq->entries, sq->dma_addr,
+	ENA_MEM_ALLOC_COHERENT(admin_queue->q_dmadev, size, sq->entries, sq->dma_addr,
 			       sq->mem_handle);
 
 	if (!sq->entries) {
@@ -102,12 +102,12 @@ static int ena_com_admin_init_sq(struct ena_com_admin_queue *queue)
 	return 0;
 }
 
-static int ena_com_admin_init_cq(struct ena_com_admin_queue *queue)
+static int ena_com_admin_init_cq(struct ena_com_admin_queue *admin_queue)
 {
-	struct ena_com_admin_cq *cq = &queue->cq;
-	u16 size = ADMIN_CQ_SIZE(queue->q_depth);
+	struct ena_com_admin_cq *cq = &admin_queue->cq;
+	u16 size = ADMIN_CQ_SIZE(admin_queue->q_depth);
 
-	ENA_MEM_ALLOC_COHERENT(queue->q_dmadev, size, cq->entries, cq->dma_addr,
+	ENA_MEM_ALLOC_COHERENT(admin_queue->q_dmadev, size, cq->entries, cq->dma_addr,
 			       cq->mem_handle);
 
 	if (!cq->entries)  {
@@ -121,16 +121,16 @@ static int ena_com_admin_init_cq(struct ena_com_admin_queue *queue)
 	return 0;
 }
 
-static int ena_com_admin_init_aenq(struct ena_com_dev *dev,
+static int ena_com_admin_init_aenq(struct ena_com_dev *ena_dev,
 				   struct ena_aenq_handlers *aenq_handlers)
 {
-	struct ena_com_aenq *aenq = &dev->aenq;
+	struct ena_com_aenq *aenq = &ena_dev->aenq;
 	u32 addr_low, addr_high, aenq_caps;
 	u16 size;
 
-	dev->aenq.q_depth = ENA_ASYNC_QUEUE_DEPTH;
+	ena_dev->aenq.q_depth = ENA_ASYNC_QUEUE_DEPTH;
 	size = ADMIN_AENQ_SIZE(ENA_ASYNC_QUEUE_DEPTH);
-	ENA_MEM_ALLOC_COHERENT(dev->dmadev, size,
+	ENA_MEM_ALLOC_COHERENT(ena_dev->dmadev, size,
 			aenq->entries,
 			aenq->dma_addr,
 			aenq->mem_handle);
@@ -146,15 +146,15 @@ static int ena_com_admin_init_aenq(struct ena_com_dev *dev,
 	addr_low = ENA_DMA_ADDR_TO_UINT32_LOW(aenq->dma_addr);
 	addr_high = ENA_DMA_ADDR_TO_UINT32_HIGH(aenq->dma_addr);
 
-	ENA_REG_WRITE32(dev->bus, addr_low, dev->reg_bar + ENA_REGS_AENQ_BASE_LO_OFF);
-	ENA_REG_WRITE32(dev->bus, addr_high, dev->reg_bar + ENA_REGS_AENQ_BASE_HI_OFF);
+	ENA_REG_WRITE32(ena_dev->bus, addr_low, ena_dev->reg_bar + ENA_REGS_AENQ_BASE_LO_OFF);
+	ENA_REG_WRITE32(ena_dev->bus, addr_high, ena_dev->reg_bar + ENA_REGS_AENQ_BASE_HI_OFF);
 
 	aenq_caps = 0;
-	aenq_caps |= dev->aenq.q_depth & ENA_REGS_AENQ_CAPS_AENQ_DEPTH_MASK;
+	aenq_caps |= ena_dev->aenq.q_depth & ENA_REGS_AENQ_CAPS_AENQ_DEPTH_MASK;
 	aenq_caps |= (sizeof(struct ena_admin_aenq_entry) <<
 		ENA_REGS_AENQ_CAPS_AENQ_ENTRY_SIZE_SHIFT) &
 		ENA_REGS_AENQ_CAPS_AENQ_ENTRY_SIZE_MASK;
-	ENA_REG_WRITE32(dev->bus, aenq_caps, dev->reg_bar + ENA_REGS_AENQ_CAPS_OFF);
+	ENA_REG_WRITE32(ena_dev->bus, aenq_caps, ena_dev->reg_bar + ENA_REGS_AENQ_CAPS_OFF);
 
 	if (unlikely(!aenq_handlers)) {
 		ena_trc_err("aenq handlers pointer is NULL\n");
@@ -173,31 +173,31 @@ static void comp_ctxt_release(struct ena_com_admin_queue *queue,
 	ATOMIC32_DEC(&queue->outstanding_cmds);
 }
 
-static struct ena_comp_ctx *get_comp_ctxt(struct ena_com_admin_queue *queue,
+static struct ena_comp_ctx *get_comp_ctxt(struct ena_com_admin_queue *admin_queue,
 					  u16 command_id, bool capture)
 {
-	if (unlikely(command_id >= queue->q_depth)) {
+	if (unlikely(command_id >= admin_queue->q_depth)) {
 		ena_trc_err("command id is larger than the queue size. cmd_id: %u queue size %d\n",
-			    command_id, queue->q_depth);
+			    command_id, admin_queue->q_depth);
 		return NULL;
 	}
 
-	if (unlikely(!queue->comp_ctx)) {
+	if (unlikely(!admin_queue->comp_ctx)) {
 		ena_trc_err("Completion context is NULL\n");
 		return NULL;
 	}
 
-	if (unlikely(queue->comp_ctx[command_id].occupied && capture)) {
+	if (unlikely(admin_queue->comp_ctx[command_id].occupied && capture)) {
 		ena_trc_err("Completion context is occupied\n");
 		return NULL;
 	}
 
 	if (capture) {
-		ATOMIC32_INC(&queue->outstanding_cmds);
-		queue->comp_ctx[command_id].occupied = true;
+		ATOMIC32_INC(&admin_queue->outstanding_cmds);
+		admin_queue->comp_ctx[command_id].occupied = true;
 	}
 
-	return &queue->comp_ctx[command_id];
+	return &admin_queue->comp_ctx[command_id];
 }
 
 static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queue *admin_queue,
@@ -260,20 +260,20 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queu
 	return comp_ctx;
 }
 
-static int ena_com_init_comp_ctxt(struct ena_com_admin_queue *queue)
+static int ena_com_init_comp_ctxt(struct ena_com_admin_queue *admin_queue)
 {
-	size_t size = queue->q_depth * sizeof(struct ena_comp_ctx);
+	size_t size = admin_queue->q_depth * sizeof(struct ena_comp_ctx);
 	struct ena_comp_ctx *comp_ctx;
 	u16 i;
 
-	queue->comp_ctx = ENA_MEM_ALLOC(queue->q_dmadev, size);
-	if (unlikely(!queue->comp_ctx)) {
+	admin_queue->comp_ctx = ENA_MEM_ALLOC(admin_queue->q_dmadev, size);
+	if (unlikely(!admin_queue->comp_ctx)) {
 		ena_trc_err("memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
-	for (i = 0; i < queue->q_depth; i++) {
-		comp_ctx = get_comp_ctxt(queue, i, false);
+	for (i = 0; i < admin_queue->q_depth; i++) {
+		comp_ctx = get_comp_ctxt(admin_queue, i, false);
 		if (comp_ctx)
 			ENA_WAIT_EVENT_INIT(comp_ctx->wait_event);
 	}
@@ -2049,10 +2049,10 @@ void ena_com_admin_q_comp_intr_handler(struct ena_com_dev *ena_dev)
 /* ena_handle_specific_aenq_event:
  * return the handler that is relevant to the specific event group
  */
-static ena_aenq_handler ena_com_get_specific_aenq_cb(struct ena_com_dev *dev,
+static ena_aenq_handler ena_com_get_specific_aenq_cb(struct ena_com_dev *ena_dev,
 						     u16 group)
 {
-	struct ena_aenq_handlers *aenq_handlers = dev->aenq.aenq_handlers;
+	struct ena_aenq_handlers *aenq_handlers = ena_dev->aenq.aenq_handlers;
 
 	if ((group < ENA_MAX_HANDLERS) && aenq_handlers->handlers[group])
 		return aenq_handlers->handlers[group];
@@ -2064,11 +2064,11 @@ static ena_aenq_handler ena_com_get_specific_aenq_cb(struct ena_com_dev *dev,
  * handles the aenq incoming events.
  * pop events from the queue and apply the specific handler
  */
-void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data)
+void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data)
 {
 	struct ena_admin_aenq_entry *aenq_e;
 	struct ena_admin_aenq_common_desc *aenq_common;
-	struct ena_com_aenq *aenq  = &dev->aenq;
+	struct ena_com_aenq *aenq  = &ena_dev->aenq;
 	u64 timestamp;
 	ena_aenq_handler handler_cb;
 	u16 masked_head, processed = 0;
@@ -2096,7 +2096,7 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data)
 			    timestamp);
 
 		/* Handle specific event*/
-		handler_cb = ena_com_get_specific_aenq_cb(dev,
+		handler_cb = ena_com_get_specific_aenq_cb(ena_dev,
 							  aenq_common->group);
 		handler_cb(data, aenq_e); /* call the actual event handler*/
 
@@ -2121,8 +2121,8 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data)
 
 	/* write the aenq doorbell after all AENQ descriptors were read */
 	mb();
-	ENA_REG_WRITE32_RELAXED(dev->bus, (u32)aenq->head,
-				dev->reg_bar + ENA_REGS_AENQ_HEAD_DB_OFF);
+	ENA_REG_WRITE32_RELAXED(ena_dev->bus, (u32)aenq->head,
+				ena_dev->reg_bar + ENA_REGS_AENQ_HEAD_DB_OFF);
 	mmiowb();
 }
 
drivers/net/ena/base/ena_com.h +1 -1
index 64d8f247cb..e9601b1a8e 100644
@@ -522,7 +522,7 @@ void ena_com_admin_q_comp_intr_handler(struct ena_com_dev *ena_dev);
  * This method goes over the async event notification queue and calls the proper
  * aenq handler.
  */
-void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data);
+void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data);
 
 /* ena_com_abort_admin_commands - Abort all the outstanding admin commands.
  * @ena_dev: ENA communication layer struct
Signature · 1 line
2.25.1
#26 lore raw

PATCH v2 3/22 net/ena/base: add dev arg to the logging macros

In reply to Michal Krawczyk

Some platforms may make use of the device argument to make the logs more verbose and specific for the appropriate device.

As it's not used by the ENA DPDK PMD for the logging, the type is just defined, but never used.

It may be reconsidered to change this in the future by adding port ID to the message logs, but as for now the logging behavior won't change.

---
 drivers/net/ena/base/ena_com.c       | 238 ++++++++++++++-------------
 drivers/net/ena/base/ena_com.h       |  21 +++
 drivers/net/ena/base/ena_eth_com.c   |  78 ++++++---
 drivers/net/ena/base/ena_eth_com.h   |  17 +-
 drivers/net/ena/base/ena_plat_dpdk.h |  44 ++---
 5 files changed, 236 insertions(+), 162 deletions(-)
drivers/net/ena/base/ena_com.c +128 -110
index f7258254a5..9931819bbb 100644
@@ -70,7 +70,7 @@ static int ena_com_mem_addr_set(struct ena_com_dev *ena_dev,
 				       dma_addr_t addr)
 {
 	if ((addr & GENMASK_ULL(ena_dev->dma_addr_bits - 1, 0)) != addr) {
-		ena_trc_err("dma address has more bits that the device supports\n");
+		ena_trc_err(ena_dev, "DMA address has more bits than the device supports\n");
 		return ENA_COM_INVAL;
 	}
 
@@ -82,6 +82,7 @@ static int ena_com_mem_addr_set(struct ena_com_dev *ena_dev,
 
 static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue)
 {
+	struct ena_com_dev *ena_dev = admin_queue->ena_dev;
 	struct ena_com_admin_sq *sq = &admin_queue->sq;
 	u16 size = ADMIN_SQ_SIZE(admin_queue->q_depth);
 
@@ -89,7 +90,7 @@ static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue)
 			       sq->mem_handle);
 
 	if (!sq->entries) {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -104,6 +105,7 @@ static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue)
 
 static int ena_com_admin_init_cq(struct ena_com_admin_queue *admin_queue)
 {
+	struct ena_com_dev *ena_dev = admin_queue->ena_dev;
 	struct ena_com_admin_cq *cq = &admin_queue->cq;
 	u16 size = ADMIN_CQ_SIZE(admin_queue->q_depth);
 
@@ -111,7 +113,7 @@ static int ena_com_admin_init_cq(struct ena_com_admin_queue *admin_queue)
 			       cq->mem_handle);
 
 	if (!cq->entries)  {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -136,7 +138,7 @@ static int ena_com_admin_init_aenq(struct ena_com_dev *ena_dev,
 			aenq->mem_handle);
 
 	if (!aenq->entries) {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -157,7 +159,7 @@ static int ena_com_admin_init_aenq(struct ena_com_dev *ena_dev,
 	ENA_REG_WRITE32(ena_dev->bus, aenq_caps, ena_dev->reg_bar + ENA_REGS_AENQ_CAPS_OFF);
 
 	if (unlikely(!aenq_handlers)) {
-		ena_trc_err("aenq handlers pointer is NULL\n");
+		ena_trc_err(ena_dev, "AENQ handlers pointer is NULL\n");
 		return ENA_COM_INVAL;
 	}
 
@@ -177,18 +179,21 @@ static struct ena_comp_ctx *get_comp_ctxt(struct ena_com_admin_queue *admin_queu
 					  u16 command_id, bool capture)
 {
 	if (unlikely(command_id >= admin_queue->q_depth)) {
-		ena_trc_err("command id is larger than the queue size. cmd_id: %u queue size %d\n",
+		ena_trc_err(admin_queue->ena_dev,
+			    "Command id is larger than the queue size. cmd_id: %u queue size %d\n",
 			    command_id, admin_queue->q_depth);
 		return NULL;
 	}
 
 	if (unlikely(!admin_queue->comp_ctx)) {
-		ena_trc_err("Completion context is NULL\n");
+		ena_trc_err(admin_queue->ena_dev,
+			    "Completion context is NULL\n");
 		return NULL;
 	}
 
 	if (unlikely(admin_queue->comp_ctx[command_id].occupied && capture)) {
-		ena_trc_err("Completion context is occupied\n");
+		ena_trc_err(admin_queue->ena_dev,
+			    "Completion context is occupied\n");
 		return NULL;
 	}
 
@@ -218,7 +223,7 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queu
 	/* In case of queue FULL */
 	cnt = (u16)ATOMIC32_READ(&admin_queue->outstanding_cmds);
 	if (cnt >= admin_queue->q_depth) {
-		ena_trc_dbg("admin queue is full.\n");
+		ena_trc_dbg(admin_queue->ena_dev, "Admin queue is full.\n");
 		admin_queue->stats.out_of_space++;
 		return ERR_PTR(ENA_COM_NO_SPACE);
 	}
@@ -262,13 +267,14 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queu
 
 static int ena_com_init_comp_ctxt(struct ena_com_admin_queue *admin_queue)
 {
+	struct ena_com_dev *ena_dev = admin_queue->ena_dev;
 	size_t size = admin_queue->q_depth * sizeof(struct ena_comp_ctx);
 	struct ena_comp_ctx *comp_ctx;
 	u16 i;
 
 	admin_queue->comp_ctx = ENA_MEM_ALLOC(admin_queue->q_dmadev, size);
 	if (unlikely(!admin_queue->comp_ctx)) {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -341,7 +347,7 @@ static int ena_com_init_io_sq(struct ena_com_dev *ena_dev,
 		}
 
 		if (!io_sq->desc_addr.virt_addr) {
-			ena_trc_err("memory allocation failed\n");
+			ena_trc_err(ena_dev, "Memory allocation failed\n");
 			return ENA_COM_NO_MEM;
 		}
 	}
@@ -366,7 +372,7 @@ static int ena_com_init_io_sq(struct ena_com_dev *ena_dev,
 			io_sq->bounce_buf_ctrl.base_buffer = ENA_MEM_ALLOC(ena_dev->dmadev, size);
 
 		if (!io_sq->bounce_buf_ctrl.base_buffer) {
-			ena_trc_err("bounce buffer memory allocation failed\n");
+			ena_trc_err(ena_dev, "Bounce buffer memory allocation failed\n");
 			return ENA_COM_NO_MEM;
 		}
 
@@ -431,7 +437,7 @@ static int ena_com_init_io_cq(struct ena_com_dev *ena_dev,
 	}
 
 	if (!io_cq->cdesc_addr.virt_addr) {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -452,7 +458,8 @@ static void ena_com_handle_single_admin_completion(struct ena_com_admin_queue *a
 
 	comp_ctx = get_comp_ctxt(admin_queue, cmd_id, false);
 	if (unlikely(!comp_ctx)) {
-		ena_trc_err("comp_ctx is NULL. Changing the admin queue running state\n");
+		ena_trc_err(admin_queue->ena_dev,
+			    "comp_ctx is NULL. Changing the admin queue running state\n");
 		admin_queue->running_state = false;
 		return;
 	}
@@ -504,10 +511,12 @@ static void ena_com_handle_admin_completion(struct ena_com_admin_queue *admin_qu
 	admin_queue->stats.completed_cmd += comp_num;
 }
 
-static int ena_com_comp_status_to_errno(u8 comp_status)
+static int ena_com_comp_status_to_errno(struct ena_com_admin_queue *admin_queue,
+					u8 comp_status)
 {
 	if (unlikely(comp_status != 0))
-		ena_trc_err("admin command failed[%u]\n", comp_status);
+		ena_trc_err(admin_queue->ena_dev,
+			    "Admin command failed[%u]\n", comp_status);
 
 	switch (comp_status) {
 	case ENA_ADMIN_SUCCESS:
@@ -554,7 +563,8 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
 			break;
 
 		if (ENA_TIME_EXPIRE(timeout)) {
-			ena_trc_err("Wait for completion (polling) timeout\n");
+			ena_trc_err(admin_queue->ena_dev,
+				    "Wait for completion (polling) timeout\n");
 			/* ENA didn't have any completion */
 			ENA_SPINLOCK_LOCK(admin_queue->q_lock, flags);
 			admin_queue->stats.no_completion++;
@@ -570,7 +580,7 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
 	}
 
 	if (unlikely(comp_ctx->status == ENA_CMD_ABORTED)) {
-		ena_trc_err("Command was aborted\n");
+		ena_trc_err(admin_queue->ena_dev, "Command was aborted\n");
 		ENA_SPINLOCK_LOCK(admin_queue->q_lock, flags);
 		admin_queue->stats.aborted_cmd++;
 		ENA_SPINLOCK_UNLOCK(admin_queue->q_lock, flags);
@@ -579,9 +589,10 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
 	}
 
 	ENA_WARN(comp_ctx->status != ENA_CMD_COMPLETED,
-		 "Invalid comp status %d\n", comp_ctx->status);
+		 admin_queue->ena_dev, "Invalid comp status %d\n",
+		 comp_ctx->status);
 
-	ret = ena_com_comp_status_to_errno(comp_ctx->comp_status);
+	ret = ena_com_comp_status_to_errno(admin_queue, comp_ctx->comp_status);
 err:
 	comp_ctxt_release(admin_queue, comp_ctx);
 	return ret;
@@ -623,7 +634,7 @@ static int ena_com_set_llq(struct ena_com_dev *ena_dev)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to set LLQ configurations: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to set LLQ configurations: %d\n", ret);
 
 	return ret;
 }
@@ -645,7 +656,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 		llq_info->header_location_ctrl =
 			llq_default_cfg->llq_header_location;
 	} else {
-		ena_trc_err("Invalid header location control, supported: 0x%x\n",
+		ena_trc_err(ena_dev, "Invalid header location control, supported: 0x%x\n",
 			    supported_feat);
 		return -EINVAL;
 	}
@@ -660,12 +671,12 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 			} else if (supported_feat & ENA_ADMIN_SINGLE_DESC_PER_ENTRY) {
 				llq_info->desc_stride_ctrl = ENA_ADMIN_SINGLE_DESC_PER_ENTRY;
 			} else {
-				ena_trc_err("Invalid desc_stride_ctrl, supported: 0x%x\n",
+				ena_trc_err(ena_dev, "Invalid desc_stride_ctrl, supported: 0x%x\n",
 					    supported_feat);
 				return -EINVAL;
 			}
 
-			ena_trc_err("Default llq stride ctrl is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
+			ena_trc_err(ena_dev, "Default llq stride ctrl is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
 				    llq_default_cfg->llq_stride_ctrl,
 				    supported_feat,
 				    llq_info->desc_stride_ctrl);
@@ -689,11 +700,12 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 			llq_info->desc_list_entry_size_ctrl = ENA_ADMIN_LIST_ENTRY_SIZE_256B;
 			llq_info->desc_list_entry_size = 256;
 		} else {
-			ena_trc_err("Invalid entry_size_ctrl, supported: 0x%x\n", supported_feat);
+			ena_trc_err(ena_dev, "Invalid entry_size_ctrl, supported: 0x%x\n",
+				    supported_feat);
 			return -EINVAL;
 		}
 
-		ena_trc_err("Default llq ring entry size is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
+		ena_trc_err(ena_dev, "Default llq ring entry size is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
 			    llq_default_cfg->llq_ring_entry_size,
 			    supported_feat,
 			    llq_info->desc_list_entry_size);
@@ -702,7 +714,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 		/* The desc list entry size should be whole multiply of 8
 		 * This requirement comes from __iowrite64_copy()
 		 */
-		ena_trc_err("illegal entry size %d\n",
+		ena_trc_err(ena_dev, "Illegal entry size %d\n",
 			    llq_info->desc_list_entry_size);
 		return -EINVAL;
 	}
@@ -726,12 +738,12 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 		} else if (supported_feat & ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_8) {
 			llq_info->descs_num_before_header = ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_8;
 		} else {
-			ena_trc_err("Invalid descs_num_before_header, supported: 0x%x\n",
+			ena_trc_err(ena_dev, "Invalid descs_num_before_header, supported: 0x%x\n",
 				    supported_feat);
 			return -EINVAL;
 		}
 
-		ena_trc_err("Default llq num descs before header is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
+		ena_trc_err(ena_dev, "Default llq num descs before header is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
 			    llq_default_cfg->llq_num_decs_before_header,
 			    supported_feat,
 			    llq_info->descs_num_before_header);
@@ -750,7 +762,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 
 	rc = ena_com_set_llq(ena_dev);
 	if (rc)
-		ena_trc_err("Cannot set LLQ configuration: %d\n", rc);
+		ena_trc_err(ena_dev, "Cannot set LLQ configuration: %d\n", rc);
 
 	return rc;
 }
@@ -776,13 +788,15 @@ static int ena_com_wait_and_process_admin_cq_interrupts(struct ena_comp_ctx *com
 		ENA_SPINLOCK_UNLOCK(admin_queue->q_lock, flags);
 
 		if (comp_ctx->status == ENA_CMD_COMPLETED) {
-			ena_trc_err("The ena device sent a completion but the driver didn't receive a MSI-X interrupt (cmd %d), autopolling mode is %s\n",
+			ena_trc_err(admin_queue->ena_dev,
+				    "The ena device sent a completion but the driver didn't receive a MSI-X interrupt (cmd %d), autopolling mode is %s\n",
 				    comp_ctx->cmd_opcode, admin_queue->auto_polling ? "ON" : "OFF");
 			/* Check if fallback to polling is enabled */
 			if (admin_queue->auto_polling)
 				admin_queue->polling = true;
 		} else {
-			ena_trc_err("The ena device didn't send a completion for the admin cmd %d status %d\n",
+			ena_trc_err(admin_queue->ena_dev,
+				    "The ena device didn't send a completion for the admin cmd %d status %d\n",
 				    comp_ctx->cmd_opcode, comp_ctx->status);
 		}
 		/* Check if shifted to polling mode.
@@ -796,7 +810,7 @@ static int ena_com_wait_and_process_admin_cq_interrupts(struct ena_comp_ctx *com
 		}
 	}
 
-	ret = ena_com_comp_status_to_errno(comp_ctx->comp_status);
+	ret = ena_com_comp_status_to_errno(admin_queue, comp_ctx->comp_status);
 err:
 	comp_ctxt_release(admin_queue, comp_ctx);
 	return ret;
@@ -844,7 +858,7 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev *ena_dev, u16 offset)
 	}
 
 	if (unlikely(i == timeout)) {
-		ena_trc_err("reading reg failed for timeout. expected: req id[%hu] offset[%hu] actual: req id[%hu] offset[%hu]\n",
+		ena_trc_err(ena_dev, "Reading reg failed for timeout. expected: req id[%hu] offset[%hu] actual: req id[%hu] offset[%hu]\n",
 			    mmio_read->seq_num,
 			    offset,
 			    read_resp->req_id,
@@ -854,7 +868,7 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev *ena_dev, u16 offset)
 	}
 
 	if (read_resp->reg_off != offset) {
-		ena_trc_err("Read failure: wrong offset provided\n");
+		ena_trc_err(ena_dev, "Read failure: wrong offset provided\n");
 		ret = ENA_MMIO_READ_TIMEOUT;
 	} else {
 		ret = read_resp->reg_val;
@@ -913,7 +927,7 @@ static int ena_com_destroy_io_sq(struct ena_com_dev *ena_dev,
 					    sizeof(destroy_resp));
 
 	if (unlikely(ret && (ret != ENA_COM_NO_DEVICE)))
-		ena_trc_err("failed to destroy io sq error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to destroy io sq error: %d\n", ret);
 
 	return ret;
 }
@@ -969,7 +983,7 @@ static int wait_for_reset_state(struct ena_com_dev *ena_dev, u32 timeout,
 		val = ena_com_reg_bar_read32(ena_dev, ENA_REGS_DEV_STS_OFF);
 
 		if (unlikely(val == ENA_MMIO_READ_TIMEOUT)) {
-			ena_trc_err("Reg read timeout occurred\n");
+			ena_trc_err(ena_dev, "Reg read timeout occurred\n");
 			return ENA_COM_TIMER_EXPIRED;
 		}
 
@@ -1009,7 +1023,7 @@ static int ena_com_get_feature_ex(struct ena_com_dev *ena_dev,
 	int ret;
 
 	if (!ena_com_check_supported_feature_id(ena_dev, feature_id)) {
-		ena_trc_dbg("Feature %d isn't supported\n", feature_id);
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n", feature_id);
 		return ENA_COM_UNSUPPORTED;
 	}
 
@@ -1028,7 +1042,7 @@ static int ena_com_get_feature_ex(struct ena_com_dev *ena_dev,
 				   &get_cmd.control_buffer.address,
 				   control_buf_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -1045,7 +1059,7 @@ static int ena_com_get_feature_ex(struct ena_com_dev *ena_dev,
 					    sizeof(*get_resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to submit get_feature command %d error: %d\n",
+		ena_trc_err(ena_dev, "Failed to submit get_feature command %d error: %d\n",
 			    feature_id, ret);
 
 	return ret;
@@ -1157,7 +1171,7 @@ static int ena_com_indirect_table_allocate(struct ena_com_dev *ena_dev,
 
 	if ((get_resp.u.ind_table.min_size > log_size) ||
 	    (get_resp.u.ind_table.max_size < log_size)) {
-		ena_trc_err("indirect table size doesn't fit. requested size: %d while min is:%d and max %d\n",
+		ena_trc_err(ena_dev, "Indirect table size doesn't fit. requested size: %d while min is:%d and max %d\n",
 			    1 << log_size,
 			    1 << get_resp.u.ind_table.min_size,
 			    1 << get_resp.u.ind_table.max_size);
@@ -1261,7 +1275,7 @@ static int ena_com_create_io_sq(struct ena_com_dev *ena_dev,
 					   &create_cmd.sq_ba,
 					   io_sq->desc_addr.phys_addr);
 		if (unlikely(ret)) {
-			ena_trc_err("memory address set failed\n");
+			ena_trc_err(ena_dev, "Memory address set failed\n");
 			return ret;
 		}
 	}
@@ -1272,7 +1286,7 @@ static int ena_com_create_io_sq(struct ena_com_dev *ena_dev,
 					    (struct ena_admin_acq_entry *)&cmd_completion,
 					    sizeof(cmd_completion));
 	if (unlikely(ret)) {
-		ena_trc_err("Failed to create IO SQ. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to create IO SQ. error: %d\n", ret);
 		return ret;
 	}
 
@@ -1290,7 +1304,7 @@ static int ena_com_create_io_sq(struct ena_com_dev *ena_dev,
 			cmd_completion.llq_descriptors_offset);
 	}
 
-	ena_trc_dbg("created sq[%u], depth[%u]\n", io_sq->idx, io_sq->q_depth);
+	ena_trc_dbg(ena_dev, "Created sq[%u], depth[%u]\n", io_sq->idx, io_sq->q_depth);
 
 	return ret;
 }
@@ -1324,7 +1338,7 @@ static void ena_com_update_intr_delay_resolution(struct ena_com_dev *ena_dev,
 	u16 prev_intr_delay_resolution = ena_dev->intr_delay_resolution;
 
 	if (unlikely(!intr_delay_resolution)) {
-		ena_trc_err("Illegal intr_delay_resolution provided. Going to use default 1 usec resolution\n");
+		ena_trc_err(ena_dev, "Illegal intr_delay_resolution provided. Going to use default 1 usec resolution\n");
 		intr_delay_resolution = ENA_DEFAULT_INTR_DELAY_RESOLUTION;
 	}
 
@@ -1360,10 +1374,12 @@ int ena_com_execute_admin_command(struct ena_com_admin_queue *admin_queue,
 					    comp, comp_size);
 	if (IS_ERR(comp_ctx)) {
 		if (comp_ctx == ERR_PTR(ENA_COM_NO_DEVICE))
-			ena_trc_dbg("Failed to submit command [%ld]\n",
+			ena_trc_dbg(admin_queue->ena_dev,
+				    "Failed to submit command [%ld]\n",
 				    PTR_ERR(comp_ctx));
 		else
-			ena_trc_err("Failed to submit command [%ld]\n",
+			ena_trc_err(admin_queue->ena_dev,
+				    "Failed to submit command [%ld]\n",
 				    PTR_ERR(comp_ctx));
 
 		return PTR_ERR(comp_ctx);
@@ -1372,11 +1388,11 @@ int ena_com_execute_admin_command(struct ena_com_admin_queue *admin_queue,
 	ret = ena_com_wait_and_process_admin_cq(comp_ctx, admin_queue);
 	if (unlikely(ret)) {
 		if (admin_queue->running_state)
-			ena_trc_err("Failed to process command. ret = %d\n",
-				    ret);
+			ena_trc_err(admin_queue->ena_dev,
+				    "Failed to process command. ret = %d\n", ret);
 		else
-			ena_trc_dbg("Failed to process command. ret = %d\n",
-				    ret);
+			ena_trc_dbg(admin_queue->ena_dev,
+				    "Failed to process command. ret = %d\n", ret);
 	}
 	return ret;
 }
@@ -1405,7 +1421,7 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev,
 				   &create_cmd.cq_ba,
 				   io_cq->cdesc_addr.phys_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -1415,7 +1431,7 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev,
 					    (struct ena_admin_acq_entry *)&cmd_completion,
 					    sizeof(cmd_completion));
 	if (unlikely(ret)) {
-		ena_trc_err("Failed to create IO CQ. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to create IO CQ. error: %d\n", ret);
 		return ret;
 	}
 
@@ -1434,7 +1450,7 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev,
 			(u32 __iomem *)((uintptr_t)ena_dev->reg_bar +
 			cmd_completion.numa_node_register_offset);
 
-	ena_trc_dbg("created cq[%u], depth[%u]\n", io_cq->idx, io_cq->q_depth);
+	ena_trc_dbg(ena_dev, "Created cq[%u], depth[%u]\n", io_cq->idx, io_cq->q_depth);
 
 	return ret;
 }
@@ -1444,7 +1460,7 @@ int ena_com_get_io_handlers(struct ena_com_dev *ena_dev, u16 qid,
 			    struct ena_com_io_cq **io_cq)
 {
 	if (qid >= ENA_TOTAL_NUM_QUEUES) {
-		ena_trc_err("Invalid queue number %d but the max is %d\n",
+		ena_trc_err(ena_dev, "Invalid queue number %d but the max is %d\n",
 			    qid, ENA_TOTAL_NUM_QUEUES);
 		return ENA_COM_INVAL;
 	}
@@ -1510,7 +1526,7 @@ int ena_com_destroy_io_cq(struct ena_com_dev *ena_dev,
 					    sizeof(destroy_resp));
 
 	if (unlikely(ret && (ret != ENA_COM_NO_DEVICE)))
-		ena_trc_err("Failed to destroy IO CQ. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to destroy IO CQ. error: %d\n", ret);
 
 	return ret;
 }
@@ -1534,7 +1550,7 @@ void ena_com_admin_aenq_enable(struct ena_com_dev *ena_dev)
 {
 	u16 depth = ena_dev->aenq.q_depth;
 
-	ENA_WARN(ena_dev->aenq.head != depth, "Invalid AENQ state\n");
+	ENA_WARN(ena_dev->aenq.head != depth, ena_dev, "Invalid AENQ state\n");
 
 	/* Init head_db to mark that all entries in the queue
 	 * are initially available
@@ -1552,12 +1568,12 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_dev, u32 groups_flag)
 
 	ret = ena_com_get_feature(ena_dev, &get_resp, ENA_ADMIN_AENQ_CONFIG, 0);
 	if (ret) {
-		ena_trc_info("Can't get aenq configuration\n");
+		ena_trc_info(ena_dev, "Can't get aenq configuration\n");
 		return ret;
 	}
 
 	if ((get_resp.u.aenq.supported_groups & groups_flag) != groups_flag) {
-		ena_trc_warn("Trying to set unsupported aenq events. supported flag: 0x%x asked flag: 0x%x\n",
+		ena_trc_warn(ena_dev, "Trying to set unsupported aenq events. supported flag: 0x%x asked flag: 0x%x\n",
 			     get_resp.u.aenq.supported_groups,
 			     groups_flag);
 		return ENA_COM_UNSUPPORTED;
@@ -1578,7 +1594,7 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_dev, u32 groups_flag)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to config AENQ ret: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to config AENQ ret: %d\n", ret);
 
 	return ret;
 }
@@ -1589,17 +1605,17 @@ int ena_com_get_dma_width(struct ena_com_dev *ena_dev)
 	int width;
 
 	if (unlikely(caps == ENA_MMIO_READ_TIMEOUT)) {
-		ena_trc_err("Reg read timeout occurred\n");
+		ena_trc_err(ena_dev, "Reg read timeout occurred\n");
 		return ENA_COM_TIMER_EXPIRED;
 	}
 
 	width = (caps & ENA_REGS_CAPS_DMA_ADDR_WIDTH_MASK) >>
 		ENA_REGS_CAPS_DMA_ADDR_WIDTH_SHIFT;
 
-	ena_trc_dbg("ENA dma width: %d\n", width);
+	ena_trc_dbg(ena_dev, "ENA dma width: %d\n", width);
 
 	if ((width < 32) || width > ENA_MAX_PHYS_ADDR_SIZE_BITS) {
-		ena_trc_err("DMA width illegal value: %d\n", width);
+		ena_trc_err(ena_dev, "DMA width illegal value: %d\n", width);
 		return ENA_COM_INVAL;
 	}
 
@@ -1623,16 +1639,16 @@ int ena_com_validate_version(struct ena_com_dev *ena_dev)
 
 	if (unlikely((ver == ENA_MMIO_READ_TIMEOUT) ||
 		     (ctrl_ver == ENA_MMIO_READ_TIMEOUT))) {
-		ena_trc_err("Reg read timeout occurred\n");
+		ena_trc_err(ena_dev, "Reg read timeout occurred\n");
 		return ENA_COM_TIMER_EXPIRED;
 	}
 
-	ena_trc_info("ena device version: %d.%d\n",
+	ena_trc_info(ena_dev, "ENA device version: %d.%d\n",
 		     (ver & ENA_REGS_VERSION_MAJOR_VERSION_MASK) >>
 		     ENA_REGS_VERSION_MAJOR_VERSION_SHIFT,
 		     ver & ENA_REGS_VERSION_MINOR_VERSION_MASK);
 
-	ena_trc_info("ena controller version: %d.%d.%d implementation version %d\n",
+	ena_trc_info(ena_dev, "ENA controller version: %d.%d.%d implementation version %d\n",
 		     (ctrl_ver & ENA_REGS_CONTROLLER_VERSION_MAJOR_VERSION_MASK)
 		     >> ENA_REGS_CONTROLLER_VERSION_MAJOR_VERSION_SHIFT,
 		     (ctrl_ver & ENA_REGS_CONTROLLER_VERSION_MINOR_VERSION_MASK)
@@ -1648,7 +1664,7 @@ int ena_com_validate_version(struct ena_com_dev *ena_dev)
 
 	/* Validate the ctrl version without the implementation ID */
 	if (ctrl_ver_masked < MIN_ENA_CTRL_VER) {
-		ena_trc_err("ENA ctrl version is lower than the minimal ctrl version the driver supports\n");
+		ena_trc_err(ena_dev, "ENA ctrl version is lower than the minimal ctrl version the driver supports\n");
 		return -1;
 	}
 
@@ -1786,12 +1802,12 @@ int ena_com_admin_init(struct ena_com_dev *ena_dev,
 	dev_sts = ena_com_reg_bar_read32(ena_dev, ENA_REGS_DEV_STS_OFF);
 
 	if (unlikely(dev_sts == ENA_MMIO_READ_TIMEOUT)) {
-		ena_trc_err("Reg read timeout occurred\n");
+		ena_trc_err(ena_dev, "Reg read timeout occurred\n");
 		return ENA_COM_TIMER_EXPIRED;
 	}
 
 	if (!(dev_sts & ENA_REGS_DEV_STS_READY_MASK)) {
-		ena_trc_err("Device isn't ready, abort com init\n");
+		ena_trc_err(ena_dev, "Device isn't ready, abort com init\n");
 		return ENA_COM_NO_DEVICE;
 	}
 
@@ -1869,7 +1885,7 @@ int ena_com_create_io_queue(struct ena_com_dev *ena_dev,
 	int ret;
 
 	if (ctx->qid >= ENA_TOTAL_NUM_QUEUES) {
-		ena_trc_err("Qid (%d) is bigger than max num of queues (%d)\n",
+		ena_trc_err(ena_dev, "Qid (%d) is bigger than max num of queues (%d)\n",
 			    ctx->qid, ENA_TOTAL_NUM_QUEUES);
 		return ENA_COM_INVAL;
 	}
@@ -1928,7 +1944,7 @@ void ena_com_destroy_io_queue(struct ena_com_dev *ena_dev, u16 qid)
 	struct ena_com_io_cq *io_cq;
 
 	if (qid >= ENA_TOTAL_NUM_QUEUES) {
-		ena_trc_err("Qid (%d) is bigger than max num of queues (%d)\n",
+		ena_trc_err(ena_dev, "Qid (%d) is bigger than max num of queues (%d)\n",
 			    qid, ENA_TOTAL_NUM_QUEUES);
 		return;
 	}
@@ -2090,7 +2106,7 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data)
 		timestamp = (u64)aenq_common->timestamp_low |
 			((u64)aenq_common->timestamp_high << 32);
 		ENA_TOUCH(timestamp); /* In case debug is disabled */
-		ena_trc_dbg("AENQ! Group[%x] Syndrom[%x] timestamp: [%" ENA_PRIu64 "s]\n",
+		ena_trc_dbg(ena_dev, "AENQ! Group[%x] Syndrom[%x] timestamp: [%" ENA_PRIu64 "s]\n",
 			    aenq_common->group,
 			    aenq_common->syndrom,
 			    timestamp);
@@ -2137,19 +2153,19 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev,
 
 	if (unlikely((stat == ENA_MMIO_READ_TIMEOUT) ||
 		     (cap == ENA_MMIO_READ_TIMEOUT))) {
-		ena_trc_err("Reg read32 timeout occurred\n");
+		ena_trc_err(ena_dev, "Reg read32 timeout occurred\n");
 		return ENA_COM_TIMER_EXPIRED;
 	}
 
 	if ((stat & ENA_REGS_DEV_STS_READY_MASK) == 0) {
-		ena_trc_err("Device isn't ready, can't reset device\n");
+		ena_trc_err(ena_dev, "Device isn't ready, can't reset device\n");
 		return ENA_COM_INVAL;
 	}
 
 	timeout = (cap & ENA_REGS_CAPS_RESET_TIMEOUT_MASK) >>
 			ENA_REGS_CAPS_RESET_TIMEOUT_SHIFT;
 	if (timeout == 0) {
-		ena_trc_err("Invalid timeout value\n");
+		ena_trc_err(ena_dev, "Invalid timeout value\n");
 		return ENA_COM_INVAL;
 	}
 
@@ -2165,7 +2181,7 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev,
 	rc = wait_for_reset_state(ena_dev, timeout,
 				  ENA_REGS_DEV_STS_RESET_IN_PROGRESS_MASK);
 	if (rc != 0) {
-		ena_trc_err("Reset indication didn't turn on\n");
+		ena_trc_err(ena_dev, "Reset indication didn't turn on\n");
 		return rc;
 	}
 
@@ -2173,7 +2189,7 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev,
 	ENA_REG_WRITE32(ena_dev->bus, 0, ena_dev->reg_bar + ENA_REGS_DEV_CTL_OFF);
 	rc = wait_for_reset_state(ena_dev, timeout, 0);
 	if (rc != 0) {
-		ena_trc_err("Reset indication didn't turn off\n");
+		ena_trc_err(ena_dev, "Reset indication didn't turn off\n");
 		return rc;
 	}
 
@@ -2210,7 +2226,7 @@ static int ena_get_dev_stats(struct ena_com_dev *ena_dev,
 					     sizeof(*get_resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to get stats. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to get stats. error: %d\n", ret);
 
 	return ret;
 }
@@ -2253,7 +2269,7 @@ int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu)
 	int ret;
 
 	if (!ena_com_check_supported_feature_id(ena_dev, ENA_ADMIN_MTU)) {
-		ena_trc_dbg("Feature %d isn't supported\n", ENA_ADMIN_MTU);
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n", ENA_ADMIN_MTU);
 		return ENA_COM_UNSUPPORTED;
 	}
 
@@ -2272,7 +2288,7 @@ int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to set mtu %d. error: %d\n", mtu, ret);
+		ena_trc_err(ena_dev, "Failed to set mtu %d. error: %d\n", mtu, ret);
 
 	return ret;
 }
@@ -2286,7 +2302,7 @@ int ena_com_get_offload_settings(struct ena_com_dev *ena_dev,
 	ret = ena_com_get_feature(ena_dev, &resp,
 				  ENA_ADMIN_STATELESS_OFFLOAD_CONFIG, 0);
 	if (unlikely(ret)) {
-		ena_trc_err("Failed to get offload capabilities %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to get offload capabilities %d\n", ret);
 		return ret;
 	}
 
@@ -2306,7 +2322,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
 
 	if (!ena_com_check_supported_feature_id(ena_dev,
 						ENA_ADMIN_RSS_HASH_FUNCTION)) {
-		ena_trc_dbg("Feature %d isn't supported\n",
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
 			    ENA_ADMIN_RSS_HASH_FUNCTION);
 		return ENA_COM_UNSUPPORTED;
 	}
@@ -2318,7 +2334,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
 		return ret;
 
 	if (!(get_resp.u.flow_hash_func.supported_func & BIT(rss->hash_func))) {
-		ena_trc_err("Func hash %d isn't supported by device, abort\n",
+		ena_trc_err(ena_dev, "Func hash %d isn't supported by device, abort\n",
 			    rss->hash_func);
 		return ENA_COM_UNSUPPORTED;
 	}
@@ -2336,7 +2352,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
 				   &cmd.control_buffer.address,
 				   rss->hash_key_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -2348,7 +2364,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
 					    (struct ena_admin_acq_entry *)&resp,
 					    sizeof(resp));
 	if (unlikely(ret)) {
-		ena_trc_err("Failed to set hash function %d. error: %d\n",
+		ena_trc_err(ena_dev, "Failed to set hash function %d. error: %d\n",
 			    rss->hash_func, ret);
 		return ENA_COM_INVAL;
 	}
@@ -2380,7 +2396,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
 		return rc;
 
 	if (!(BIT(func) & get_resp.u.flow_hash_func.supported_func)) {
-		ena_trc_err("Flow hash function %d isn't supported\n", func);
+		ena_trc_err(ena_dev, "Flow hash function %d isn't supported\n", func);
 		return ENA_COM_UNSUPPORTED;
 	}
 
@@ -2388,7 +2404,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
 	case ENA_ADMIN_TOEPLITZ:
 		if (key) {
 			if (key_len != sizeof(hash_key->key)) {
-				ena_trc_err("key len (%hu) doesn't equal the supported size (%zu)\n",
+				ena_trc_err(ena_dev, "key len (%hu) doesn't equal the supported size (%zu)\n",
 					     key_len, sizeof(hash_key->key));
 				return ENA_COM_INVAL;
 			}
@@ -2401,7 +2417,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
 		rss->hash_init_val = init_val;
 		break;
 	default:
-		ena_trc_err("Invalid hash function (%d)\n", func);
+		ena_trc_err(ena_dev, "Invalid hash function (%d)\n", func);
 		return ENA_COM_INVAL;
 	}
 
@@ -2486,7 +2502,7 @@ int ena_com_set_hash_ctrl(struct ena_com_dev *ena_dev)
 
 	if (!ena_com_check_supported_feature_id(ena_dev,
 						ENA_ADMIN_RSS_HASH_INPUT)) {
-		ena_trc_dbg("Feature %d isn't supported\n",
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
 			    ENA_ADMIN_RSS_HASH_INPUT);
 		return ENA_COM_UNSUPPORTED;
 	}
@@ -2505,7 +2521,7 @@ int ena_com_set_hash_ctrl(struct ena_com_dev *ena_dev)
 				   &cmd.control_buffer.address,
 				   rss->hash_ctrl_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 	cmd.control_buffer.length = sizeof(*hash_ctrl);
@@ -2516,7 +2532,7 @@ int ena_com_set_hash_ctrl(struct ena_com_dev *ena_dev)
 					    (struct ena_admin_acq_entry *)&resp,
 					    sizeof(resp));
 	if (unlikely(ret))
-		ena_trc_err("Failed to set hash input. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to set hash input. error: %d\n", ret);
 
 	return ret;
 }
@@ -2566,7 +2582,7 @@ int ena_com_set_default_hash_ctrl(struct ena_com_dev *ena_dev)
 		available_fields = hash_ctrl->selected_fields[i].fields &
 				hash_ctrl->supported_fields[i].fields;
 		if (available_fields != hash_ctrl->selected_fields[i].fields) {
-			ena_trc_err("hash control doesn't support all the desire configuration. proto %x supported %x selected %x\n",
+			ena_trc_err(ena_dev, "Hash control doesn't support all the desire configuration. proto %x supported %x selected %x\n",
 				    i, hash_ctrl->supported_fields[i].fields,
 				    hash_ctrl->selected_fields[i].fields);
 			return ENA_COM_UNSUPPORTED;
@@ -2592,7 +2608,7 @@ int ena_com_fill_hash_ctrl(struct ena_com_dev *ena_dev,
 	int rc;
 
 	if (proto >= ENA_ADMIN_RSS_PROTO_NUM) {
-		ena_trc_err("Invalid proto num (%u)\n", proto);
+		ena_trc_err(ena_dev, "Invalid proto num (%u)\n", proto);
 		return ENA_COM_INVAL;
 	}
 
@@ -2604,7 +2620,7 @@ int ena_com_fill_hash_ctrl(struct ena_com_dev *ena_dev,
 	/* Make sure all the fields are supported */
 	supported_fields = hash_ctrl->supported_fields[proto].fields;
 	if ((hash_fields & supported_fields) != hash_fields) {
-		ena_trc_err("proto %d doesn't support the required fields %x. supports only: %x\n",
+		ena_trc_err(ena_dev, "Proto %d doesn't support the required fields %x. supports only: %x\n",
 			    proto, hash_fields, supported_fields);
 	}
 
@@ -2645,14 +2661,14 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 
 	if (!ena_com_check_supported_feature_id(ena_dev,
 						ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG)) {
-		ena_trc_dbg("Feature %d isn't supported\n",
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
 			    ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG);
 		return ENA_COM_UNSUPPORTED;
 	}
 
 	ret = ena_com_ind_tbl_convert_to_device(ena_dev);
 	if (ret) {
-		ena_trc_err("Failed to convert host indirection table to device table\n");
+		ena_trc_err(ena_dev, "Failed to convert host indirection table to device table\n");
 		return ret;
 	}
 
@@ -2669,7 +2685,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 				   &cmd.control_buffer.address,
 				   rss->rss_ind_tbl_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -2683,7 +2699,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to set indirect table. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to set indirect table. error: %d\n", ret);
 
 	return ret;
 }
@@ -2848,7 +2864,7 @@ int ena_com_set_host_attributes(struct ena_com_dev *ena_dev)
 				   &cmd.u.host_attr.debug_ba,
 				   host_attr->debug_area_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -2856,7 +2872,7 @@ int ena_com_set_host_attributes(struct ena_com_dev *ena_dev)
 				   &cmd.u.host_attr.os_info_ba,
 				   host_attr->host_info_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -2869,7 +2885,7 @@ int ena_com_set_host_attributes(struct ena_com_dev *ena_dev)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to set host attributes: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to set host attributes: %d\n", ret);
 
 	return ret;
 }
@@ -2881,12 +2897,13 @@ bool ena_com_interrupt_moderation_supported(struct ena_com_dev *ena_dev)
 						  ENA_ADMIN_INTERRUPT_MODERATION);
 }
 
-static int ena_com_update_nonadaptive_moderation_interval(u32 coalesce_usecs,
+static int ena_com_update_nonadaptive_moderation_interval(struct ena_com_dev *ena_dev,
+							  u32 coalesce_usecs,
 							  u32 intr_delay_resolution,
 							  u32 *intr_moder_interval)
 {
 	if (!intr_delay_resolution) {
-		ena_trc_err("Illegal interrupt delay granularity value\n");
+		ena_trc_err(ena_dev, "Illegal interrupt delay granularity value\n");
 		return ENA_COM_FAULT;
 	}
 
@@ -2895,11 +2912,11 @@ static int ena_com_update_nonadaptive_moderation_interval(u32 coalesce_usecs,
 	return 0;
 }
 
-
 int ena_com_update_nonadaptive_moderation_interval_tx(struct ena_com_dev *ena_dev,
 						      u32 tx_coalesce_usecs)
 {
-	return ena_com_update_nonadaptive_moderation_interval(tx_coalesce_usecs,
+	return ena_com_update_nonadaptive_moderation_interval(ena_dev,
+							      tx_coalesce_usecs,
 							      ena_dev->intr_delay_resolution,
 							      &ena_dev->intr_moder_tx_interval);
 }
@@ -2907,7 +2924,8 @@ int ena_com_update_nonadaptive_moderation_interval_tx(struct ena_com_dev *ena_de
 int ena_com_update_nonadaptive_moderation_interval_rx(struct ena_com_dev *ena_dev,
 						      u32 rx_coalesce_usecs)
 {
-	return ena_com_update_nonadaptive_moderation_interval(rx_coalesce_usecs,
+	return ena_com_update_nonadaptive_moderation_interval(ena_dev,
+							      rx_coalesce_usecs,
 							      ena_dev->intr_delay_resolution,
 							      &ena_dev->intr_moder_rx_interval);
 }
@@ -2923,12 +2941,12 @@ int ena_com_init_interrupt_moderation(struct ena_com_dev *ena_dev)
 
 	if (rc) {
 		if (rc == ENA_COM_UNSUPPORTED) {
-			ena_trc_dbg("Feature %d isn't supported\n",
+			ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
 				    ENA_ADMIN_INTERRUPT_MODERATION);
 			rc = 0;
 		} else {
-			ena_trc_err("Failed to get interrupt moderation admin cmd. rc: %d\n",
-				    rc);
+			ena_trc_err(ena_dev,
+				    "Failed to get interrupt moderation admin cmd. rc: %d\n", rc);
 		}
 
 		/* no moderation supported, disable adaptive support */
@@ -2976,7 +2994,7 @@ int ena_com_config_dev_mode(struct ena_com_dev *ena_dev,
 		(llq_info->descs_num_before_header * sizeof(struct ena_eth_io_tx_desc));
 
 	if (unlikely(ena_dev->tx_max_header_size == 0)) {
-		ena_trc_err("the size of the LLQ entry is smaller than needed\n");
+		ena_trc_err(ena_dev, "The size of the LLQ entry is smaller than needed\n");
 		return -EINVAL;
 	}
 
drivers/net/ena/base/ena_com.h +21 -0
index e9601b1a8e..cd116e90e6 100644
@@ -300,6 +300,7 @@ struct ena_com_dev {
 	void __iomem *mem_bar;
 	void *dmadev;
 	void *bus;
+	ena_netdev *net_device;
 
 	enum ena_admin_placement_policy_type tx_mem_queue_type;
 	u32 tx_max_header_size;
@@ -944,6 +945,26 @@ int ena_com_config_dev_mode(struct ena_com_dev *ena_dev,
 			    struct ena_admin_feature_llq_desc *llq_features,
 			    struct ena_llq_configurations *llq_default_config);
 
+/* ena_com_io_sq_to_ena_dev - Extract ena_com_dev using contained field io_sq.
+ * @io_sq: IO submit queue struct
+ *
+ * @return - ena_com_dev struct extracted from io_sq
+ */
+static inline struct ena_com_dev *ena_com_io_sq_to_ena_dev(struct ena_com_io_sq *io_sq)
+{
+	return container_of(io_sq, struct ena_com_dev, io_sq_queues[io_sq->qid]);
+}
+
+/* ena_com_io_cq_to_ena_dev - Extract ena_com_dev using contained field io_cq.
+ * @io_sq: IO submit queue struct
+ *
+ * @return - ena_com_dev struct extracted from io_sq
+ */
+static inline struct ena_com_dev *ena_com_io_cq_to_ena_dev(struct ena_com_io_cq *io_cq)
+{
+	return container_of(io_cq, struct ena_com_dev, io_cq_queues[io_cq->qid]);
+}
+
 static inline bool ena_com_get_adaptive_moderation_enabled(struct ena_com_dev *ena_dev)
 {
 	return ena_dev->adaptive_coalescing;
drivers/net/ena/base/ena_eth_com.c +52 -26

220 lines not on this page · raw message

drivers/net/ena/base/ena_eth_com.h +11 -6
index 7dda16cd9f..0cfd18882e 100644
@@ -143,7 +143,8 @@ static inline bool ena_com_is_doorbell_needed(struct ena_com_io_sq *io_sq,
 						   llq_info->descs_per_entry);
 	}
 
-	ena_trc_dbg("queue: %d num_descs: %d num_entries_needed: %d\n",
+	ena_trc_dbg(ena_com_io_sq_to_ena_dev(io_sq),
+		    "Queue: %d num_descs: %d num_entries_needed: %d\n",
 		    io_sq->qid, num_descs, num_entries_needed);
 
 	return num_entries_needed > io_sq->entries_in_tx_burst_left;
@@ -154,14 +155,16 @@ static inline int ena_com_write_sq_doorbell(struct ena_com_io_sq *io_sq)
 	u16 max_entries_in_tx_burst = io_sq->llq_info.max_entries_in_tx_burst;
 	u16 tail = io_sq->tail;
 
-	ena_trc_dbg("write submission queue doorbell for queue: %d tail: %d\n",
+	ena_trc_dbg(ena_com_io_sq_to_ena_dev(io_sq),
+		    "Write submission queue doorbell for queue: %d tail: %d\n",
 		    io_sq->qid, tail);
 
 	ENA_REG_WRITE32(io_sq->bus, tail, io_sq->db_addr);
 
 	if (is_llq_max_tx_burst_exists(io_sq)) {
-		ena_trc_dbg("reset available entries in tx burst for queue %d to %d\n",
-			     io_sq->qid, max_entries_in_tx_burst);
+		ena_trc_dbg(ena_com_io_sq_to_ena_dev(io_sq),
+			    "Reset available entries in tx burst for queue %d to %d\n",
+			    io_sq->qid, max_entries_in_tx_burst);
 		io_sq->entries_in_tx_burst_left = max_entries_in_tx_burst;
 	}
 
@@ -179,7 +182,8 @@ static inline int ena_com_update_dev_comp_head(struct ena_com_io_cq *io_cq)
 		need_update = unreported_comp > (io_cq->q_depth / ENA_COMP_HEAD_THRESH);
 
 		if (unlikely(need_update)) {
-			ena_trc_dbg("Write completion queue doorbell for queue %d: head: %d\n",
+			ena_trc_dbg(ena_com_io_cq_to_ena_dev(io_cq),
+				    "Write completion queue doorbell for queue %d: head: %d\n",
 				    io_cq->qid, head);
 			ENA_REG_WRITE32(io_cq->bus, head, io_cq->cq_head_db_reg);
 			io_cq->last_head_update = head;
@@ -243,7 +247,8 @@ static inline int ena_com_tx_comp_req_id_get(struct ena_com_io_cq *io_cq,
 
 	*req_id = READ_ONCE16(cdesc->req_id);
 	if (unlikely(*req_id >= io_cq->q_depth)) {
-		ena_trc_err("Invalid req id %d\n", cdesc->req_id);
+		ena_trc_err(ena_com_io_cq_to_ena_dev(io_cq),
+			    "Invalid req id %d\n", cdesc->req_id);
 		return ENA_COM_INVAL;
 	}
 
drivers/net/ena/base/ena_plat_dpdk.h +24 -20

59 lines not on this page · raw message

Signature · 1 line
2.25.1
#27 lore raw

PATCH v2 4/22 net/ena/base: typos, style and comments improvements

In reply to Michal Krawczyk

List of changes:
* Comment style was adjusted for the functions
* The keys_num at "struct ena_admin_feature_rss_flow_hash_control" was renamed to the key_parts to better describe it's meaning
* The RSS indirection table was called "REDIRECTION" -> changed to INDIRECTION
* Change AENQ field "syndrom" -> "syndrome"
* Calculate number of the RSS key parts or whole key by ussing the common way: sizeof of the first element of the RSS key
* Add description of the "enum ena_admin_aq_feature_id"
* Rename "map_rx_buf_bidirectional" field as "rx_buf_mirroring"
* Other minor style fixes (remove extra spaces, add missing line break, improve indentation)
* Remove unused macros ENA_ADMIN_EXTRA_PROPERTIES_*
* Restructure the "if {} else if {} else" conditional statement for setting up the meta descriptor

Fixes 99ecfbf845b3 ("ena: import communication layer")
Fixes b68309be44c0 ("net/ena/base: update communication layer for the ENAv2")
Fixes b2b02edeb0d6 ("net/ena/base: upgrade HAL for new HW features")
---
 drivers/net/ena/base/ena_com.c                | 26 +++---
 .../net/ena/base/ena_defs/ena_admin_defs.h    | 85 +++++++++----------
 drivers/net/ena/base/ena_eth_com.c            | 16 ++--
 drivers/net/ena/ena_ethdev.c                  |  4 +-
 4 files changed, 66 insertions(+), 65 deletions(-)
drivers/net/ena/base/ena_com.c +14 -12
index 9931819bbb..9dc9f280c4 100644
@@ -598,7 +598,7 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
 	return ret;
 }
 
-/**
+/*
  * Set the LLQ configurations of the firmware
  *
  * The driver provides only the enabled feature values to the device,
@@ -1092,7 +1092,7 @@ static void ena_com_hash_key_fill_default_key(struct ena_com_dev *ena_dev)
 	/* The key buffer is stored in the device in an array of
 	 * uint32 elements.
 	 */
-	hash_key->keys_num = ENA_ADMIN_RSS_KEY_PARTS;
+	hash_key->key_parts = ENA_ADMIN_RSS_KEY_PARTS;
 }
 
 static int ena_com_hash_key_allocate(struct ena_com_dev *ena_dev)
@@ -1165,7 +1165,7 @@ static int ena_com_indirect_table_allocate(struct ena_com_dev *ena_dev,
 	int ret;
 
 	ret = ena_com_get_feature(ena_dev, &get_resp,
-				  ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG, 0);
+				  ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG, 0);
 	if (unlikely(ret))
 		return ret;
 
@@ -1977,6 +1977,7 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev,
 
 	memcpy(&get_feat_ctx->dev_attr, &get_resp.u.dev_attr,
 	       sizeof(get_resp.u.dev_attr));
+
 	ena_dev->supported_features = get_resp.u.dev_attr.supported_features;
 
 	if (ena_dev->supported_features & BIT(ENA_ADMIN_MAX_QUEUES_EXT)) {
@@ -2044,7 +2045,7 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev,
 		return rc;
 
 	rc = ena_com_get_feature(ena_dev, &get_resp,
-				 ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG, 0);
+				 ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG, 0);
 	if (!rc)
 		memcpy(&get_feat_ctx->ind_table, &get_resp.u.ind_table,
 		       sizeof(get_resp.u.ind_table));
@@ -2106,9 +2107,9 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data)
 		timestamp = (u64)aenq_common->timestamp_low |
 			((u64)aenq_common->timestamp_high << 32);
 		ENA_TOUCH(timestamp); /* In case debug is disabled */
-		ena_trc_dbg(ena_dev, "AENQ! Group[%x] Syndrom[%x] timestamp: [%" ENA_PRIu64 "s]\n",
+		ena_trc_dbg(ena_dev, "AENQ! Group[%x] Syndrome[%x] timestamp: [%" ENA_PRIu64 "s]\n",
 			    aenq_common->group,
-			    aenq_common->syndrom,
+			    aenq_common->syndrome,
 			    timestamp);
 
 		/* Handle specific event*/
@@ -2410,7 +2411,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
 			}
 			memcpy(hash_key->key, key, key_len);
 			rss->hash_init_val = init_val;
-			hash_key->keys_num = key_len / sizeof(u32);
+			hash_key->key_parts = key_len / sizeof(hash_key->key[0]);
 		}
 		break;
 	case ENA_ADMIN_CRC32:
@@ -2465,7 +2466,8 @@ int ena_com_get_hash_key(struct ena_com_dev *ena_dev, u8 *key)
 		ena_dev->rss.hash_key;
 
 	if (key)
-		memcpy(key, hash_key->key, (size_t)(hash_key->keys_num) << 2);
+		memcpy(key, hash_key->key,
+		       (size_t)(hash_key->key_parts) * sizeof(hash_key->key[0]));
 
 	return 0;
 }
@@ -2660,9 +2662,9 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 	int ret;
 
 	if (!ena_com_check_supported_feature_id(ena_dev,
-						ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG)) {
+						ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG)) {
 		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
-			    ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG);
+			    ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG);
 		return ENA_COM_UNSUPPORTED;
 	}
 
@@ -2677,7 +2679,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 	cmd.aq_common_descriptor.opcode = ENA_ADMIN_SET_FEATURE;
 	cmd.aq_common_descriptor.flags =
 		ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_INDIRECT_MASK;
-	cmd.feat_common.feature_id = ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG;
+	cmd.feat_common.feature_id = ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG;
 	cmd.u.ind_table.size = rss->tbl_log_size;
 	cmd.u.ind_table.inline_index = 0xFFFFFFFF;
 
@@ -2715,7 +2717,7 @@ int ena_com_indirect_table_get(struct ena_com_dev *ena_dev, u32 *ind_tbl)
 		sizeof(struct ena_admin_rss_ind_table_entry);
 
 	rc = ena_com_get_feature_ex(ena_dev, &get_resp,
-				    ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG,
+				    ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG,
 				    rss->rss_ind_tbl_dma_addr,
 				    tbl_size, 0);
 	if (unlikely(rc))
drivers/net/ena/base/ena_defs/ena_admin_defs.h +41 -44

224 lines not on this page · raw message

drivers/net/ena/base/ena_eth_com.c +9 -7
index 701e6721e3..92a9a10a9e 100644
@@ -331,16 +331,18 @@ static int ena_com_create_and_store_tx_meta_desc(struct ena_com_io_sq *io_sq,
 
 		*have_meta = true;
 		return ena_com_create_meta(io_sq, ena_meta);
-	} else if (ena_com_meta_desc_changed(io_sq, ena_tx_ctx)) {
+	}
+
+	if (ena_com_meta_desc_changed(io_sq, ena_tx_ctx)) {
 		*have_meta = true;
 		/* Cache the meta desc */
 		memcpy(&io_sq->cached_tx_meta, ena_meta,
 		       sizeof(struct ena_com_tx_meta));
 		return ena_com_create_meta(io_sq, ena_meta);
-	} else {
-		*have_meta = false;
-		return ENA_COM_OK;
 	}
+
+	*have_meta = false;
+	return ENA_COM_OK;
 }
 
 static void ena_com_rx_set_flags(struct ena_com_io_cq *io_cq,
@@ -626,9 +628,9 @@ int ena_com_add_single_rx_desc(struct ena_com_io_sq *io_sq,
 	desc->length = ena_buf->len;
 
 	desc->ctrl = ENA_ETH_IO_RX_DESC_FIRST_MASK |
-		ENA_ETH_IO_RX_DESC_LAST_MASK |
-		(io_sq->phase & ENA_ETH_IO_RX_DESC_PHASE_MASK) |
-		ENA_ETH_IO_RX_DESC_COMP_REQ_MASK;
+		     ENA_ETH_IO_RX_DESC_LAST_MASK |
+		     ENA_ETH_IO_RX_DESC_COMP_REQ_MASK |
+		     (io_sq->phase & ENA_ETH_IO_RX_DESC_PHASE_MASK);
 
 	desc->req_id = req_id;
 
drivers/net/ena/ena_ethdev.c +2 -2
index f60e843b7f..f1ff4dad36 100644
@@ -2973,7 +2973,7 @@ static void ena_notification(void *data,
 			aenq_e->aenq_common_desc.group,
 			ENA_ADMIN_NOTIFICATION);
 
-	switch (aenq_e->aenq_common_desc.syndrom) {
+	switch (aenq_e->aenq_common_desc.syndrome) {
 	case ENA_ADMIN_UPDATE_HINTS:
 		hints = (struct ena_admin_ena_hw_hints *)
 			(&aenq_e->inline_data_w4);
@@ -2981,7 +2981,7 @@ static void ena_notification(void *data,
 		break;
 	default:
 		PMD_DRV_LOG(ERR, "Invalid aenq notification link state %d\n",
-			aenq_e->aenq_common_desc.syndrom);
+			aenq_e->aenq_common_desc.syndrome);
 	}
 }
 
Signature · 1 line
2.25.1
#28 lore raw

PATCH v2 5/22 net/ena/base: fix issues from the static code scan

In reply to Michal Krawczyk

To silence error messages from the static code analysis, make the type conversions explicit where they're intended.

Also fix the type for the DMA width value.

Fixes 99ecfbf845b3 ("ena: import communication layer")
---
 drivers/net/ena/base/ena_com.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ena/base/ena_com.c +5 -5
index 9dc9f280c4..0cdeb1a2d9 100644
@@ -1382,7 +1382,7 @@ int ena_com_execute_admin_command(struct ena_com_admin_queue *admin_queue,
 				    "Failed to submit command [%ld]\n",
 				    PTR_ERR(comp_ctx));
 
-		return PTR_ERR(comp_ctx);
+		return (int)PTR_ERR(comp_ctx);
 	}
 
 	ret = ena_com_wait_and_process_admin_cq(comp_ctx, admin_queue);
@@ -1602,7 +1602,7 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_dev, u32 groups_flag)
 int ena_com_get_dma_width(struct ena_com_dev *ena_dev)
 {
 	u32 caps = ena_com_reg_bar_read32(ena_dev, ENA_REGS_CAPS_OFF);
-	int width;
+	u32 width;
 
 	if (unlikely(caps == ENA_MMIO_READ_TIMEOUT)) {
 		ena_trc_err(ena_dev, "Reg read timeout occurred\n");
@@ -2280,7 +2280,7 @@ int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu)
 	cmd.aq_common_descriptor.opcode = ENA_ADMIN_SET_FEATURE;
 	cmd.aq_common_descriptor.flags = 0;
 	cmd.feat_common.feature_id = ENA_ADMIN_MTU;
-	cmd.u.mtu.mtu = mtu;
+	cmd.u.mtu.mtu = (u32)mtu;
 
 	ret = ena_com_execute_admin_command(admin_queue,
 					    (struct ena_admin_aq_entry *)&cmd,
@@ -2691,7 +2691,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 		return ret;
 	}
 
-	cmd.control_buffer.length = (1ULL << rss->tbl_log_size) *
+	cmd.control_buffer.length = (u32)(1ULL << rss->tbl_log_size) *
 		sizeof(struct ena_admin_rss_ind_table_entry);
 
 	ret = ena_com_execute_admin_command(admin_queue,
@@ -2713,7 +2713,7 @@ int ena_com_indirect_table_get(struct ena_com_dev *ena_dev, u32 *ind_tbl)
 	u32 tbl_size;
 	int i, rc;
 
-	tbl_size = (1ULL << rss->tbl_log_size) *
+	tbl_size = (u32)(1ULL << rss->tbl_log_size) *
 		sizeof(struct ena_admin_rss_ind_table_entry);
 
 	rc = ena_com_get_feature_ex(ena_dev, &get_resp,
Signature · 1 line
2.25.1
#29 lore raw

PATCH v2 6/22 net/ena/base: destroy multiple "wait events"

In reply to Michal Krawczyk

Although the ENA DPDK PMD doesn't have to perform any actions for destroying the wait event, some other platforms have to.

The macro "ENA_WAIT_EVENT_DESTROY" was renamed to "ENA_WAIT_EVENTS_DESTROY" and also whole implementation responsible for that was moved to a separate function for better readability.

Fixes 3adcba9a8987 ("net/ena: update HAL to the newer version")
---
 drivers/net/ena/base/ena_com.c       | 24 +++++++++++++++++-------
 drivers/net/ena/base/ena_plat_dpdk.h |  4 ++--
 2 files changed, 19 insertions(+), 9 deletions(-)
drivers/net/ena/base/ena_com.c +17 -7
index 0cdeb1a2d9..d025c9cee1 100644
@@ -1671,6 +1671,22 @@ int ena_com_validate_version(struct ena_com_dev *ena_dev)
 	return 0;
 }
 
+static void
+ena_com_free_ena_admin_queue_comp_ctx(struct ena_com_dev *ena_dev,
+				      struct ena_com_admin_queue *admin_queue)
+
+{
+	if (!admin_queue->comp_ctx)
+		return;
+
+	ENA_WAIT_EVENTS_DESTROY(admin_queue);
+	ENA_MEM_FREE(ena_dev->dmadev,
+		     admin_queue->comp_ctx,
+		     (admin_queue->q_depth * sizeof(struct ena_comp_ctx)));
+
+	admin_queue->comp_ctx = NULL;
+}
+
 void ena_com_admin_destroy(struct ena_com_dev *ena_dev)
 {
 	struct ena_com_admin_queue *admin_queue = &ena_dev->admin_queue;
@@ -1679,14 +1695,8 @@ void ena_com_admin_destroy(struct ena_com_dev *ena_dev)
 	struct ena_com_aenq *aenq = &ena_dev->aenq;
 	u16 size;
 
-	if (admin_queue->comp_ctx) {
-		ENA_WAIT_EVENT_DESTROY(admin_queue->comp_ctx->wait_event);
-		ENA_MEM_FREE(ena_dev->dmadev,
-			     admin_queue->comp_ctx,
-			     (admin_queue->q_depth * sizeof(struct ena_comp_ctx)));
-	}
+	ena_com_free_ena_admin_queue_comp_ctx(ena_dev, admin_queue);
 
-	admin_queue->comp_ctx = NULL;
 	size = ADMIN_SQ_SIZE(admin_queue->q_depth);
 	if (sq->entries)
 		ENA_MEM_FREE_COHERENT(ena_dev->dmadev, size, sq->entries,
drivers/net/ena/base/ena_plat_dpdk.h +2 -2
index f1338cd1fe..067909f745 100644
@@ -166,7 +166,7 @@ extern int ena_logtype_com;
 #define ENA_WAIT_EVENT_SIGNAL(waitevent) pthread_cond_signal(&waitevent.cond)
 /* pthread condition doesn't need to be rearmed after usage */
 #define ENA_WAIT_EVENT_CLEAR(...)
-#define ENA_WAIT_EVENT_DESTROY(waitqueue) ((void)(waitqueue))
+#define ENA_WAIT_EVENT_DESTROY(admin_queue) ((void)(admin_queue))
 
 #define ena_wait_event_t ena_wait_queue_t
 #define ENA_MIGHT_SLEEP()
@@ -298,7 +298,7 @@ extern rte_atomic32_t ena_alloc_cnt;
 #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_WAIT_EVENT_DESTROY(waitqueue) ((void)(waitqueue))
+#define ENA_WAIT_EVENTS_DESTROY(waitqueue) ((void)(waitqueue))
 
 #ifndef READ_ONCE
 #define READ_ONCE(var) (*((volatile typeof(var) *)(&(var))))
Signature · 1 line
2.25.1
#30 lore raw

PATCH v2 7/22 net/ena/base: remove indir table from ENA feat ctx

In reply to Michal Krawczyk

The RSS indirection table shouldn't be included as a part of the device features context.

If the driver has to acquire it, it can be done using the separate API whenever the RSS configuration is needed.

---
 drivers/net/ena/base/ena_com.c | 11 -----------
 drivers/net/ena/base/ena_com.h |  1 -
 2 files changed, 12 deletions(-)
drivers/net/ena/base/ena_com.c +0 -11
index d025c9cee1..5ca36ab6d9 100644
@@ -2054,17 +2054,6 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev,
 	else
 		return rc;
 
-	rc = ena_com_get_feature(ena_dev, &get_resp,
-				 ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG, 0);
-	if (!rc)
-		memcpy(&get_feat_ctx->ind_table, &get_resp.u.ind_table,
-		       sizeof(get_resp.u.ind_table));
-	else if (rc == ENA_COM_UNSUPPORTED)
-		memset(&get_feat_ctx->ind_table, 0x0,
-		       sizeof(get_feat_ctx->ind_table));
-	else
-		return rc;
-
 	return 0;
 }
 
drivers/net/ena/base/ena_com.h +0 -1
index cd116e90e6..ca84e2e8bc 100644
@@ -338,7 +338,6 @@ struct ena_com_dev_get_features_ctx {
 	struct ena_admin_feature_offload_desc offload;
 	struct ena_admin_ena_hw_hints hw_hints;
 	struct ena_admin_feature_llq_desc llq;
-	struct ena_admin_feature_rss_ind_table ind_table;
 };
 
 struct ena_com_create_io_ctx {
Signature · 1 line
2.25.1
#31 lore raw

PATCH v2 8/22 net/ena/base: remove mutable RSS from the host info

In reply to Michal Krawczyk

This feature wasn't used by any of the drivers. Because of that, it was removed.

---
 drivers/net/ena/base/ena_defs/ena_admin_defs.h | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/net/ena/base/ena_defs/ena_admin_defs.h +1 -12
index 40c2db717c..56768e1a1b 100644
@@ -866,7 +866,7 @@ struct ena_admin_host_info {
 
 	uint16_t reserved;
 
-	/* 0 : mutable_rss_table_size
+	/* 0 : reserved
 	 * 1 : rx_offset
 	 * 2 : interrupt_moderation
 	 * 3 : rx_buf_mirroring
@@ -1189,7 +1189,6 @@ struct ena_admin_ena_mmio_req_read_less_resp {
 #define ENA_ADMIN_HOST_INFO_DEVICE_MASK                     GENMASK(7, 3)
 #define ENA_ADMIN_HOST_INFO_BUS_SHIFT                       8
 #define ENA_ADMIN_HOST_INFO_BUS_MASK                        GENMASK(15, 8)
-#define ENA_ADMIN_HOST_INFO_MUTABLE_RSS_TABLE_SIZE_MASK     BIT(0)
 #define ENA_ADMIN_HOST_INFO_RX_OFFSET_SHIFT                 1
 #define ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK                  BIT(1)
 #define ENA_ADMIN_HOST_INFO_INTERRUPT_MODERATION_SHIFT      2
@@ -1619,16 +1618,6 @@ static inline void set_ena_admin_host_info_bus(struct ena_admin_host_info *p, ui
 	p->bdf |= (val << ENA_ADMIN_HOST_INFO_BUS_SHIFT) & ENA_ADMIN_HOST_INFO_BUS_MASK;
 }
 
-static inline uint32_t get_ena_admin_host_info_mutable_rss_table_size(const struct ena_admin_host_info *p)
-{
-	return p->driver_supported_features & ENA_ADMIN_HOST_INFO_MUTABLE_RSS_TABLE_SIZE_MASK;
-}
-
-static inline void set_ena_admin_host_info_mutable_rss_table_size(struct ena_admin_host_info *p, uint32_t val)
-{
-	p->driver_supported_features |= val & ENA_ADMIN_HOST_INFO_MUTABLE_RSS_TABLE_SIZE_MASK;
-}
-
 static inline uint32_t get_ena_admin_host_info_rx_offset(const struct ena_admin_host_info *p)
 {
 	return (p->driver_supported_features & ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK) >> ENA_ADMIN_HOST_INFO_RX_OFFSET_SHIFT;
Signature · 1 line
2.25.1
#32 lore raw

PATCH v2 9/22 net/ena/base: update generation date and commit

In reply to Michal Krawczyk

The current ena_com version was generated on 18.09.2020.

---
 drivers/net/ena/base/ena_defs/ena_gen_info.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ena/base/ena_defs/ena_gen_info.h +2 -2
index 54bbfda11f..49895108d5 100644
@@ -2,5 +2,5 @@
  * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates.
  * All rights reserved.
  */
-#define	ENA_GEN_DATE	"Sun Apr 26 13:45:21 DST 2020"
-#define	ENA_GEN_COMMIT	"37aa7c3"
+#define	ENA_GEN_DATE	"Fri Sep 18 17:09:00 IDT 2020"
+#define	ENA_GEN_COMMIT	"0f80d82"
Signature · 1 line
2.25.1
#33 lore raw

PATCH v2 10/22 net/ena/base: use rte_prefetch0_write

In reply to Michal Krawczyk

As in the v20.11 rte_prefetch0_write API was added, it should be used in the platform file for the definition of the macro prefetchw, instead of using simply prefetch0.

---
 drivers/net/ena/base/ena_plat_dpdk.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ena/base/ena_plat_dpdk.h +1 -1
index 067909f745..6902efae08 100644
@@ -290,7 +290,7 @@ extern rte_atomic32_t ena_alloc_cnt;
 #define might_sleep()
 
 #define prefetch(x) rte_prefetch0(x)
-#define prefetchw(x) prefetch(x)
+#define prefetchw(x) rte_prefetch0_write(x)
 
 #define lower_32_bits(x) ((uint32_t)(x))
 #define upper_32_bits(x) ((uint32_t)(((x) >> 16) >> 16))
Signature · 1 line
2.25.1
#34 lore raw

PATCH v2 11/22 net/ena/base: adjust changes to lastest ena-com

In reply to Michal Krawczyk

From: Amit Bernstein <[email protected]>

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

---
 drivers/net/ena/base/ena_plat_dpdk.h | 242 +++++++++++++--------------
 drivers/net/ena/ena_ethdev.c         |   2 +-
 2 files changed, 114 insertions(+), 130 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +113 -129
index 6902efae08..591bc6c8bb 100644
@@ -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,15 +97,15 @@ 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...)				\
+#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))		\
+		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)
@@ -117,51 +119,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)				\
+#define ENA_SPINLOCK_LOCK(spinlock, flags)				       \
 	({(void)flags; rte_spinlock_lock(&spinlock); })
-#define ENA_SPINLOCK_UNLOCK(spinlock, flags)				\
+#define ENA_SPINLOCK_UNLOCK(spinlock, flags)				       \
 	({(void)flags; rte_spinlock_unlock(&(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 */
@@ -173,104 +175,88 @@ 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)
@@ -296,7 +282,7 @@ 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)				\
+#define ENA_GET_SYSTEM_TIMEOUT(timeout_us)				       \
     (timeout_us * rte_get_timer_hz() / 1000000 + rte_get_timer_cycles())
 #define ENA_WAIT_EVENTS_DESTROY(waitqueue) ((void)(waitqueue))
 
@@ -309,14 +295,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))
@@ -329,7 +315,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_ */
drivers/net/ena/ena_ethdev.c +1 -1
index f1ff4dad36..3c9102cd19 100644
@@ -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),
Signature · 1 line
2.25.1
#35 lore raw

PATCH v2 12/22 net/ena: fix parsing of large_llq_hdr argument

In reply to Michal Krawczyk

From: Igor Chauskin <[email protected]>

The code incorrectly checked the return value of comparison when parsing the argument key name. The return value of strcmp should be compared to 0 to identify a match.

Fixes 8a7a73f26cc9 ("net/ena: support large LLQ headers")
---
 drivers/net/ena/ena_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ena/ena_ethdev.c +1 -1
index 3c9102cd19..cb8ad5c3d0 100644
@@ -2865,7 +2865,7 @@ static int ena_process_bool_devarg(const char *key,
 	}
 
 	/* Now, assign it to the proper adapter field. */
-	if (strcmp(key, ENA_DEVARG_LARGE_LLQ_HDR))
+	if (strcmp(key, ENA_DEVARG_LARGE_LLQ_HDR) == 0)
 		adapter->use_large_llq_hdr = bool_value;
 
 	return 0;
Signature · 1 line
2.25.1
#36 lore raw

PATCH v2 13/22 net/ena: terminate devargs allowed keys with NULL

In reply to Michal Krawczyk

As the documentation of rte_kvargs_parse() states, the valid_keys argument must be NULL terminated. Lack of this feature may cause segmentation fault if the passed devarg will be different then the supported value.

Fixes 8a7a73f26cc9 ("net/ena: support large LLQ headers")
---
 drivers/net/ena/ena_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ena/ena_ethdev.c +1 -0
index cb8ad5c3d0..6092288239 100644
@@ -2876,6 +2876,7 @@ static int ena_parse_devargs(struct ena_adapter *adapter,
 {
 	static const char * const allowed_args[] = {
 		ENA_DEVARG_LARGE_LLQ_HDR,
+		NULL,
 	};
 	struct rte_kvargs *kvlist;
 	int rc;
Signature · 1 line
2.25.1
#37 lore raw

PATCH v2 14/22 net/ena: indicate Rx RSS hash presence

In reply to Michal Krawczyk

To make it possible to the app to determine if the hash was calculated for the packet or not, the PKT_RX_RSS_HASH should be set in the mbuf's ol_flags.

As the PMD wasn't setting that, the application couldn't check if there is a hash in a proper way.

The hash is valid only if it's UDP or TCP and the IP packet wasn't fragmented.

Fixes e5df9f33db00 ("net/ena: fix passing RSS hash to mbuf")
---
 drivers/net/ena/ena_ethdev.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ena/ena_ethdev.c +7 -2
index 6092288239..5d107775f4 100644
@@ -51,6 +51,8 @@
 
 #define ENA_MIN_RING_DESC	128
 
+#define ENA_PTYPE_HAS_HASH	(RTE_PTYPE_L4_TCP | RTE_PTYPE_L4_UDP)
+
 enum ethtool_stringset {
 	ETH_SS_TEST             = 0,
 	ETH_SS_STATS,
@@ -314,6 +316,11 @@ static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
 		else
 			ol_flags |= PKT_RX_L4_CKSUM_GOOD;
 
+	if (likely((packet_type & ENA_PTYPE_HAS_HASH) && !ena_rx_ctx->frag)) {
+		ol_flags |= PKT_RX_RSS_HASH;
+		mbuf->hash.rss = ena_rx_ctx->hash;
+	}
+
 	mbuf->ol_flags = ol_flags;
 	mbuf->packet_type = packet_type;
 }
@@ -2245,8 +2252,6 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 			++rx_ring->rx_stats.bad_csum;
 		}
 
-		mbuf->hash.rss = ena_rx_ctx.hash;
-
 		rx_pkts[completed] = mbuf;
 		rx_ring->rx_stats.bytes += mbuf->pkt_len;
 	}
Signature · 1 line
2.25.1
#38 lore raw

PATCH v2 15/22 net/ena: remove endian swap functions

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

swap*_*_le() functions are not used anywhere and besides there are rte alternatives already present.

Fixes 1173fca25af9 ("ena: add polling-mode driver")
---
 drivers/net/ena/ena_platform.h | 12 ------------
 1 file changed, 12 deletions(-)
drivers/net/ena/ena_platform.h +0 -12
index d3e40e0e9e..748928b2d9 100644
@@ -6,18 +6,6 @@
 #ifndef __ENA_PLATFORM_H__
 #define __ENA_PLATFORM_H__
 
-#define swap16_to_le(x)		(x)
-
-#define swap32_to_le(x)		(x)
-
-#define swap64_to_le(x)		(x)
-
-#define swap16_from_le(x)       (x)
-
-#define swap32_from_le(x)	(x)
-
-#define swap64_from_le(x)	(x)
-
 #define ena_assert_msg(cond, msg)		\
 	do {					\
 		if (unlikely(!(cond))) {	\
Signature · 1 line
2.25.1
#39 lore raw

PATCH v2 16/22 net/ena: handle spurious wakeups in ENA_WAIT_EVENT

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

pthread_cond_timedwait() may spuriously wakeup according to POSIX. Therefore it is required to check whether predicate is actually true before finishing the waiting loop.

---
 drivers/net/ena/base/ena_plat_dpdk.h | 75 +++++++++++++++++-----------
 1 file changed, 47 insertions(+), 28 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +47 -28
index 591bc6c8bb..bfb4b9aaa8 100644
@@ -77,6 +77,14 @@ typedef uint64_t dma_addr_t;
 #define mmiowb rte_io_wmb
 #define __iomem
 
+#ifndef READ_ONCE
+#define READ_ONCE(var) (*((volatile typeof(var) *)(&(var))))
+#endif
+
+#define READ_ONCE8(var) READ_ONCE(var)
+#define READ_ONCE16(var) READ_ONCE(var)
+#define READ_ONCE32(var) READ_ONCE(var)
+
 #define US_PER_S 1000000
 #define ENA_GET_SYSTEM_USECS()						       \
 	(rte_get_timer_cycles() * US_PER_S / rte_get_timer_hz())
@@ -137,40 +145,59 @@ extern int ena_logtype_com;
 	({(void)flags; rte_spinlock_unlock(&(spinlock)); })
 #define ENA_SPINLOCK_DESTROY(spinlock) ((void)spinlock)
 
-#define q_waitqueue_t							       \
-	struct {							       \
-		pthread_cond_t cond;					       \
-		pthread_mutex_t mutex;					       \
-	}
+typedef struct {
+	pthread_cond_t cond;
+	pthread_mutex_t mutex;
+	uint8_t flag;
+} ena_wait_event_t;
 
-#define ena_wait_queue_t q_waitqueue_t
-
-#define ENA_WAIT_EVENT_INIT(waitqueue)					       \
+#define ENA_WAIT_EVENT_INIT(waitevent)					       \
 	do {								       \
-		pthread_mutex_init(&(waitqueue).mutex, NULL);		       \
-		pthread_cond_init(&(waitqueue).cond, NULL);		       \
+		ena_wait_event_t *_we = &(waitevent);			       \
+		pthread_mutex_init(&_we->mutex, NULL);			       \
+		pthread_cond_init(&_we->cond, NULL);			       \
+		_we->flag = 0;						       \
 	} while (0)
 
 #define ENA_WAIT_EVENT_WAIT(waitevent, timeout)				       \
 	do {								       \
+		ena_wait_event_t *_we = &(waitevent);			       \
+		typeof(timeout) _tmo = (timeout);			       \
+		int ret = 0;						       \
 		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_sec = now.tv_sec + _tmo / 1000000UL;		       \
+		timeout_us = _tmo % 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);			       \
+		pthread_mutex_lock(&_we->mutex);			       \
+		while (ret == 0 && !_we->flag) {			       \
+			ret = pthread_cond_timedwait(&_we->cond,	       \
+				&_we->mutex, &wait);			       \
+		}							       \
+		/* Asserts only if not working on ena_wait_event_t */	       \
+		if (unlikely(ret != 0 && ret != ETIMEDOUT))		       \
+			rte_panic("Invalid wait event. pthread ret: %d\n",     \
+				  ret);					       \
+		else if (unlikely(ret == ETIMEDOUT))			       \
+			ena_trc_err(NULL,				       \
+				"Timeout waiting for " #waitevent "\n");       \
+		_we->flag = 0;						       \
+		pthread_mutex_unlock(&_we->mutex);			       \
+	} while (0)
+#define ENA_WAIT_EVENT_SIGNAL(waitevent)				       \
+	do {								       \
+		ena_wait_event_t *_we = &(waitevent);			       \
+		pthread_mutex_lock(&_we->mutex);			       \
+		_we->flag = 1;						       \
+		pthread_cond_signal(&_we->cond);			       \
+		pthread_mutex_unlock(&_we->mutex);			       \
 	} while (0)
-#define ENA_WAIT_EVENT_SIGNAL(waitevent) pthread_cond_signal(&waitevent.cond)
 /* pthread condition doesn't need to be rearmed after usage */
 #define ENA_WAIT_EVENT_CLEAR(...)
-#define ENA_WAIT_EVENT_DESTROY(admin_queue) ((void)(admin_queue))
+#define ENA_WAIT_EVENT_DESTROY(waitevent) ((void)(waitevent))
 
-#define ena_wait_event_t ena_wait_queue_t
 #define ENA_MIGHT_SLEEP()
 
 #define ena_time_t uint64_t
@@ -284,15 +311,7 @@ extern rte_atomic64_t ena_alloc_cnt;
 #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_WAIT_EVENTS_DESTROY(waitqueue) ((void)(waitqueue))
-
-#ifndef READ_ONCE
-#define READ_ONCE(var) (*((volatile typeof(var) *)(&(var))))
-#endif
-
-#define READ_ONCE8(var) READ_ONCE(var)
-#define READ_ONCE16(var) READ_ONCE(var)
-#define READ_ONCE32(var) READ_ONCE(var)
+#define ENA_WAIT_EVENTS_DESTROY(admin_queue) ((void)(admin_queue))
 
 /* The size must be 8 byte align */
 #define ENA_MEMCPY_TO_DEVICE_64(dst, src, size)				       \
Signature · 1 line
2.25.1
#40 lore raw

PATCH v2 17/22 net/ena: support SMP for mz alloc counter

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

Introduce a memory area for ENA driver shared between all the processes of a same prefix (memzone backed).
Move the memzone allocation counter for ENA_MEM_ALLOC_COHERENT there so that all processes may utilize it.

---
 drivers/net/ena/base/ena_plat_dpdk.h |  6 ++--
 drivers/net/ena/ena_ethdev.c         | 46 +++++++++++++++++++++++++++-
 drivers/net/ena/ena_ethdev.h         |  8 +++++
 3 files changed, 56 insertions(+), 4 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +3 -3
index bfb4b9aaa8..3b85003cd0 100644
@@ -209,7 +209,7 @@ typedef struct {
  * Each rte_memzone should have unique name.
  * To satisfy it, count number of allocations and add it to name.
  */
-extern rte_atomic64_t ena_alloc_cnt;
+extern rte_atomic64_t *ena_alloc_cnt;
 
 #define ENA_MEM_ALLOC_COHERENT_ALIGNED(					       \
 	dmadev, size, virt, phys, mem_handle, alignment)		       \
@@ -219,7 +219,7 @@ extern rte_atomic64_t ena_alloc_cnt;
 		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));   \
+				rte_atomic64_add_return(ena_alloc_cnt, 1));    \
 			mz = rte_memzone_reserve_aligned(z_name, size,	       \
 					SOCKET_ID_ANY, RTE_MEMZONE_IOVA_CONTIG,\
 					alignment);			       \
@@ -249,7 +249,7 @@ extern rte_atomic64_t ena_alloc_cnt;
 		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));   \
+				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;				       \
drivers/net/ena/ena_ethdev.c +45 -1

68 lines not on this page · raw message

drivers/net/ena/ena_ethdev.h +8 -0
index ae235897ee..e8858c6118 100644
@@ -207,6 +207,14 @@ struct ena_offloads {
 	bool rx_csum_supported;
 };
 
+/* Holds data shared between all instances of ENA PMD. */
+struct ena_shared_data {
+	/* Each rte_memzone should have unique name.
+	 * To satisfy it, count number of allocation and add it to name.
+	 */
+	rte_atomic64_t mz_alloc_cnt;
+};
+
 /* board specific private data structure */
 struct ena_adapter {
 	/* OS defined structs */
Signature · 1 line
2.25.1
#41 lore raw

PATCH v2 18/22 net/ena: move default RSS key to shared mem

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

Make sure the same random generated RSS key is available to all ENA PMD instances in all processes.

---
 drivers/net/ena/ena_ethdev.c | 16 +++++-----------
 drivers/net/ena/ena_ethdev.h |  1 +
 2 files changed, 6 insertions(+), 11 deletions(-)
drivers/net/ena/ena_ethdev.c +5 -11
index 0780e2fee2..5c365e1ab5 100644
@@ -276,19 +276,9 @@ static const struct eth_dev_ops ena_dev_ops = {
 
 void ena_rss_key_fill(void *key, size_t size)
 {
-	static bool key_generated;
-	static uint8_t default_key[ENA_HASH_KEY_SIZE];
-	size_t i;
-
 	RTE_ASSERT(size <= ENA_HASH_KEY_SIZE);
 
-	if (!key_generated) {
-		for (i = 0; i < ENA_HASH_KEY_SIZE; ++i)
-			default_key[i] = rte_rand() & 0xff;
-		key_generated = true;
-	}
-
-	rte_memcpy(key, default_key, size);
+	rte_memcpy(key, ena_shared_data->default_key, size);
 }
 
 static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
@@ -1758,7 +1748,11 @@ static uint32_t ena_calc_max_io_queue_num(struct ena_com_dev *ena_dev,
 
 static void ena_prepare_shared_data(struct ena_shared_data *shared_data)
 {
+	size_t i;
+
 	memset(shared_data, 0, sizeof(*shared_data));
+	for (i = 0; i < ENA_HASH_KEY_SIZE; ++i)
+		shared_data->default_key[i] = rte_rand() & 0xff;
 }
 
 static int ena_shared_data_init(void)
drivers/net/ena/ena_ethdev.h +1 -0
index e8858c6118..1f7383dce0 100644
@@ -209,6 +209,7 @@ struct ena_offloads {
 
 /* Holds data shared between all instances of ENA PMD. */
 struct ena_shared_data {
+	uint8_t default_key[ENA_HASH_KEY_SIZE];
 	/* Each rte_memzone should have unique name.
 	 * To satisfy it, count number of allocation and add it to name.
 	 */
Signature · 1 line
2.25.1
#42 lore raw

PATCH v2 19/22 net/ena: make ethdev references smp safe

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

rte_pci_device and rte_eth_dev are process-local structures. Therefore ena_adapter::pdev and ena_adapter::rte_dev cannot be used universally. Switch this to extracting those structures via rte_eth_devices indexing and remove pdev since it's not used outside of init.

---
 drivers/net/ena/ena_ethdev.c | 47 ++++++++++++++++++------------------
 drivers/net/ena/ena_ethdev.h |  5 ++--
 2 files changed, 25 insertions(+), 27 deletions(-)
drivers/net/ena/ena_ethdev.c +23 -24
index 5c365e1ab5..90ea40513a 100644
@@ -168,6 +168,7 @@ static const struct rte_pci_id pci_id_ena_map[] = {
 static struct ena_aenq_handlers aenq_handlers;
 
 static int ena_device_init(struct ena_com_dev *ena_dev,
+			   struct rte_pci_device *pdev,
 			   struct ena_com_dev_get_features_ctx *get_feat_ctx,
 			   bool *wd_state);
 static int ena_dev_configure(struct rte_eth_dev *dev);
@@ -451,11 +452,11 @@ static void ena_config_host_info(struct ena_com_dev *ena_dev)
 }
 
 /* This function calculates the number of xstats based on the current config */
-static unsigned int ena_xstats_calc_num(struct rte_eth_dev *dev)
+static unsigned int ena_xstats_calc_num(struct rte_eth_dev_data *data)
 {
 	return ENA_STATS_ARRAY_GLOBAL + ENA_STATS_ARRAY_ENI +
-		(dev->data->nb_tx_queues * ENA_STATS_ARRAY_TX) +
-		(dev->data->nb_rx_queues * ENA_STATS_ARRAY_RX);
+		(data->nb_tx_queues * ENA_STATS_ARRAY_TX) +
+		(data->nb_rx_queues * ENA_STATS_ARRAY_RX);
 }
 
 static void ena_config_debug_area(struct ena_adapter *adapter)
@@ -463,7 +464,7 @@ static void ena_config_debug_area(struct ena_adapter *adapter)
 	u32 debug_area_size;
 	int rc, ss_count;
 
-	ss_count = ena_xstats_calc_num(adapter->rte_dev);
+	ss_count = ena_xstats_calc_num(adapter->edev_data);
 
 	/* allocate 32 bytes for each string and 64bit for the value */
 	debug_area_size = ss_count * ETH_GSTRING_LEN + sizeof(u64) * ss_count;
@@ -587,7 +588,7 @@ static int ena_rss_reta_update(struct rte_eth_dev *dev,
 	}
 
 	PMD_DRV_LOG(DEBUG, "%s(): RSS configured %d entries  for port %d\n",
-		__func__, reta_size, adapter->rte_dev->data->port_id);
+		__func__, reta_size, dev->data->port_id);
 
 	return 0;
 }
@@ -631,7 +632,7 @@ static int ena_rss_reta_query(struct rte_eth_dev *dev,
 static int ena_rss_init_default(struct ena_adapter *adapter)
 {
 	struct ena_com_dev *ena_dev = &adapter->ena_dev;
-	uint16_t nb_rx_queues = adapter->rte_dev->data->nb_rx_queues;
+	uint16_t nb_rx_queues = adapter->edev_data->nb_rx_queues;
 	int rc, i;
 	u32 val;
 
@@ -669,8 +670,7 @@ static int ena_rss_init_default(struct ena_adapter *adapter)
 		PMD_DRV_LOG(ERR, "Cannot flush the indirect table\n");
 		goto err_fill_indir;
 	}
-	PMD_DRV_LOG(DEBUG, "RSS configured for port %d\n",
-		adapter->rte_dev->data->port_id);
+	PMD_DRV_LOG(DEBUG, "RSS configured for port %d\n", adapter->port_id);
 
 	return 0;
 
@@ -841,10 +841,10 @@ static uint32_t ena_get_mtu_conf(struct ena_adapter *adapter)
 {
 	uint32_t max_frame_len = adapter->max_mtu;
 
-	if (adapter->rte_eth_dev_data->dev_conf.rxmode.offloads &
+	if (adapter->edev_data->dev_conf.rxmode.offloads &
 	    DEV_RX_OFFLOAD_JUMBO_FRAME)
 		max_frame_len =
-			adapter->rte_eth_dev_data->dev_conf.rxmode.max_rx_pkt_len;
+			adapter->edev_data->dev_conf.rxmode.max_rx_pkt_len;
 
 	return max_frame_len;
 }
@@ -1064,8 +1064,8 @@ static int ena_start(struct rte_eth_dev *dev)
 	if (rc)
 		goto err_start_tx;
 
-	if (adapter->rte_dev->data->dev_conf.rxmode.mq_mode &
-	    ETH_MQ_RX_RSS_FLAG && adapter->rte_dev->data->nb_rx_queues > 0) {
+	if (adapter->edev_data->dev_conf.rxmode.mq_mode &
+	    ETH_MQ_RX_RSS_FLAG && adapter->edev_data->nb_rx_queues > 0) {
 		rc = ena_rss_init_default(adapter);
 		if (rc)
 			goto err_rss_init;
@@ -1505,6 +1505,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count)
 }
 
 static int ena_device_init(struct ena_com_dev *ena_dev,
+			   struct rte_pci_device *pdev,
 			   struct ena_com_dev_get_features_ctx *get_feat_ctx,
 			   bool *wd_state)
 {
@@ -1522,9 +1523,7 @@ static int ena_device_init(struct ena_com_dev *ena_dev,
 	/* The PCIe configuration space revision id indicate if mmio reg
 	 * read is disabled.
 	 */
-	readless_supported =
-		!(((struct rte_pci_device *)ena_dev->dmadev)->id.class_id
-			       & ENA_MMIO_DISABLE_REG_READ);
+	readless_supported = !(pdev->id.class_id & ENA_MMIO_DISABLE_REG_READ);
 	ena_com_set_mmio_read_mode(ena_dev, readless_supported);
 
 	/* reset device */
@@ -1634,7 +1633,7 @@ static void ena_timer_wd_callback(__rte_unused struct rte_timer *timer,
 				  void *arg)
 {
 	struct ena_adapter *adapter = arg;
-	struct rte_eth_dev *dev = adapter->rte_dev;
+	struct rte_eth_dev *dev = &rte_eth_devices[adapter->port_id];
 
 	check_for_missing_keep_alive(adapter);
 	check_for_admin_com_state(adapter);
@@ -1819,11 +1818,10 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	memset(adapter, 0, sizeof(struct ena_adapter));
 	ena_dev = &adapter->ena_dev;
 
-	adapter->rte_eth_dev_data = eth_dev->data;
-	adapter->rte_dev = eth_dev;
+	adapter->edev_data = eth_dev->data;
+	adapter->port_id = eth_dev->data->port_id;
 
 	pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
-	adapter->pdev = pci_dev;
 
 	PMD_INIT_LOG(INFO, "Initializing %x:%x:%x.%d",
 		     pci_dev->addr.domain,
@@ -1843,7 +1841,8 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	ena_dev->reg_bar = adapter->regs;
-	ena_dev->dmadev = adapter->pdev;
+	/* This is a dummy pointer for ena_com functions. */
+	ena_dev->dmadev = adapter;
 
 	adapter->id_number = adapters_found;
 
@@ -1857,7 +1856,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	/* device specific initialization routine */
-	rc = ena_device_init(ena_dev, &get_feat_ctx, &wd_state);
+	rc = ena_device_init(ena_dev, pci_dev, &get_feat_ctx, &wd_state);
 	if (rc) {
 		PMD_INIT_LOG(CRIT, "Failed to init ENA device");
 		goto err;
@@ -2716,7 +2715,7 @@ static int ena_xstats_get_names(struct rte_eth_dev *dev,
 				struct rte_eth_xstat_name *xstats_names,
 				unsigned int n)
 {
-	unsigned int xstats_count = ena_xstats_calc_num(dev);
+	unsigned int xstats_count = ena_xstats_calc_num(dev->data);
 	unsigned int stat, i, count = 0;
 
 	if (n < xstats_count || !xstats_names)
@@ -2765,7 +2764,7 @@ static int ena_xstats_get(struct rte_eth_dev *dev,
 			  unsigned int n)
 {
 	struct ena_adapter *adapter = dev->data->dev_private;
-	unsigned int xstats_count = ena_xstats_calc_num(dev);
+	unsigned int xstats_count = ena_xstats_calc_num(dev->data);
 	unsigned int stat, i, count = 0;
 	int stat_offset;
 	void *stats_begin;
@@ -2997,7 +2996,7 @@ static void ena_update_on_link_change(void *adapter_data,
 
 	adapter = adapter_data;
 	aenq_link_desc = (struct ena_admin_aenq_link_change_desc *)aenq_e;
-	eth_dev = adapter->rte_dev;
+	eth_dev = &rte_eth_devices[adapter->port_id];
 
 	status = get_ena_admin_aenq_link_change_desc_link_status(aenq_link_desc);
 	adapter->link_status = status;
drivers/net/ena/ena_ethdev.h +2 -3
index 1f7383dce0..32e92e1d6b 100644
@@ -219,9 +219,8 @@ struct ena_shared_data {
 /* board specific private data structure */
 struct ena_adapter {
 	/* OS defined structs */
-	struct rte_pci_device *pdev;
-	struct rte_eth_dev_data *rte_eth_dev_data;
-	struct rte_eth_dev *rte_dev;
+	struct rte_eth_dev_data *edev_data;
+	int port_id;
 
 	struct ena_com_dev ena_dev __rte_cache_aligned;
 
Signature · 1 line
2.25.1
#43 lore raw

PATCH v2 20/22 net/ena: disable dev_ops not supported in SMP

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

For dev_ops not supported in SMP, either return -EPERM or return without doing anything. In both cases log a warning.

---
 drivers/net/ena/ena_ethdev.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/net/ena/ena_ethdev.c +18 -0
index 90ea40513a..73e99e956a 100644
@@ -529,6 +529,12 @@ ena_dev_reset(struct rte_eth_dev *dev)
 {
 	int rc = 0;
 
+	/* Cannot release memory in secondary process */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		PMD_DRV_LOG(WARNING, "dev_reset not supported in secondary.\n");
+		return -EPERM;
+	}
+
 	ena_destroy_device(dev);
 	rc = eth_ena_dev_init(dev);
 	if (rc)
@@ -1052,6 +1058,12 @@ static int ena_start(struct rte_eth_dev *dev)
 	uint64_t ticks;
 	int rc = 0;
 
+	/* Cannot allocate memory in secondary process */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		PMD_DRV_LOG(WARNING, "dev_start not supported in secondary.\n");
+		return -EPERM;
+	}
+
 	rc = ena_check_valid_conf(adapter);
 	if (rc)
 		return rc;
@@ -1098,6 +1110,12 @@ static int ena_stop(struct rte_eth_dev *dev)
 	struct ena_com_dev *ena_dev = &adapter->ena_dev;
 	int rc;
 
+	/* Cannot free memory in secondary process */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		PMD_DRV_LOG(WARNING, "dev_stop not supported in secondary.\n");
+		return -EPERM;
+	}
+
 	rte_timer_stop_sync(&adapter->timer_wd);
 	ena_queue_stop_all(dev, ENA_RING_TYPE_TX);
 	ena_queue_stop_all(dev, ENA_RING_TYPE_RX);
Signature · 1 line
2.25.1
#44 lore raw

PATCH v2 21/22 net/ena: report default ring size

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

Remove invalid ring size alignment logic and add default rx and tx port ring sizes to the device info spec.

The logic in lines 1297 and 1371 is invalid. The RTE_ETH_DEV_FALLBACK_RX_RINGSIZE (and the TX counterpart) is a value that rte_eth_rx_queue_setup() will set if dev_info.default_rxportconf.ring_size is 0 and user provided 0 in nb_rx_desc argument. However the current code treats it as a hint for the PMD to change the ring size to internal defaults.

Additionally since the ENA_DEFAULT_RING_SIZE is defined, report it in the device capabilities so that both rte_ethdev code and the user can utilize it for device configuration.

Fixes ea93d37eb49d ("net/ena: add HW queues depth setup")
---
 drivers/net/ena/ena_ethdev.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/ena/ena_ethdev.c +3 -6
index 73e99e956a..c5d8e7d43e 100644
@@ -1294,9 +1294,6 @@ static int ena_tx_queue_setup(struct rte_eth_dev *dev,
 		return -EINVAL;
 	}
 
-	if (nb_desc == RTE_ETH_DEV_FALLBACK_TX_RINGSIZE)
-		nb_desc = adapter->max_tx_ring_size;
-
 	txq->port_id = dev->data->port_id;
 	txq->next_to_clean = 0;
 	txq->next_to_use = 0;
@@ -1368,9 +1365,6 @@ static int ena_rx_queue_setup(struct rte_eth_dev *dev,
 		return ENA_COM_FAULT;
 	}
 
-	if (nb_desc == RTE_ETH_DEV_FALLBACK_RX_RINGSIZE)
-		nb_desc = adapter->max_rx_ring_size;
-
 	if (!rte_is_power_of_2(nb_desc)) {
 		PMD_DRV_LOG(ERR,
 			"Unsupported size of RX queue: %d is not a power of 2.\n",
@@ -2130,6 +2124,9 @@ static int ena_infos_get(struct rte_eth_dev *dev,
 	dev_info->tx_desc_lim.nb_mtu_seg_max = RTE_MIN(ENA_PKT_MAX_BUFS,
 					adapter->max_tx_sgl_size);
 
+	dev_info->default_rxportconf.ring_size = ENA_DEFAULT_RING_SIZE;
+	dev_info->default_txportconf.ring_size = ENA_DEFAULT_RING_SIZE;
+
 	return 0;
 }
 
Signature · 1 line
2.25.1
#45 lore raw

PATCH v2 22/22 net/ena: update version to v2.3.0

In reply to Michal Krawczyk

This version update contains:
* memcpy mapping to the dpdk-optimized version.
* ena_com (HAL) update to the latest version.
* Bug fixes for the the large LLQ headers and devargs parsing.
* Mbuf RSS hash presence indication.
* Bug fix for the default ring size.
* Various fixes for SMP mode (although ENA is not fully MP aware, yet).

---
 doc/guides/rel_notes/release_21_05.rst | 13 +++++++++++++
 drivers/net/ena/ena_ethdev.c           |  4 ++--
 2 files changed, 15 insertions(+), 2 deletions(-)
doc/guides/rel_notes/release_21_05.rst +13 -0
index 00a55503f0..cf12dafbc4 100644
@@ -280,6 +280,19 @@ New Features
   * Added support for crypto adapter forward mode in octeontx2 event and crypto
     device driver.
 
+* **Updated Amazon ENA PMD.**
+
+  The new driver version (v2.3.0) introduces bug fixes and improvements,
+  including:
+
+  * Changed memcpy mapping to the dpdk-optimized version.
+  * Updated ena_com (HAL) to the latest version.
+  * Fixed bugs when requesting large LLQ headers using the devargs.
+  * Added indication of the RSS hash presence in the mbuf.
+  * Fixed bug when the default ring size was set.
+  * Add multiple fixes for the SMP mode (although ENA is not fully MP aware,
+    yet).
+
 
 Removed Items
 -------------
drivers/net/ena/ena_ethdev.c +2 -2
index c5d8e7d43e..e1e086f31e 100644
@@ -27,8 +27,8 @@
 #include <ena_eth_io_defs.h>
 
 #define DRV_MODULE_VER_MAJOR	2
-#define DRV_MODULE_VER_MINOR	2
-#define DRV_MODULE_VER_SUBMINOR	1
+#define DRV_MODULE_VER_MINOR	3
+#define DRV_MODULE_VER_SUBMINOR	0
 
 #define ENA_IO_TXQ_IDX(q)	(2 * (q))
 #define ENA_IO_RXQ_IDX(q)	(2 * (q) + 1)
Signature · 1 line
2.25.1
#46 lore raw

v3 cover net/ena: update ENA PMD to v2.3.0

In reply to Michal Krawczyk

Hi,

this version updates the driver to version 2.3.0, which fixes multiple bugs, contains part of the work on making the ENA PMD fully MP aware, and also updates HAL to the latest version.

More detailed list of changes:
* memcpy mapping to the dpdk-optimized version.
* ena_com (HAL) update to the latest version.
* Bug fixes for the large LLQ headers and devargs parsing.
* Mbuf RSS hash presence indication.
* Bug fix for the default ring size.
* Various fixes for the SMP mode.

v3:
* Fix build of the PMD with the debug flags enabled.
* Fix typo in the commit log of the version upgrade patch.

v2:
* Fix nested declaration of the rte_memcpy on arm64 architecture.

Amit Bernstein (1):
net/ena/base: adjust changes to lastest ena-com

Igor Chauskin (2):
net/ena: switch memcpy to dpdk-optimized version net/ena: fix parsing of large_llq_hdr argument

Michal Krawczyk (12):
net/ena/base: unify arg names for the functions net/ena/base: add dev arg to the logging macros net/ena/base: typos, style and comments improvements net/ena/base: fix issues from the static code scan net/ena/base: destroy multiple "wait events" net/ena/base: remove indir table from ENA feat ctx net/ena/base: remove mutable RSS from the host info net/ena/base: update generation date and commit net/ena/base: use rte_prefetch0_write net/ena: terminate devargs allowed keys with NULL net/ena: indicate Rx RSS hash presence net/ena: update version to v2.3.0

Stanislaw Kardach (7):
net/ena: remove endian swap functions net/ena: handle spurious wakeups in ENA_WAIT_EVENT net/ena: support SMP for mz alloc counter net/ena: move default RSS key to shared mem net/ena: make ethdev references smp safe net/ena: disable dev_ops not supported in SMP net/ena: report default ring size

 doc/guides/rel_notes/release_21_05.rst        |  13 +
 drivers/net/ena/base/ena_com.c                | 379 +++++++++---------
 drivers/net/ena/base/ena_com.h                |  24 +-
 .../net/ena/base/ena_defs/ena_admin_defs.h    |  98 ++---
 drivers/net/ena/base/ena_defs/ena_gen_info.h  |   4 +-
 drivers/net/ena/base/ena_eth_com.c            |  94 +++--
 drivers/net/ena/base/ena_eth_com.h            |  17 +-
 drivers/net/ena/base/ena_plat_dpdk.h          | 324 ++++++++-------
 drivers/net/ena/ena_ethdev.c                  | 156 ++++---
 drivers/net/ena/ena_ethdev.h                  |  14 +-
 drivers/net/ena/ena_platform.h                |  12 -
 11 files changed, 636 insertions(+), 499 deletions(-)
Signature · 1 line
2.25.1
#47 lore raw

PATCH v3 1/22 net/ena: switch memcpy to dpdk-optimized version

From: Igor Chauskin <[email protected]>

memcpy is now mapped to rte_memcpy macro on x86 architectures.

Fixes 9ba7981ec992 ("ena: add communication layer for DPDK")

---
v2:
* Fix nested declaration of the rte_memcpy on arm64 architecture.

 drivers/net/ena/base/ena_plat_dpdk.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ena/base/ena_plat_dpdk.h +6 -1
index a1d749f83f..ae68f860a5 100644
@@ -25,6 +25,7 @@
 #include <rte_spinlock.h>
 
 #include <sys/time.h>
+#include <rte_memcpy.h>
 
 typedef uint64_t u64;
 typedef uint32_t u32;
@@ -62,7 +63,11 @@ typedef uint64_t dma_addr_t;
 #define ENA_UDELAY(x) rte_delay_us_block(x)
 
 #define ENA_TOUCH(x) ((void)(x))
-#define memcpy_toio memcpy
+/* Avoid nested declaration on arm64, as it may define rte_memcpy as memcpy. */
+#if defined(RTE_ARCH_X86)
+#undef memcpy
+#define memcpy rte_memcpy
+#endif
 #define wmb rte_wmb
 #define rmb rte_rmb
 #define mb rte_mb
Signature · 1 line
2.25.1
#48 lore raw

PATCH v3 2/22 net/ena/base: unify arg names for the functions

In reply to Michal Krawczyk

Instead of using 'queue' for struct ena_com_admin_queue and 'dev' for struct ena_com_dev variables, use more descriptive 'admin_queue' and 'ena_dev'.

This also unifies the names of variables of the type struct ena_com_dev in the driver.

---
v3:
* Fix typo in the commit log of the version upgrade patch.

 drivers/net/ena/base/ena_com.c | 74 +++++++++++++++++-----------------
 drivers/net/ena/base/ena_com.h |  2 +-
 2 files changed, 38 insertions(+), 38 deletions(-)
drivers/net/ena/base/ena_com.c +37 -37
index aae68721fb..f7258254a5 100644
@@ -80,12 +80,12 @@ static int ena_com_mem_addr_set(struct ena_com_dev *ena_dev,
 	return 0;
 }
 
-static int ena_com_admin_init_sq(struct ena_com_admin_queue *queue)
+static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue)
 {
-	struct ena_com_admin_sq *sq = &queue->sq;
-	u16 size = ADMIN_SQ_SIZE(queue->q_depth);
+	struct ena_com_admin_sq *sq = &admin_queue->sq;
+	u16 size = ADMIN_SQ_SIZE(admin_queue->q_depth);
 
-	ENA_MEM_ALLOC_COHERENT(queue->q_dmadev, size, sq->entries, sq->dma_addr,
+	ENA_MEM_ALLOC_COHERENT(admin_queue->q_dmadev, size, sq->entries, sq->dma_addr,
 			       sq->mem_handle);
 
 	if (!sq->entries) {
@@ -102,12 +102,12 @@ static int ena_com_admin_init_sq(struct ena_com_admin_queue *queue)
 	return 0;
 }
 
-static int ena_com_admin_init_cq(struct ena_com_admin_queue *queue)
+static int ena_com_admin_init_cq(struct ena_com_admin_queue *admin_queue)
 {
-	struct ena_com_admin_cq *cq = &queue->cq;
-	u16 size = ADMIN_CQ_SIZE(queue->q_depth);
+	struct ena_com_admin_cq *cq = &admin_queue->cq;
+	u16 size = ADMIN_CQ_SIZE(admin_queue->q_depth);
 
-	ENA_MEM_ALLOC_COHERENT(queue->q_dmadev, size, cq->entries, cq->dma_addr,
+	ENA_MEM_ALLOC_COHERENT(admin_queue->q_dmadev, size, cq->entries, cq->dma_addr,
 			       cq->mem_handle);
 
 	if (!cq->entries)  {
@@ -121,16 +121,16 @@ static int ena_com_admin_init_cq(struct ena_com_admin_queue *queue)
 	return 0;
 }
 
-static int ena_com_admin_init_aenq(struct ena_com_dev *dev,
+static int ena_com_admin_init_aenq(struct ena_com_dev *ena_dev,
 				   struct ena_aenq_handlers *aenq_handlers)
 {
-	struct ena_com_aenq *aenq = &dev->aenq;
+	struct ena_com_aenq *aenq = &ena_dev->aenq;
 	u32 addr_low, addr_high, aenq_caps;
 	u16 size;
 
-	dev->aenq.q_depth = ENA_ASYNC_QUEUE_DEPTH;
+	ena_dev->aenq.q_depth = ENA_ASYNC_QUEUE_DEPTH;
 	size = ADMIN_AENQ_SIZE(ENA_ASYNC_QUEUE_DEPTH);
-	ENA_MEM_ALLOC_COHERENT(dev->dmadev, size,
+	ENA_MEM_ALLOC_COHERENT(ena_dev->dmadev, size,
 			aenq->entries,
 			aenq->dma_addr,
 			aenq->mem_handle);
@@ -146,15 +146,15 @@ static int ena_com_admin_init_aenq(struct ena_com_dev *dev,
 	addr_low = ENA_DMA_ADDR_TO_UINT32_LOW(aenq->dma_addr);
 	addr_high = ENA_DMA_ADDR_TO_UINT32_HIGH(aenq->dma_addr);
 
-	ENA_REG_WRITE32(dev->bus, addr_low, dev->reg_bar + ENA_REGS_AENQ_BASE_LO_OFF);
-	ENA_REG_WRITE32(dev->bus, addr_high, dev->reg_bar + ENA_REGS_AENQ_BASE_HI_OFF);
+	ENA_REG_WRITE32(ena_dev->bus, addr_low, ena_dev->reg_bar + ENA_REGS_AENQ_BASE_LO_OFF);
+	ENA_REG_WRITE32(ena_dev->bus, addr_high, ena_dev->reg_bar + ENA_REGS_AENQ_BASE_HI_OFF);
 
 	aenq_caps = 0;
-	aenq_caps |= dev->aenq.q_depth & ENA_REGS_AENQ_CAPS_AENQ_DEPTH_MASK;
+	aenq_caps |= ena_dev->aenq.q_depth & ENA_REGS_AENQ_CAPS_AENQ_DEPTH_MASK;
 	aenq_caps |= (sizeof(struct ena_admin_aenq_entry) <<
 		ENA_REGS_AENQ_CAPS_AENQ_ENTRY_SIZE_SHIFT) &
 		ENA_REGS_AENQ_CAPS_AENQ_ENTRY_SIZE_MASK;
-	ENA_REG_WRITE32(dev->bus, aenq_caps, dev->reg_bar + ENA_REGS_AENQ_CAPS_OFF);
+	ENA_REG_WRITE32(ena_dev->bus, aenq_caps, ena_dev->reg_bar + ENA_REGS_AENQ_CAPS_OFF);
 
 	if (unlikely(!aenq_handlers)) {
 		ena_trc_err("aenq handlers pointer is NULL\n");
@@ -173,31 +173,31 @@ static void comp_ctxt_release(struct ena_com_admin_queue *queue,
 	ATOMIC32_DEC(&queue->outstanding_cmds);
 }
 
-static struct ena_comp_ctx *get_comp_ctxt(struct ena_com_admin_queue *queue,
+static struct ena_comp_ctx *get_comp_ctxt(struct ena_com_admin_queue *admin_queue,
 					  u16 command_id, bool capture)
 {
-	if (unlikely(command_id >= queue->q_depth)) {
+	if (unlikely(command_id >= admin_queue->q_depth)) {
 		ena_trc_err("command id is larger than the queue size. cmd_id: %u queue size %d\n",
-			    command_id, queue->q_depth);
+			    command_id, admin_queue->q_depth);
 		return NULL;
 	}
 
-	if (unlikely(!queue->comp_ctx)) {
+	if (unlikely(!admin_queue->comp_ctx)) {
 		ena_trc_err("Completion context is NULL\n");
 		return NULL;
 	}
 
-	if (unlikely(queue->comp_ctx[command_id].occupied && capture)) {
+	if (unlikely(admin_queue->comp_ctx[command_id].occupied && capture)) {
 		ena_trc_err("Completion context is occupied\n");
 		return NULL;
 	}
 
 	if (capture) {
-		ATOMIC32_INC(&queue->outstanding_cmds);
-		queue->comp_ctx[command_id].occupied = true;
+		ATOMIC32_INC(&admin_queue->outstanding_cmds);
+		admin_queue->comp_ctx[command_id].occupied = true;
 	}
 
-	return &queue->comp_ctx[command_id];
+	return &admin_queue->comp_ctx[command_id];
 }
 
 static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queue *admin_queue,
@@ -260,20 +260,20 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queu
 	return comp_ctx;
 }
 
-static int ena_com_init_comp_ctxt(struct ena_com_admin_queue *queue)
+static int ena_com_init_comp_ctxt(struct ena_com_admin_queue *admin_queue)
 {
-	size_t size = queue->q_depth * sizeof(struct ena_comp_ctx);
+	size_t size = admin_queue->q_depth * sizeof(struct ena_comp_ctx);
 	struct ena_comp_ctx *comp_ctx;
 	u16 i;
 
-	queue->comp_ctx = ENA_MEM_ALLOC(queue->q_dmadev, size);
-	if (unlikely(!queue->comp_ctx)) {
+	admin_queue->comp_ctx = ENA_MEM_ALLOC(admin_queue->q_dmadev, size);
+	if (unlikely(!admin_queue->comp_ctx)) {
 		ena_trc_err("memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
-	for (i = 0; i < queue->q_depth; i++) {
-		comp_ctx = get_comp_ctxt(queue, i, false);
+	for (i = 0; i < admin_queue->q_depth; i++) {
+		comp_ctx = get_comp_ctxt(admin_queue, i, false);
 		if (comp_ctx)
 			ENA_WAIT_EVENT_INIT(comp_ctx->wait_event);
 	}
@@ -2049,10 +2049,10 @@ void ena_com_admin_q_comp_intr_handler(struct ena_com_dev *ena_dev)
 /* ena_handle_specific_aenq_event:
  * return the handler that is relevant to the specific event group
  */
-static ena_aenq_handler ena_com_get_specific_aenq_cb(struct ena_com_dev *dev,
+static ena_aenq_handler ena_com_get_specific_aenq_cb(struct ena_com_dev *ena_dev,
 						     u16 group)
 {
-	struct ena_aenq_handlers *aenq_handlers = dev->aenq.aenq_handlers;
+	struct ena_aenq_handlers *aenq_handlers = ena_dev->aenq.aenq_handlers;
 
 	if ((group < ENA_MAX_HANDLERS) && aenq_handlers->handlers[group])
 		return aenq_handlers->handlers[group];
@@ -2064,11 +2064,11 @@ static ena_aenq_handler ena_com_get_specific_aenq_cb(struct ena_com_dev *dev,
  * handles the aenq incoming events.
  * pop events from the queue and apply the specific handler
  */
-void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data)
+void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data)
 {
 	struct ena_admin_aenq_entry *aenq_e;
 	struct ena_admin_aenq_common_desc *aenq_common;
-	struct ena_com_aenq *aenq  = &dev->aenq;
+	struct ena_com_aenq *aenq  = &ena_dev->aenq;
 	u64 timestamp;
 	ena_aenq_handler handler_cb;
 	u16 masked_head, processed = 0;
@@ -2096,7 +2096,7 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data)
 			    timestamp);
 
 		/* Handle specific event*/
-		handler_cb = ena_com_get_specific_aenq_cb(dev,
+		handler_cb = ena_com_get_specific_aenq_cb(ena_dev,
 							  aenq_common->group);
 		handler_cb(data, aenq_e); /* call the actual event handler*/
 
@@ -2121,8 +2121,8 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data)
 
 	/* write the aenq doorbell after all AENQ descriptors were read */
 	mb();
-	ENA_REG_WRITE32_RELAXED(dev->bus, (u32)aenq->head,
-				dev->reg_bar + ENA_REGS_AENQ_HEAD_DB_OFF);
+	ENA_REG_WRITE32_RELAXED(ena_dev->bus, (u32)aenq->head,
+				ena_dev->reg_bar + ENA_REGS_AENQ_HEAD_DB_OFF);
 	mmiowb();
 }
 
drivers/net/ena/base/ena_com.h +1 -1
index 64d8f247cb..e9601b1a8e 100644
@@ -522,7 +522,7 @@ void ena_com_admin_q_comp_intr_handler(struct ena_com_dev *ena_dev);
  * This method goes over the async event notification queue and calls the proper
  * aenq handler.
  */
-void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data);
+void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data);
 
 /* ena_com_abort_admin_commands - Abort all the outstanding admin commands.
  * @ena_dev: ENA communication layer struct
Signature · 1 line
2.25.1
#49 lore raw

PATCH v3 3/22 net/ena/base: add dev arg to the logging macros

In reply to Michal Krawczyk

Some platforms may make use of the device argument to make the logs more verbose and specific for the appropriate device.

As it's not used by the ENA DPDK PMD for the logging, the type is just defined, but never used.

It may be reconsidered to change this in the future by adding port ID to the message logs, but as for now the logging behavior won't change.

---
 drivers/net/ena/base/ena_com.c       | 238 ++++++++++++++-------------
 drivers/net/ena/base/ena_com.h       |  21 +++
 drivers/net/ena/base/ena_eth_com.c   |  78 ++++++---
 drivers/net/ena/base/ena_eth_com.h   |  17 +-
 drivers/net/ena/base/ena_plat_dpdk.h |  44 ++---
 5 files changed, 236 insertions(+), 162 deletions(-)
drivers/net/ena/base/ena_com.c +128 -110
index f7258254a5..9931819bbb 100644
@@ -70,7 +70,7 @@ static int ena_com_mem_addr_set(struct ena_com_dev *ena_dev,
 				       dma_addr_t addr)
 {
 	if ((addr & GENMASK_ULL(ena_dev->dma_addr_bits - 1, 0)) != addr) {
-		ena_trc_err("dma address has more bits that the device supports\n");
+		ena_trc_err(ena_dev, "DMA address has more bits than the device supports\n");
 		return ENA_COM_INVAL;
 	}
 
@@ -82,6 +82,7 @@ static int ena_com_mem_addr_set(struct ena_com_dev *ena_dev,
 
 static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue)
 {
+	struct ena_com_dev *ena_dev = admin_queue->ena_dev;
 	struct ena_com_admin_sq *sq = &admin_queue->sq;
 	u16 size = ADMIN_SQ_SIZE(admin_queue->q_depth);
 
@@ -89,7 +90,7 @@ static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue)
 			       sq->mem_handle);
 
 	if (!sq->entries) {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -104,6 +105,7 @@ static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue)
 
 static int ena_com_admin_init_cq(struct ena_com_admin_queue *admin_queue)
 {
+	struct ena_com_dev *ena_dev = admin_queue->ena_dev;
 	struct ena_com_admin_cq *cq = &admin_queue->cq;
 	u16 size = ADMIN_CQ_SIZE(admin_queue->q_depth);
 
@@ -111,7 +113,7 @@ static int ena_com_admin_init_cq(struct ena_com_admin_queue *admin_queue)
 			       cq->mem_handle);
 
 	if (!cq->entries)  {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -136,7 +138,7 @@ static int ena_com_admin_init_aenq(struct ena_com_dev *ena_dev,
 			aenq->mem_handle);
 
 	if (!aenq->entries) {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -157,7 +159,7 @@ static int ena_com_admin_init_aenq(struct ena_com_dev *ena_dev,
 	ENA_REG_WRITE32(ena_dev->bus, aenq_caps, ena_dev->reg_bar + ENA_REGS_AENQ_CAPS_OFF);
 
 	if (unlikely(!aenq_handlers)) {
-		ena_trc_err("aenq handlers pointer is NULL\n");
+		ena_trc_err(ena_dev, "AENQ handlers pointer is NULL\n");
 		return ENA_COM_INVAL;
 	}
 
@@ -177,18 +179,21 @@ static struct ena_comp_ctx *get_comp_ctxt(struct ena_com_admin_queue *admin_queu
 					  u16 command_id, bool capture)
 {
 	if (unlikely(command_id >= admin_queue->q_depth)) {
-		ena_trc_err("command id is larger than the queue size. cmd_id: %u queue size %d\n",
+		ena_trc_err(admin_queue->ena_dev,
+			    "Command id is larger than the queue size. cmd_id: %u queue size %d\n",
 			    command_id, admin_queue->q_depth);
 		return NULL;
 	}
 
 	if (unlikely(!admin_queue->comp_ctx)) {
-		ena_trc_err("Completion context is NULL\n");
+		ena_trc_err(admin_queue->ena_dev,
+			    "Completion context is NULL\n");
 		return NULL;
 	}
 
 	if (unlikely(admin_queue->comp_ctx[command_id].occupied && capture)) {
-		ena_trc_err("Completion context is occupied\n");
+		ena_trc_err(admin_queue->ena_dev,
+			    "Completion context is occupied\n");
 		return NULL;
 	}
 
@@ -218,7 +223,7 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queu
 	/* In case of queue FULL */
 	cnt = (u16)ATOMIC32_READ(&admin_queue->outstanding_cmds);
 	if (cnt >= admin_queue->q_depth) {
-		ena_trc_dbg("admin queue is full.\n");
+		ena_trc_dbg(admin_queue->ena_dev, "Admin queue is full.\n");
 		admin_queue->stats.out_of_space++;
 		return ERR_PTR(ENA_COM_NO_SPACE);
 	}
@@ -262,13 +267,14 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queu
 
 static int ena_com_init_comp_ctxt(struct ena_com_admin_queue *admin_queue)
 {
+	struct ena_com_dev *ena_dev = admin_queue->ena_dev;
 	size_t size = admin_queue->q_depth * sizeof(struct ena_comp_ctx);
 	struct ena_comp_ctx *comp_ctx;
 	u16 i;
 
 	admin_queue->comp_ctx = ENA_MEM_ALLOC(admin_queue->q_dmadev, size);
 	if (unlikely(!admin_queue->comp_ctx)) {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -341,7 +347,7 @@ static int ena_com_init_io_sq(struct ena_com_dev *ena_dev,
 		}
 
 		if (!io_sq->desc_addr.virt_addr) {
-			ena_trc_err("memory allocation failed\n");
+			ena_trc_err(ena_dev, "Memory allocation failed\n");
 			return ENA_COM_NO_MEM;
 		}
 	}
@@ -366,7 +372,7 @@ static int ena_com_init_io_sq(struct ena_com_dev *ena_dev,
 			io_sq->bounce_buf_ctrl.base_buffer = ENA_MEM_ALLOC(ena_dev->dmadev, size);
 
 		if (!io_sq->bounce_buf_ctrl.base_buffer) {
-			ena_trc_err("bounce buffer memory allocation failed\n");
+			ena_trc_err(ena_dev, "Bounce buffer memory allocation failed\n");
 			return ENA_COM_NO_MEM;
 		}
 
@@ -431,7 +437,7 @@ static int ena_com_init_io_cq(struct ena_com_dev *ena_dev,
 	}
 
 	if (!io_cq->cdesc_addr.virt_addr) {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -452,7 +458,8 @@ static void ena_com_handle_single_admin_completion(struct ena_com_admin_queue *a
 
 	comp_ctx = get_comp_ctxt(admin_queue, cmd_id, false);
 	if (unlikely(!comp_ctx)) {
-		ena_trc_err("comp_ctx is NULL. Changing the admin queue running state\n");
+		ena_trc_err(admin_queue->ena_dev,
+			    "comp_ctx is NULL. Changing the admin queue running state\n");
 		admin_queue->running_state = false;
 		return;
 	}
@@ -504,10 +511,12 @@ static void ena_com_handle_admin_completion(struct ena_com_admin_queue *admin_qu
 	admin_queue->stats.completed_cmd += comp_num;
 }
 
-static int ena_com_comp_status_to_errno(u8 comp_status)
+static int ena_com_comp_status_to_errno(struct ena_com_admin_queue *admin_queue,
+					u8 comp_status)
 {
 	if (unlikely(comp_status != 0))
-		ena_trc_err("admin command failed[%u]\n", comp_status);
+		ena_trc_err(admin_queue->ena_dev,
+			    "Admin command failed[%u]\n", comp_status);
 
 	switch (comp_status) {
 	case ENA_ADMIN_SUCCESS:
@@ -554,7 +563,8 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
 			break;
 
 		if (ENA_TIME_EXPIRE(timeout)) {
-			ena_trc_err("Wait for completion (polling) timeout\n");
+			ena_trc_err(admin_queue->ena_dev,
+				    "Wait for completion (polling) timeout\n");
 			/* ENA didn't have any completion */
 			ENA_SPINLOCK_LOCK(admin_queue->q_lock, flags);
 			admin_queue->stats.no_completion++;
@@ -570,7 +580,7 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
 	}
 
 	if (unlikely(comp_ctx->status == ENA_CMD_ABORTED)) {
-		ena_trc_err("Command was aborted\n");
+		ena_trc_err(admin_queue->ena_dev, "Command was aborted\n");
 		ENA_SPINLOCK_LOCK(admin_queue->q_lock, flags);
 		admin_queue->stats.aborted_cmd++;
 		ENA_SPINLOCK_UNLOCK(admin_queue->q_lock, flags);
@@ -579,9 +589,10 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
 	}
 
 	ENA_WARN(comp_ctx->status != ENA_CMD_COMPLETED,
-		 "Invalid comp status %d\n", comp_ctx->status);
+		 admin_queue->ena_dev, "Invalid comp status %d\n",
+		 comp_ctx->status);
 
-	ret = ena_com_comp_status_to_errno(comp_ctx->comp_status);
+	ret = ena_com_comp_status_to_errno(admin_queue, comp_ctx->comp_status);
 err:
 	comp_ctxt_release(admin_queue, comp_ctx);
 	return ret;
@@ -623,7 +634,7 @@ static int ena_com_set_llq(struct ena_com_dev *ena_dev)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to set LLQ configurations: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to set LLQ configurations: %d\n", ret);
 
 	return ret;
 }
@@ -645,7 +656,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 		llq_info->header_location_ctrl =
 			llq_default_cfg->llq_header_location;
 	} else {
-		ena_trc_err("Invalid header location control, supported: 0x%x\n",
+		ena_trc_err(ena_dev, "Invalid header location control, supported: 0x%x\n",
 			    supported_feat);
 		return -EINVAL;
 	}
@@ -660,12 +671,12 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 			} else if (supported_feat & ENA_ADMIN_SINGLE_DESC_PER_ENTRY) {
 				llq_info->desc_stride_ctrl = ENA_ADMIN_SINGLE_DESC_PER_ENTRY;
 			} else {
-				ena_trc_err("Invalid desc_stride_ctrl, supported: 0x%x\n",
+				ena_trc_err(ena_dev, "Invalid desc_stride_ctrl, supported: 0x%x\n",
 					    supported_feat);
 				return -EINVAL;
 			}
 
-			ena_trc_err("Default llq stride ctrl is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
+			ena_trc_err(ena_dev, "Default llq stride ctrl is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
 				    llq_default_cfg->llq_stride_ctrl,
 				    supported_feat,
 				    llq_info->desc_stride_ctrl);
@@ -689,11 +700,12 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 			llq_info->desc_list_entry_size_ctrl = ENA_ADMIN_LIST_ENTRY_SIZE_256B;
 			llq_info->desc_list_entry_size = 256;
 		} else {
-			ena_trc_err("Invalid entry_size_ctrl, supported: 0x%x\n", supported_feat);
+			ena_trc_err(ena_dev, "Invalid entry_size_ctrl, supported: 0x%x\n",
+				    supported_feat);
 			return -EINVAL;
 		}
 
-		ena_trc_err("Default llq ring entry size is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
+		ena_trc_err(ena_dev, "Default llq ring entry size is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
 			    llq_default_cfg->llq_ring_entry_size,
 			    supported_feat,
 			    llq_info->desc_list_entry_size);
@@ -702,7 +714,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 		/* The desc list entry size should be whole multiply of 8
 		 * This requirement comes from __iowrite64_copy()
 		 */
-		ena_trc_err("illegal entry size %d\n",
+		ena_trc_err(ena_dev, "Illegal entry size %d\n",
 			    llq_info->desc_list_entry_size);
 		return -EINVAL;
 	}
@@ -726,12 +738,12 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 		} else if (supported_feat & ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_8) {
 			llq_info->descs_num_before_header = ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_8;
 		} else {
-			ena_trc_err("Invalid descs_num_before_header, supported: 0x%x\n",
+			ena_trc_err(ena_dev, "Invalid descs_num_before_header, supported: 0x%x\n",
 				    supported_feat);
 			return -EINVAL;
 		}
 
-		ena_trc_err("Default llq num descs before header is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
+		ena_trc_err(ena_dev, "Default llq num descs before header is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
 			    llq_default_cfg->llq_num_decs_before_header,
 			    supported_feat,
 			    llq_info->descs_num_before_header);
@@ -750,7 +762,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 
 	rc = ena_com_set_llq(ena_dev);
 	if (rc)
-		ena_trc_err("Cannot set LLQ configuration: %d\n", rc);
+		ena_trc_err(ena_dev, "Cannot set LLQ configuration: %d\n", rc);
 
 	return rc;
 }
@@ -776,13 +788,15 @@ static int ena_com_wait_and_process_admin_cq_interrupts(struct ena_comp_ctx *com
 		ENA_SPINLOCK_UNLOCK(admin_queue->q_lock, flags);
 
 		if (comp_ctx->status == ENA_CMD_COMPLETED) {
-			ena_trc_err("The ena device sent a completion but the driver didn't receive a MSI-X interrupt (cmd %d), autopolling mode is %s\n",
+			ena_trc_err(admin_queue->ena_dev,
+				    "The ena device sent a completion but the driver didn't receive a MSI-X interrupt (cmd %d), autopolling mode is %s\n",
 				    comp_ctx->cmd_opcode, admin_queue->auto_polling ? "ON" : "OFF");
 			/* Check if fallback to polling is enabled */
 			if (admin_queue->auto_polling)
 				admin_queue->polling = true;
 		} else {
-			ena_trc_err("The ena device didn't send a completion for the admin cmd %d status %d\n",
+			ena_trc_err(admin_queue->ena_dev,
+				    "The ena device didn't send a completion for the admin cmd %d status %d\n",
 				    comp_ctx->cmd_opcode, comp_ctx->status);
 		}
 		/* Check if shifted to polling mode.
@@ -796,7 +810,7 @@ static int ena_com_wait_and_process_admin_cq_interrupts(struct ena_comp_ctx *com
 		}
 	}
 
-	ret = ena_com_comp_status_to_errno(comp_ctx->comp_status);
+	ret = ena_com_comp_status_to_errno(admin_queue, comp_ctx->comp_status);
 err:
 	comp_ctxt_release(admin_queue, comp_ctx);
 	return ret;
@@ -844,7 +858,7 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev *ena_dev, u16 offset)
 	}
 
 	if (unlikely(i == timeout)) {
-		ena_trc_err("reading reg failed for timeout. expected: req id[%hu] offset[%hu] actual: req id[%hu] offset[%hu]\n",
+		ena_trc_err(ena_dev, "Reading reg failed for timeout. expected: req id[%hu] offset[%hu] actual: req id[%hu] offset[%hu]\n",
 			    mmio_read->seq_num,
 			    offset,
 			    read_resp->req_id,
@@ -854,7 +868,7 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev *ena_dev, u16 offset)
 	}
 
 	if (read_resp->reg_off != offset) {
-		ena_trc_err("Read failure: wrong offset provided\n");
+		ena_trc_err(ena_dev, "Read failure: wrong offset provided\n");
 		ret = ENA_MMIO_READ_TIMEOUT;
 	} else {
 		ret = read_resp->reg_val;
@@ -913,7 +927,7 @@ static int ena_com_destroy_io_sq(struct ena_com_dev *ena_dev,
 					    sizeof(destroy_resp));
 
 	if (unlikely(ret && (ret != ENA_COM_NO_DEVICE)))
-		ena_trc_err("failed to destroy io sq error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to destroy io sq error: %d\n", ret);
 
 	return ret;
 }
@@ -969,7 +983,7 @@ static int wait_for_reset_state(struct ena_com_dev *ena_dev, u32 timeout,
 		val = ena_com_reg_bar_read32(ena_dev, ENA_REGS_DEV_STS_OFF);
 
 		if (unlikely(val == ENA_MMIO_READ_TIMEOUT)) {
-			ena_trc_err("Reg read timeout occurred\n");
+			ena_trc_err(ena_dev, "Reg read timeout occurred\n");
 			return ENA_COM_TIMER_EXPIRED;
 		}
 
@@ -1009,7 +1023,7 @@ static int ena_com_get_feature_ex(struct ena_com_dev *ena_dev,
 	int ret;
 
 	if (!ena_com_check_supported_feature_id(ena_dev, feature_id)) {
-		ena_trc_dbg("Feature %d isn't supported\n", feature_id);
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n", feature_id);
 		return ENA_COM_UNSUPPORTED;
 	}
 
@@ -1028,7 +1042,7 @@ static int ena_com_get_feature_ex(struct ena_com_dev *ena_dev,
 				   &get_cmd.control_buffer.address,
 				   control_buf_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -1045,7 +1059,7 @@ static int ena_com_get_feature_ex(struct ena_com_dev *ena_dev,
 					    sizeof(*get_resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to submit get_feature command %d error: %d\n",
+		ena_trc_err(ena_dev, "Failed to submit get_feature command %d error: %d\n",
 			    feature_id, ret);
 
 	return ret;
@@ -1157,7 +1171,7 @@ static int ena_com_indirect_table_allocate(struct ena_com_dev *ena_dev,
 
 	if ((get_resp.u.ind_table.min_size > log_size) ||
 	    (get_resp.u.ind_table.max_size < log_size)) {
-		ena_trc_err("indirect table size doesn't fit. requested size: %d while min is:%d and max %d\n",
+		ena_trc_err(ena_dev, "Indirect table size doesn't fit. requested size: %d while min is:%d and max %d\n",
 			    1 << log_size,
 			    1 << get_resp.u.ind_table.min_size,
 			    1 << get_resp.u.ind_table.max_size);
@@ -1261,7 +1275,7 @@ static int ena_com_create_io_sq(struct ena_com_dev *ena_dev,
 					   &create_cmd.sq_ba,
 					   io_sq->desc_addr.phys_addr);
 		if (unlikely(ret)) {
-			ena_trc_err("memory address set failed\n");
+			ena_trc_err(ena_dev, "Memory address set failed\n");
 			return ret;
 		}
 	}
@@ -1272,7 +1286,7 @@ static int ena_com_create_io_sq(struct ena_com_dev *ena_dev,
 					    (struct ena_admin_acq_entry *)&cmd_completion,
 					    sizeof(cmd_completion));
 	if (unlikely(ret)) {
-		ena_trc_err("Failed to create IO SQ. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to create IO SQ. error: %d\n", ret);
 		return ret;
 	}
 
@@ -1290,7 +1304,7 @@ static int ena_com_create_io_sq(struct ena_com_dev *ena_dev,
 			cmd_completion.llq_descriptors_offset);
 	}
 
-	ena_trc_dbg("created sq[%u], depth[%u]\n", io_sq->idx, io_sq->q_depth);
+	ena_trc_dbg(ena_dev, "Created sq[%u], depth[%u]\n", io_sq->idx, io_sq->q_depth);
 
 	return ret;
 }
@@ -1324,7 +1338,7 @@ static void ena_com_update_intr_delay_resolution(struct ena_com_dev *ena_dev,
 	u16 prev_intr_delay_resolution = ena_dev->intr_delay_resolution;
 
 	if (unlikely(!intr_delay_resolution)) {
-		ena_trc_err("Illegal intr_delay_resolution provided. Going to use default 1 usec resolution\n");
+		ena_trc_err(ena_dev, "Illegal intr_delay_resolution provided. Going to use default 1 usec resolution\n");
 		intr_delay_resolution = ENA_DEFAULT_INTR_DELAY_RESOLUTION;
 	}
 
@@ -1360,10 +1374,12 @@ int ena_com_execute_admin_command(struct ena_com_admin_queue *admin_queue,
 					    comp, comp_size);
 	if (IS_ERR(comp_ctx)) {
 		if (comp_ctx == ERR_PTR(ENA_COM_NO_DEVICE))
-			ena_trc_dbg("Failed to submit command [%ld]\n",
+			ena_trc_dbg(admin_queue->ena_dev,
+				    "Failed to submit command [%ld]\n",
 				    PTR_ERR(comp_ctx));
 		else
-			ena_trc_err("Failed to submit command [%ld]\n",
+			ena_trc_err(admin_queue->ena_dev,
+				    "Failed to submit command [%ld]\n",
 				    PTR_ERR(comp_ctx));
 
 		return PTR_ERR(comp_ctx);
@@ -1372,11 +1388,11 @@ int ena_com_execute_admin_command(struct ena_com_admin_queue *admin_queue,
 	ret = ena_com_wait_and_process_admin_cq(comp_ctx, admin_queue);
 	if (unlikely(ret)) {
 		if (admin_queue->running_state)
-			ena_trc_err("Failed to process command. ret = %d\n",
-				    ret);
+			ena_trc_err(admin_queue->ena_dev,
+				    "Failed to process command. ret = %d\n", ret);
 		else
-			ena_trc_dbg("Failed to process command. ret = %d\n",
-				    ret);
+			ena_trc_dbg(admin_queue->ena_dev,
+				    "Failed to process command. ret = %d\n", ret);
 	}
 	return ret;
 }
@@ -1405,7 +1421,7 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev,
 				   &create_cmd.cq_ba,
 				   io_cq->cdesc_addr.phys_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -1415,7 +1431,7 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev,
 					    (struct ena_admin_acq_entry *)&cmd_completion,
 					    sizeof(cmd_completion));
 	if (unlikely(ret)) {
-		ena_trc_err("Failed to create IO CQ. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to create IO CQ. error: %d\n", ret);
 		return ret;
 	}
 
@@ -1434,7 +1450,7 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev,
 			(u32 __iomem *)((uintptr_t)ena_dev->reg_bar +
 			cmd_completion.numa_node_register_offset);
 
-	ena_trc_dbg("created cq[%u], depth[%u]\n", io_cq->idx, io_cq->q_depth);
+	ena_trc_dbg(ena_dev, "Created cq[%u], depth[%u]\n", io_cq->idx, io_cq->q_depth);
 
 	return ret;
 }
@@ -1444,7 +1460,7 @@ int ena_com_get_io_handlers(struct ena_com_dev *ena_dev, u16 qid,
 			    struct ena_com_io_cq **io_cq)
 {
 	if (qid >= ENA_TOTAL_NUM_QUEUES) {
-		ena_trc_err("Invalid queue number %d but the max is %d\n",
+		ena_trc_err(ena_dev, "Invalid queue number %d but the max is %d\n",
 			    qid, ENA_TOTAL_NUM_QUEUES);
 		return ENA_COM_INVAL;
 	}
@@ -1510,7 +1526,7 @@ int ena_com_destroy_io_cq(struct ena_com_dev *ena_dev,
 					    sizeof(destroy_resp));
 
 	if (unlikely(ret && (ret != ENA_COM_NO_DEVICE)))
-		ena_trc_err("Failed to destroy IO CQ. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to destroy IO CQ. error: %d\n", ret);
 
 	return ret;
 }
@@ -1534,7 +1550,7 @@ void ena_com_admin_aenq_enable(struct ena_com_dev *ena_dev)
 {
 	u16 depth = ena_dev->aenq.q_depth;
 
-	ENA_WARN(ena_dev->aenq.head != depth, "Invalid AENQ state\n");
+	ENA_WARN(ena_dev->aenq.head != depth, ena_dev, "Invalid AENQ state\n");
 
 	/* Init head_db to mark that all entries in the queue
 	 * are initially available
@@ -1552,12 +1568,12 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_dev, u32 groups_flag)
 
 	ret = ena_com_get_feature(ena_dev, &get_resp, ENA_ADMIN_AENQ_CONFIG, 0);
 	if (ret) {
-		ena_trc_info("Can't get aenq configuration\n");
+		ena_trc_info(ena_dev, "Can't get aenq configuration\n");
 		return ret;
 	}
 
 	if ((get_resp.u.aenq.supported_groups & groups_flag) != groups_flag) {
-		ena_trc_warn("Trying to set unsupported aenq events. supported flag: 0x%x asked flag: 0x%x\n",
+		ena_trc_warn(ena_dev, "Trying to set unsupported aenq events. supported flag: 0x%x asked flag: 0x%x\n",
 			     get_resp.u.aenq.supported_groups,
 			     groups_flag);
 		return ENA_COM_UNSUPPORTED;
@@ -1578,7 +1594,7 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_dev, u32 groups_flag)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to config AENQ ret: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to config AENQ ret: %d\n", ret);
 
 	return ret;
 }
@@ -1589,17 +1605,17 @@ int ena_com_get_dma_width(struct ena_com_dev *ena_dev)
 	int width;
 
 	if (unlikely(caps == ENA_MMIO_READ_TIMEOUT)) {
-		ena_trc_err("Reg read timeout occurred\n");
+		ena_trc_err(ena_dev, "Reg read timeout occurred\n");
 		return ENA_COM_TIMER_EXPIRED;
 	}
 
 	width = (caps & ENA_REGS_CAPS_DMA_ADDR_WIDTH_MASK) >>
 		ENA_REGS_CAPS_DMA_ADDR_WIDTH_SHIFT;
 
-	ena_trc_dbg("ENA dma width: %d\n", width);
+	ena_trc_dbg(ena_dev, "ENA dma width: %d\n", width);
 
 	if ((width < 32) || width > ENA_MAX_PHYS_ADDR_SIZE_BITS) {
-		ena_trc_err("DMA width illegal value: %d\n", width);
+		ena_trc_err(ena_dev, "DMA width illegal value: %d\n", width);
 		return ENA_COM_INVAL;
 	}
 
@@ -1623,16 +1639,16 @@ int ena_com_validate_version(struct ena_com_dev *ena_dev)
 
 	if (unlikely((ver == ENA_MMIO_READ_TIMEOUT) ||
 		     (ctrl_ver == ENA_MMIO_READ_TIMEOUT))) {
-		ena_trc_err("Reg read timeout occurred\n");
+		ena_trc_err(ena_dev, "Reg read timeout occurred\n");
 		return ENA_COM_TIMER_EXPIRED;
 	}
 
-	ena_trc_info("ena device version: %d.%d\n",
+	ena_trc_info(ena_dev, "ENA device version: %d.%d\n",
 		     (ver & ENA_REGS_VERSION_MAJOR_VERSION_MASK) >>
 		     ENA_REGS_VERSION_MAJOR_VERSION_SHIFT,
 		     ver & ENA_REGS_VERSION_MINOR_VERSION_MASK);
 
-	ena_trc_info("ena controller version: %d.%d.%d implementation version %d\n",
+	ena_trc_info(ena_dev, "ENA controller version: %d.%d.%d implementation version %d\n",
 		     (ctrl_ver & ENA_REGS_CONTROLLER_VERSION_MAJOR_VERSION_MASK)
 		     >> ENA_REGS_CONTROLLER_VERSION_MAJOR_VERSION_SHIFT,
 		     (ctrl_ver & ENA_REGS_CONTROLLER_VERSION_MINOR_VERSION_MASK)
@@ -1648,7 +1664,7 @@ int ena_com_validate_version(struct ena_com_dev *ena_dev)
 
 	/* Validate the ctrl version without the implementation ID */
 	if (ctrl_ver_masked < MIN_ENA_CTRL_VER) {
-		ena_trc_err("ENA ctrl version is lower than the minimal ctrl version the driver supports\n");
+		ena_trc_err(ena_dev, "ENA ctrl version is lower than the minimal ctrl version the driver supports\n");
 		return -1;
 	}
 
@@ -1786,12 +1802,12 @@ int ena_com_admin_init(struct ena_com_dev *ena_dev,
 	dev_sts = ena_com_reg_bar_read32(ena_dev, ENA_REGS_DEV_STS_OFF);
 
 	if (unlikely(dev_sts == ENA_MMIO_READ_TIMEOUT)) {
-		ena_trc_err("Reg read timeout occurred\n");
+		ena_trc_err(ena_dev, "Reg read timeout occurred\n");
 		return ENA_COM_TIMER_EXPIRED;
 	}
 
 	if (!(dev_sts & ENA_REGS_DEV_STS_READY_MASK)) {
-		ena_trc_err("Device isn't ready, abort com init\n");
+		ena_trc_err(ena_dev, "Device isn't ready, abort com init\n");
 		return ENA_COM_NO_DEVICE;
 	}
 
@@ -1869,7 +1885,7 @@ int ena_com_create_io_queue(struct ena_com_dev *ena_dev,
 	int ret;
 
 	if (ctx->qid >= ENA_TOTAL_NUM_QUEUES) {
-		ena_trc_err("Qid (%d) is bigger than max num of queues (%d)\n",
+		ena_trc_err(ena_dev, "Qid (%d) is bigger than max num of queues (%d)\n",
 			    ctx->qid, ENA_TOTAL_NUM_QUEUES);
 		return ENA_COM_INVAL;
 	}
@@ -1928,7 +1944,7 @@ void ena_com_destroy_io_queue(struct ena_com_dev *ena_dev, u16 qid)
 	struct ena_com_io_cq *io_cq;
 
 	if (qid >= ENA_TOTAL_NUM_QUEUES) {
-		ena_trc_err("Qid (%d) is bigger than max num of queues (%d)\n",
+		ena_trc_err(ena_dev, "Qid (%d) is bigger than max num of queues (%d)\n",
 			    qid, ENA_TOTAL_NUM_QUEUES);
 		return;
 	}
@@ -2090,7 +2106,7 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data)
 		timestamp = (u64)aenq_common->timestamp_low |
 			((u64)aenq_common->timestamp_high << 32);
 		ENA_TOUCH(timestamp); /* In case debug is disabled */
-		ena_trc_dbg("AENQ! Group[%x] Syndrom[%x] timestamp: [%" ENA_PRIu64 "s]\n",
+		ena_trc_dbg(ena_dev, "AENQ! Group[%x] Syndrom[%x] timestamp: [%" ENA_PRIu64 "s]\n",
 			    aenq_common->group,
 			    aenq_common->syndrom,
 			    timestamp);
@@ -2137,19 +2153,19 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev,
 
 	if (unlikely((stat == ENA_MMIO_READ_TIMEOUT) ||
 		     (cap == ENA_MMIO_READ_TIMEOUT))) {
-		ena_trc_err("Reg read32 timeout occurred\n");
+		ena_trc_err(ena_dev, "Reg read32 timeout occurred\n");
 		return ENA_COM_TIMER_EXPIRED;
 	}
 
 	if ((stat & ENA_REGS_DEV_STS_READY_MASK) == 0) {
-		ena_trc_err("Device isn't ready, can't reset device\n");
+		ena_trc_err(ena_dev, "Device isn't ready, can't reset device\n");
 		return ENA_COM_INVAL;
 	}
 
 	timeout = (cap & ENA_REGS_CAPS_RESET_TIMEOUT_MASK) >>
 			ENA_REGS_CAPS_RESET_TIMEOUT_SHIFT;
 	if (timeout == 0) {
-		ena_trc_err("Invalid timeout value\n");
+		ena_trc_err(ena_dev, "Invalid timeout value\n");
 		return ENA_COM_INVAL;
 	}
 
@@ -2165,7 +2181,7 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev,
 	rc = wait_for_reset_state(ena_dev, timeout,
 				  ENA_REGS_DEV_STS_RESET_IN_PROGRESS_MASK);
 	if (rc != 0) {
-		ena_trc_err("Reset indication didn't turn on\n");
+		ena_trc_err(ena_dev, "Reset indication didn't turn on\n");
 		return rc;
 	}
 
@@ -2173,7 +2189,7 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev,
 	ENA_REG_WRITE32(ena_dev->bus, 0, ena_dev->reg_bar + ENA_REGS_DEV_CTL_OFF);
 	rc = wait_for_reset_state(ena_dev, timeout, 0);
 	if (rc != 0) {
-		ena_trc_err("Reset indication didn't turn off\n");
+		ena_trc_err(ena_dev, "Reset indication didn't turn off\n");
 		return rc;
 	}
 
@@ -2210,7 +2226,7 @@ static int ena_get_dev_stats(struct ena_com_dev *ena_dev,
 					     sizeof(*get_resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to get stats. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to get stats. error: %d\n", ret);
 
 	return ret;
 }
@@ -2253,7 +2269,7 @@ int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu)
 	int ret;
 
 	if (!ena_com_check_supported_feature_id(ena_dev, ENA_ADMIN_MTU)) {
-		ena_trc_dbg("Feature %d isn't supported\n", ENA_ADMIN_MTU);
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n", ENA_ADMIN_MTU);
 		return ENA_COM_UNSUPPORTED;
 	}
 
@@ -2272,7 +2288,7 @@ int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to set mtu %d. error: %d\n", mtu, ret);
+		ena_trc_err(ena_dev, "Failed to set mtu %d. error: %d\n", mtu, ret);
 
 	return ret;
 }
@@ -2286,7 +2302,7 @@ int ena_com_get_offload_settings(struct ena_com_dev *ena_dev,
 	ret = ena_com_get_feature(ena_dev, &resp,
 				  ENA_ADMIN_STATELESS_OFFLOAD_CONFIG, 0);
 	if (unlikely(ret)) {
-		ena_trc_err("Failed to get offload capabilities %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to get offload capabilities %d\n", ret);
 		return ret;
 	}
 
@@ -2306,7 +2322,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
 
 	if (!ena_com_check_supported_feature_id(ena_dev,
 						ENA_ADMIN_RSS_HASH_FUNCTION)) {
-		ena_trc_dbg("Feature %d isn't supported\n",
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
 			    ENA_ADMIN_RSS_HASH_FUNCTION);
 		return ENA_COM_UNSUPPORTED;
 	}
@@ -2318,7 +2334,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
 		return ret;
 
 	if (!(get_resp.u.flow_hash_func.supported_func & BIT(rss->hash_func))) {
-		ena_trc_err("Func hash %d isn't supported by device, abort\n",
+		ena_trc_err(ena_dev, "Func hash %d isn't supported by device, abort\n",
 			    rss->hash_func);
 		return ENA_COM_UNSUPPORTED;
 	}
@@ -2336,7 +2352,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
 				   &cmd.control_buffer.address,
 				   rss->hash_key_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -2348,7 +2364,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
 					    (struct ena_admin_acq_entry *)&resp,
 					    sizeof(resp));
 	if (unlikely(ret)) {
-		ena_trc_err("Failed to set hash function %d. error: %d\n",
+		ena_trc_err(ena_dev, "Failed to set hash function %d. error: %d\n",
 			    rss->hash_func, ret);
 		return ENA_COM_INVAL;
 	}
@@ -2380,7 +2396,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
 		return rc;
 
 	if (!(BIT(func) & get_resp.u.flow_hash_func.supported_func)) {
-		ena_trc_err("Flow hash function %d isn't supported\n", func);
+		ena_trc_err(ena_dev, "Flow hash function %d isn't supported\n", func);
 		return ENA_COM_UNSUPPORTED;
 	}
 
@@ -2388,7 +2404,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
 	case ENA_ADMIN_TOEPLITZ:
 		if (key) {
 			if (key_len != sizeof(hash_key->key)) {
-				ena_trc_err("key len (%hu) doesn't equal the supported size (%zu)\n",
+				ena_trc_err(ena_dev, "key len (%hu) doesn't equal the supported size (%zu)\n",
 					     key_len, sizeof(hash_key->key));
 				return ENA_COM_INVAL;
 			}
@@ -2401,7 +2417,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
 		rss->hash_init_val = init_val;
 		break;
 	default:
-		ena_trc_err("Invalid hash function (%d)\n", func);
+		ena_trc_err(ena_dev, "Invalid hash function (%d)\n", func);
 		return ENA_COM_INVAL;
 	}
 
@@ -2486,7 +2502,7 @@ int ena_com_set_hash_ctrl(struct ena_com_dev *ena_dev)
 
 	if (!ena_com_check_supported_feature_id(ena_dev,
 						ENA_ADMIN_RSS_HASH_INPUT)) {
-		ena_trc_dbg("Feature %d isn't supported\n",
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
 			    ENA_ADMIN_RSS_HASH_INPUT);
 		return ENA_COM_UNSUPPORTED;
 	}
@@ -2505,7 +2521,7 @@ int ena_com_set_hash_ctrl(struct ena_com_dev *ena_dev)
 				   &cmd.control_buffer.address,
 				   rss->hash_ctrl_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 	cmd.control_buffer.length = sizeof(*hash_ctrl);
@@ -2516,7 +2532,7 @@ int ena_com_set_hash_ctrl(struct ena_com_dev *ena_dev)
 					    (struct ena_admin_acq_entry *)&resp,
 					    sizeof(resp));
 	if (unlikely(ret))
-		ena_trc_err("Failed to set hash input. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to set hash input. error: %d\n", ret);
 
 	return ret;
 }
@@ -2566,7 +2582,7 @@ int ena_com_set_default_hash_ctrl(struct ena_com_dev *ena_dev)
 		available_fields = hash_ctrl->selected_fields[i].fields &
 				hash_ctrl->supported_fields[i].fields;
 		if (available_fields != hash_ctrl->selected_fields[i].fields) {
-			ena_trc_err("hash control doesn't support all the desire configuration. proto %x supported %x selected %x\n",
+			ena_trc_err(ena_dev, "Hash control doesn't support all the desire configuration. proto %x supported %x selected %x\n",
 				    i, hash_ctrl->supported_fields[i].fields,
 				    hash_ctrl->selected_fields[i].fields);
 			return ENA_COM_UNSUPPORTED;
@@ -2592,7 +2608,7 @@ int ena_com_fill_hash_ctrl(struct ena_com_dev *ena_dev,
 	int rc;
 
 	if (proto >= ENA_ADMIN_RSS_PROTO_NUM) {
-		ena_trc_err("Invalid proto num (%u)\n", proto);
+		ena_trc_err(ena_dev, "Invalid proto num (%u)\n", proto);
 		return ENA_COM_INVAL;
 	}
 
@@ -2604,7 +2620,7 @@ int ena_com_fill_hash_ctrl(struct ena_com_dev *ena_dev,
 	/* Make sure all the fields are supported */
 	supported_fields = hash_ctrl->supported_fields[proto].fields;
 	if ((hash_fields & supported_fields) != hash_fields) {
-		ena_trc_err("proto %d doesn't support the required fields %x. supports only: %x\n",
+		ena_trc_err(ena_dev, "Proto %d doesn't support the required fields %x. supports only: %x\n",
 			    proto, hash_fields, supported_fields);
 	}
 
@@ -2645,14 +2661,14 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 
 	if (!ena_com_check_supported_feature_id(ena_dev,
 						ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG)) {
-		ena_trc_dbg("Feature %d isn't supported\n",
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
 			    ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG);
 		return ENA_COM_UNSUPPORTED;
 	}
 
 	ret = ena_com_ind_tbl_convert_to_device(ena_dev);
 	if (ret) {
-		ena_trc_err("Failed to convert host indirection table to device table\n");
+		ena_trc_err(ena_dev, "Failed to convert host indirection table to device table\n");
 		return ret;
 	}
 
@@ -2669,7 +2685,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 				   &cmd.control_buffer.address,
 				   rss->rss_ind_tbl_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -2683,7 +2699,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to set indirect table. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to set indirect table. error: %d\n", ret);
 
 	return ret;
 }
@@ -2848,7 +2864,7 @@ int ena_com_set_host_attributes(struct ena_com_dev *ena_dev)
 				   &cmd.u.host_attr.debug_ba,
 				   host_attr->debug_area_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -2856,7 +2872,7 @@ int ena_com_set_host_attributes(struct ena_com_dev *ena_dev)
 				   &cmd.u.host_attr.os_info_ba,
 				   host_attr->host_info_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -2869,7 +2885,7 @@ int ena_com_set_host_attributes(struct ena_com_dev *ena_dev)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to set host attributes: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to set host attributes: %d\n", ret);
 
 	return ret;
 }
@@ -2881,12 +2897,13 @@ bool ena_com_interrupt_moderation_supported(struct ena_com_dev *ena_dev)
 						  ENA_ADMIN_INTERRUPT_MODERATION);
 }
 
-static int ena_com_update_nonadaptive_moderation_interval(u32 coalesce_usecs,
+static int ena_com_update_nonadaptive_moderation_interval(struct ena_com_dev *ena_dev,
+							  u32 coalesce_usecs,
 							  u32 intr_delay_resolution,
 							  u32 *intr_moder_interval)
 {
 	if (!intr_delay_resolution) {
-		ena_trc_err("Illegal interrupt delay granularity value\n");
+		ena_trc_err(ena_dev, "Illegal interrupt delay granularity value\n");
 		return ENA_COM_FAULT;
 	}
 
@@ -2895,11 +2912,11 @@ static int ena_com_update_nonadaptive_moderation_interval(u32 coalesce_usecs,
 	return 0;
 }
 
-
 int ena_com_update_nonadaptive_moderation_interval_tx(struct ena_com_dev *ena_dev,
 						      u32 tx_coalesce_usecs)
 {
-	return ena_com_update_nonadaptive_moderation_interval(tx_coalesce_usecs,
+	return ena_com_update_nonadaptive_moderation_interval(ena_dev,
+							      tx_coalesce_usecs,
 							      ena_dev->intr_delay_resolution,
 							      &ena_dev->intr_moder_tx_interval);
 }
@@ -2907,7 +2924,8 @@ int ena_com_update_nonadaptive_moderation_interval_tx(struct ena_com_dev *ena_de
 int ena_com_update_nonadaptive_moderation_interval_rx(struct ena_com_dev *ena_dev,
 						      u32 rx_coalesce_usecs)
 {
-	return ena_com_update_nonadaptive_moderation_interval(rx_coalesce_usecs,
+	return ena_com_update_nonadaptive_moderation_interval(ena_dev,
+							      rx_coalesce_usecs,
 							      ena_dev->intr_delay_resolution,
 							      &ena_dev->intr_moder_rx_interval);
 }
@@ -2923,12 +2941,12 @@ int ena_com_init_interrupt_moderation(struct ena_com_dev *ena_dev)
 
 	if (rc) {
 		if (rc == ENA_COM_UNSUPPORTED) {
-			ena_trc_dbg("Feature %d isn't supported\n",
+			ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
 				    ENA_ADMIN_INTERRUPT_MODERATION);
 			rc = 0;
 		} else {
-			ena_trc_err("Failed to get interrupt moderation admin cmd. rc: %d\n",
-				    rc);
+			ena_trc_err(ena_dev,
+				    "Failed to get interrupt moderation admin cmd. rc: %d\n", rc);
 		}
 
 		/* no moderation supported, disable adaptive support */
@@ -2976,7 +2994,7 @@ int ena_com_config_dev_mode(struct ena_com_dev *ena_dev,
 		(llq_info->descs_num_before_header * sizeof(struct ena_eth_io_tx_desc));
 
 	if (unlikely(ena_dev->tx_max_header_size == 0)) {
-		ena_trc_err("the size of the LLQ entry is smaller than needed\n");
+		ena_trc_err(ena_dev, "The size of the LLQ entry is smaller than needed\n");
 		return -EINVAL;
 	}
 
drivers/net/ena/base/ena_com.h +21 -0
index e9601b1a8e..cd116e90e6 100644
@@ -300,6 +300,7 @@ struct ena_com_dev {
 	void __iomem *mem_bar;
 	void *dmadev;
 	void *bus;
+	ena_netdev *net_device;
 
 	enum ena_admin_placement_policy_type tx_mem_queue_type;
 	u32 tx_max_header_size;
@@ -944,6 +945,26 @@ int ena_com_config_dev_mode(struct ena_com_dev *ena_dev,
 			    struct ena_admin_feature_llq_desc *llq_features,
 			    struct ena_llq_configurations *llq_default_config);
 
+/* ena_com_io_sq_to_ena_dev - Extract ena_com_dev using contained field io_sq.
+ * @io_sq: IO submit queue struct
+ *
+ * @return - ena_com_dev struct extracted from io_sq
+ */
+static inline struct ena_com_dev *ena_com_io_sq_to_ena_dev(struct ena_com_io_sq *io_sq)
+{
+	return container_of(io_sq, struct ena_com_dev, io_sq_queues[io_sq->qid]);
+}
+
+/* ena_com_io_cq_to_ena_dev - Extract ena_com_dev using contained field io_cq.
+ * @io_sq: IO submit queue struct
+ *
+ * @return - ena_com_dev struct extracted from io_sq
+ */
+static inline struct ena_com_dev *ena_com_io_cq_to_ena_dev(struct ena_com_io_cq *io_cq)
+{
+	return container_of(io_cq, struct ena_com_dev, io_cq_queues[io_cq->qid]);
+}
+
 static inline bool ena_com_get_adaptive_moderation_enabled(struct ena_com_dev *ena_dev)
 {
 	return ena_dev->adaptive_coalescing;
drivers/net/ena/base/ena_eth_com.c +52 -26

220 lines not on this page · raw message

drivers/net/ena/base/ena_eth_com.h +11 -6
index 7dda16cd9f..0cfd18882e 100644
@@ -143,7 +143,8 @@ static inline bool ena_com_is_doorbell_needed(struct ena_com_io_sq *io_sq,
 						   llq_info->descs_per_entry);
 	}
 
-	ena_trc_dbg("queue: %d num_descs: %d num_entries_needed: %d\n",
+	ena_trc_dbg(ena_com_io_sq_to_ena_dev(io_sq),
+		    "Queue: %d num_descs: %d num_entries_needed: %d\n",
 		    io_sq->qid, num_descs, num_entries_needed);
 
 	return num_entries_needed > io_sq->entries_in_tx_burst_left;
@@ -154,14 +155,16 @@ static inline int ena_com_write_sq_doorbell(struct ena_com_io_sq *io_sq)
 	u16 max_entries_in_tx_burst = io_sq->llq_info.max_entries_in_tx_burst;
 	u16 tail = io_sq->tail;
 
-	ena_trc_dbg("write submission queue doorbell for queue: %d tail: %d\n",
+	ena_trc_dbg(ena_com_io_sq_to_ena_dev(io_sq),
+		    "Write submission queue doorbell for queue: %d tail: %d\n",
 		    io_sq->qid, tail);
 
 	ENA_REG_WRITE32(io_sq->bus, tail, io_sq->db_addr);
 
 	if (is_llq_max_tx_burst_exists(io_sq)) {
-		ena_trc_dbg("reset available entries in tx burst for queue %d to %d\n",
-			     io_sq->qid, max_entries_in_tx_burst);
+		ena_trc_dbg(ena_com_io_sq_to_ena_dev(io_sq),
+			    "Reset available entries in tx burst for queue %d to %d\n",
+			    io_sq->qid, max_entries_in_tx_burst);
 		io_sq->entries_in_tx_burst_left = max_entries_in_tx_burst;
 	}
 
@@ -179,7 +182,8 @@ static inline int ena_com_update_dev_comp_head(struct ena_com_io_cq *io_cq)
 		need_update = unreported_comp > (io_cq->q_depth / ENA_COMP_HEAD_THRESH);
 
 		if (unlikely(need_update)) {
-			ena_trc_dbg("Write completion queue doorbell for queue %d: head: %d\n",
+			ena_trc_dbg(ena_com_io_cq_to_ena_dev(io_cq),
+				    "Write completion queue doorbell for queue %d: head: %d\n",
 				    io_cq->qid, head);
 			ENA_REG_WRITE32(io_cq->bus, head, io_cq->cq_head_db_reg);
 			io_cq->last_head_update = head;
@@ -243,7 +247,8 @@ static inline int ena_com_tx_comp_req_id_get(struct ena_com_io_cq *io_cq,
 
 	*req_id = READ_ONCE16(cdesc->req_id);
 	if (unlikely(*req_id >= io_cq->q_depth)) {
-		ena_trc_err("Invalid req id %d\n", cdesc->req_id);
+		ena_trc_err(ena_com_io_cq_to_ena_dev(io_cq),
+			    "Invalid req id %d\n", cdesc->req_id);
 		return ENA_COM_INVAL;
 	}
 
drivers/net/ena/base/ena_plat_dpdk.h +24 -20

59 lines not on this page · raw message

Signature · 1 line
2.25.1
#50 lore raw

PATCH v3 4/22 net/ena/base: typos, style and comments improvements

In reply to Michal Krawczyk

List of changes:
* Comment style was adjusted for the functions
* The keys_num at "struct ena_admin_feature_rss_flow_hash_control" was renamed to the key_parts to better describe it's meaning
* The RSS indirection table was called "REDIRECTION" -> changed to INDIRECTION
* Change AENQ field "syndrom" -> "syndrome"
* Calculate number of the RSS key parts or whole key by ussing the common way: sizeof of the first element of the RSS key
* Add description of the "enum ena_admin_aq_feature_id"
* Rename "map_rx_buf_bidirectional" field as "rx_buf_mirroring"
* Other minor style fixes (remove extra spaces, add missing line break, improve indentation)
* Remove unused macros ENA_ADMIN_EXTRA_PROPERTIES_*
* Restructure the "if {} else if {} else" conditional statement for setting up the meta descriptor

Fixes 99ecfbf845b3 ("ena: import communication layer")
Fixes b68309be44c0 ("net/ena/base: update communication layer for the ENAv2")
Fixes b2b02edeb0d6 ("net/ena/base: upgrade HAL for new HW features")
---
 drivers/net/ena/base/ena_com.c                | 26 +++---
 .../net/ena/base/ena_defs/ena_admin_defs.h    | 85 +++++++++----------
 drivers/net/ena/base/ena_eth_com.c            | 16 ++--
 drivers/net/ena/ena_ethdev.c                  |  4 +-
 4 files changed, 66 insertions(+), 65 deletions(-)
drivers/net/ena/base/ena_com.c +14 -12
index 9931819bbb..9dc9f280c4 100644
@@ -598,7 +598,7 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
 	return ret;
 }
 
-/**
+/*
  * Set the LLQ configurations of the firmware
  *
  * The driver provides only the enabled feature values to the device,
@@ -1092,7 +1092,7 @@ static void ena_com_hash_key_fill_default_key(struct ena_com_dev *ena_dev)
 	/* The key buffer is stored in the device in an array of
 	 * uint32 elements.
 	 */
-	hash_key->keys_num = ENA_ADMIN_RSS_KEY_PARTS;
+	hash_key->key_parts = ENA_ADMIN_RSS_KEY_PARTS;
 }
 
 static int ena_com_hash_key_allocate(struct ena_com_dev *ena_dev)
@@ -1165,7 +1165,7 @@ static int ena_com_indirect_table_allocate(struct ena_com_dev *ena_dev,
 	int ret;
 
 	ret = ena_com_get_feature(ena_dev, &get_resp,
-				  ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG, 0);
+				  ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG, 0);
 	if (unlikely(ret))
 		return ret;
 
@@ -1977,6 +1977,7 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev,
 
 	memcpy(&get_feat_ctx->dev_attr, &get_resp.u.dev_attr,
 	       sizeof(get_resp.u.dev_attr));
+
 	ena_dev->supported_features = get_resp.u.dev_attr.supported_features;
 
 	if (ena_dev->supported_features & BIT(ENA_ADMIN_MAX_QUEUES_EXT)) {
@@ -2044,7 +2045,7 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev,
 		return rc;
 
 	rc = ena_com_get_feature(ena_dev, &get_resp,
-				 ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG, 0);
+				 ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG, 0);
 	if (!rc)
 		memcpy(&get_feat_ctx->ind_table, &get_resp.u.ind_table,
 		       sizeof(get_resp.u.ind_table));
@@ -2106,9 +2107,9 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data)
 		timestamp = (u64)aenq_common->timestamp_low |
 			((u64)aenq_common->timestamp_high << 32);
 		ENA_TOUCH(timestamp); /* In case debug is disabled */
-		ena_trc_dbg(ena_dev, "AENQ! Group[%x] Syndrom[%x] timestamp: [%" ENA_PRIu64 "s]\n",
+		ena_trc_dbg(ena_dev, "AENQ! Group[%x] Syndrome[%x] timestamp: [%" ENA_PRIu64 "s]\n",
 			    aenq_common->group,
-			    aenq_common->syndrom,
+			    aenq_common->syndrome,
 			    timestamp);
 
 		/* Handle specific event*/
@@ -2410,7 +2411,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
 			}
 			memcpy(hash_key->key, key, key_len);
 			rss->hash_init_val = init_val;
-			hash_key->keys_num = key_len / sizeof(u32);
+			hash_key->key_parts = key_len / sizeof(hash_key->key[0]);
 		}
 		break;
 	case ENA_ADMIN_CRC32:
@@ -2465,7 +2466,8 @@ int ena_com_get_hash_key(struct ena_com_dev *ena_dev, u8 *key)
 		ena_dev->rss.hash_key;
 
 	if (key)
-		memcpy(key, hash_key->key, (size_t)(hash_key->keys_num) << 2);
+		memcpy(key, hash_key->key,
+		       (size_t)(hash_key->key_parts) * sizeof(hash_key->key[0]));
 
 	return 0;
 }
@@ -2660,9 +2662,9 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 	int ret;
 
 	if (!ena_com_check_supported_feature_id(ena_dev,
-						ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG)) {
+						ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG)) {
 		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
-			    ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG);
+			    ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG);
 		return ENA_COM_UNSUPPORTED;
 	}
 
@@ -2677,7 +2679,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 	cmd.aq_common_descriptor.opcode = ENA_ADMIN_SET_FEATURE;
 	cmd.aq_common_descriptor.flags =
 		ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_INDIRECT_MASK;
-	cmd.feat_common.feature_id = ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG;
+	cmd.feat_common.feature_id = ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG;
 	cmd.u.ind_table.size = rss->tbl_log_size;
 	cmd.u.ind_table.inline_index = 0xFFFFFFFF;
 
@@ -2715,7 +2717,7 @@ int ena_com_indirect_table_get(struct ena_com_dev *ena_dev, u32 *ind_tbl)
 		sizeof(struct ena_admin_rss_ind_table_entry);
 
 	rc = ena_com_get_feature_ex(ena_dev, &get_resp,
-				    ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG,
+				    ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG,
 				    rss->rss_ind_tbl_dma_addr,
 				    tbl_size, 0);
 	if (unlikely(rc))
drivers/net/ena/base/ena_defs/ena_admin_defs.h +41 -44

224 lines not on this page · raw message

drivers/net/ena/base/ena_eth_com.c +9 -7
index 701e6721e3..92a9a10a9e 100644
@@ -331,16 +331,18 @@ static int ena_com_create_and_store_tx_meta_desc(struct ena_com_io_sq *io_sq,
 
 		*have_meta = true;
 		return ena_com_create_meta(io_sq, ena_meta);
-	} else if (ena_com_meta_desc_changed(io_sq, ena_tx_ctx)) {
+	}
+
+	if (ena_com_meta_desc_changed(io_sq, ena_tx_ctx)) {
 		*have_meta = true;
 		/* Cache the meta desc */
 		memcpy(&io_sq->cached_tx_meta, ena_meta,
 		       sizeof(struct ena_com_tx_meta));
 		return ena_com_create_meta(io_sq, ena_meta);
-	} else {
-		*have_meta = false;
-		return ENA_COM_OK;
 	}
+
+	*have_meta = false;
+	return ENA_COM_OK;
 }
 
 static void ena_com_rx_set_flags(struct ena_com_io_cq *io_cq,
@@ -626,9 +628,9 @@ int ena_com_add_single_rx_desc(struct ena_com_io_sq *io_sq,
 	desc->length = ena_buf->len;
 
 	desc->ctrl = ENA_ETH_IO_RX_DESC_FIRST_MASK |
-		ENA_ETH_IO_RX_DESC_LAST_MASK |
-		(io_sq->phase & ENA_ETH_IO_RX_DESC_PHASE_MASK) |
-		ENA_ETH_IO_RX_DESC_COMP_REQ_MASK;
+		     ENA_ETH_IO_RX_DESC_LAST_MASK |
+		     ENA_ETH_IO_RX_DESC_COMP_REQ_MASK |
+		     (io_sq->phase & ENA_ETH_IO_RX_DESC_PHASE_MASK);
 
 	desc->req_id = req_id;
 
drivers/net/ena/ena_ethdev.c +2 -2
index f60e843b7f..f1ff4dad36 100644
@@ -2973,7 +2973,7 @@ static void ena_notification(void *data,
 			aenq_e->aenq_common_desc.group,
 			ENA_ADMIN_NOTIFICATION);
 
-	switch (aenq_e->aenq_common_desc.syndrom) {
+	switch (aenq_e->aenq_common_desc.syndrome) {
 	case ENA_ADMIN_UPDATE_HINTS:
 		hints = (struct ena_admin_ena_hw_hints *)
 			(&aenq_e->inline_data_w4);
@@ -2981,7 +2981,7 @@ static void ena_notification(void *data,
 		break;
 	default:
 		PMD_DRV_LOG(ERR, "Invalid aenq notification link state %d\n",
-			aenq_e->aenq_common_desc.syndrom);
+			aenq_e->aenq_common_desc.syndrome);
 	}
 }
 
Signature · 1 line
2.25.1
#51 lore raw

PATCH v3 5/22 net/ena/base: fix issues from the static code scan

In reply to Michal Krawczyk

To silence error messages from the static code analysis, make the type conversions explicit where they're intended.

Also fix the type for the DMA width value.

Fixes 99ecfbf845b3 ("ena: import communication layer")
---
 drivers/net/ena/base/ena_com.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ena/base/ena_com.c +5 -5
index 9dc9f280c4..0cdeb1a2d9 100644
@@ -1382,7 +1382,7 @@ int ena_com_execute_admin_command(struct ena_com_admin_queue *admin_queue,
 				    "Failed to submit command [%ld]\n",
 				    PTR_ERR(comp_ctx));
 
-		return PTR_ERR(comp_ctx);
+		return (int)PTR_ERR(comp_ctx);
 	}
 
 	ret = ena_com_wait_and_process_admin_cq(comp_ctx, admin_queue);
@@ -1602,7 +1602,7 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_dev, u32 groups_flag)
 int ena_com_get_dma_width(struct ena_com_dev *ena_dev)
 {
 	u32 caps = ena_com_reg_bar_read32(ena_dev, ENA_REGS_CAPS_OFF);
-	int width;
+	u32 width;
 
 	if (unlikely(caps == ENA_MMIO_READ_TIMEOUT)) {
 		ena_trc_err(ena_dev, "Reg read timeout occurred\n");
@@ -2280,7 +2280,7 @@ int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu)
 	cmd.aq_common_descriptor.opcode = ENA_ADMIN_SET_FEATURE;
 	cmd.aq_common_descriptor.flags = 0;
 	cmd.feat_common.feature_id = ENA_ADMIN_MTU;
-	cmd.u.mtu.mtu = mtu;
+	cmd.u.mtu.mtu = (u32)mtu;
 
 	ret = ena_com_execute_admin_command(admin_queue,
 					    (struct ena_admin_aq_entry *)&cmd,
@@ -2691,7 +2691,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 		return ret;
 	}
 
-	cmd.control_buffer.length = (1ULL << rss->tbl_log_size) *
+	cmd.control_buffer.length = (u32)(1ULL << rss->tbl_log_size) *
 		sizeof(struct ena_admin_rss_ind_table_entry);
 
 	ret = ena_com_execute_admin_command(admin_queue,
@@ -2713,7 +2713,7 @@ int ena_com_indirect_table_get(struct ena_com_dev *ena_dev, u32 *ind_tbl)
 	u32 tbl_size;
 	int i, rc;
 
-	tbl_size = (1ULL << rss->tbl_log_size) *
+	tbl_size = (u32)(1ULL << rss->tbl_log_size) *
 		sizeof(struct ena_admin_rss_ind_table_entry);
 
 	rc = ena_com_get_feature_ex(ena_dev, &get_resp,
Signature · 1 line
2.25.1
#52 lore raw

PATCH v3 6/22 net/ena/base: destroy multiple "wait events"

In reply to Michal Krawczyk

Although the ENA DPDK PMD doesn't have to perform any actions for destroying the wait event, some other platforms have to.

The macro "ENA_WAIT_EVENT_DESTROY" was renamed to "ENA_WAIT_EVENTS_DESTROY" and also whole implementation responsible for that was moved to a separate function for better readability.

Fixes 3adcba9a8987 ("net/ena: update HAL to the newer version")
---
 drivers/net/ena/base/ena_com.c       | 24 +++++++++++++++++-------
 drivers/net/ena/base/ena_plat_dpdk.h |  4 ++--
 2 files changed, 19 insertions(+), 9 deletions(-)
drivers/net/ena/base/ena_com.c +17 -7
index 0cdeb1a2d9..d025c9cee1 100644
@@ -1671,6 +1671,22 @@ int ena_com_validate_version(struct ena_com_dev *ena_dev)
 	return 0;
 }
 
+static void
+ena_com_free_ena_admin_queue_comp_ctx(struct ena_com_dev *ena_dev,
+				      struct ena_com_admin_queue *admin_queue)
+
+{
+	if (!admin_queue->comp_ctx)
+		return;
+
+	ENA_WAIT_EVENTS_DESTROY(admin_queue);
+	ENA_MEM_FREE(ena_dev->dmadev,
+		     admin_queue->comp_ctx,
+		     (admin_queue->q_depth * sizeof(struct ena_comp_ctx)));
+
+	admin_queue->comp_ctx = NULL;
+}
+
 void ena_com_admin_destroy(struct ena_com_dev *ena_dev)
 {
 	struct ena_com_admin_queue *admin_queue = &ena_dev->admin_queue;
@@ -1679,14 +1695,8 @@ void ena_com_admin_destroy(struct ena_com_dev *ena_dev)
 	struct ena_com_aenq *aenq = &ena_dev->aenq;
 	u16 size;
 
-	if (admin_queue->comp_ctx) {
-		ENA_WAIT_EVENT_DESTROY(admin_queue->comp_ctx->wait_event);
-		ENA_MEM_FREE(ena_dev->dmadev,
-			     admin_queue->comp_ctx,
-			     (admin_queue->q_depth * sizeof(struct ena_comp_ctx)));
-	}
+	ena_com_free_ena_admin_queue_comp_ctx(ena_dev, admin_queue);
 
-	admin_queue->comp_ctx = NULL;
 	size = ADMIN_SQ_SIZE(admin_queue->q_depth);
 	if (sq->entries)
 		ENA_MEM_FREE_COHERENT(ena_dev->dmadev, size, sq->entries,
drivers/net/ena/base/ena_plat_dpdk.h +2 -2
index 231d44e0e0..ad7b07b374 100644
@@ -166,7 +166,7 @@ extern int ena_logtype_com;
 #define ENA_WAIT_EVENT_SIGNAL(waitevent) pthread_cond_signal(&waitevent.cond)
 /* pthread condition doesn't need to be rearmed after usage */
 #define ENA_WAIT_EVENT_CLEAR(...)
-#define ENA_WAIT_EVENT_DESTROY(waitqueue) ((void)(waitqueue))
+#define ENA_WAIT_EVENT_DESTROY(admin_queue) ((void)(admin_queue))
 
 #define ena_wait_event_t ena_wait_queue_t
 #define ENA_MIGHT_SLEEP()
@@ -298,7 +298,7 @@ extern rte_atomic32_t ena_alloc_cnt;
 #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_WAIT_EVENT_DESTROY(waitqueue) ((void)(waitqueue))
+#define ENA_WAIT_EVENTS_DESTROY(waitqueue) ((void)(waitqueue))
 
 #ifndef READ_ONCE
 #define READ_ONCE(var) (*((volatile typeof(var) *)(&(var))))
Signature · 1 line
2.25.1
#53 lore raw

Re: [dpdk-dev] [PATCH v3 06/22] net/ena/base: destroy multiple "wait events"

Quoted 24 lines · Michal Krawczyk

Although the ENA DPDK PMD doesn't have to perform any actions for destroying the wait event, some other platforms have to.

The macro "ENA_WAIT_EVENT_DESTROY" was renamed to "ENA_WAIT_EVENTS_DESTROY" and also whole implementation responsible for that was moved to a separate function for better readability.

Fixes 3adcba9a8987 ("net/ena: update HAL to the newer version")
---
 drivers/net/ena/base/ena_com.c       | 24 +++++++++++++++++-------
 drivers/net/ena/base/ena_plat_dpdk.h |  4 ++--
 2 files changed, 19 insertions(+), 9 deletions(-)
drivers/net/ena/base/ena_com.c +0 -0
index 0cdeb1a2d9..d025c9cee1 100644
@@ -1671,6 +1671,22 @@ int ena_com_validate_version(struct ena_com_dev *ena_dev)
 	return 0;
 }

drivers/net/ena/base/ena_com.c int ena_com_validate_version(struct ena_com_dev *ena_dev) · line 1682

Quoted 10 lines
drivers/net/ena/base/ena_com.c +9 -0
 
+static void
+ena_com_free_ena_admin_queue_comp_ctx(struct ena_com_dev *ena_dev,
+				      struct ena_com_admin_queue *admin_queue)
+
+{
+	if (!admin_queue->comp_ctx)
+		return;
+
+	ENA_WAIT_EVENTS_DESTROY(admin_queue);

I can see both 'ENA_WAIT_EVENT_DESTROY' & 'ENA_WAIT_EVENTS_DESTROY' does nothing but, according their definitions:
+#define ENA_WAIT_EVENT_DESTROY(admin_queue) ((void)(admin_queue)) +#define ENA_WAIT_EVENTS_DESTROY(waitqueue) ((void)(waitqueue)

If 'ENA_WAIT_EVENTS_DESTROY' also gets 'admin_queue' as parameter, does it make sense to update the definition of it to get 'admin_queue', like:
#define ENA_WAIT_EVENTS_DESTROY(admin_queue) ((void)(admin_queue)

And I can see that is updated in next patches, so may be better to update here.

Quoted 49 lines
drivers/net/ena/base/ena_com.c +8 -7
+	ENA_MEM_FREE(ena_dev->dmadev,
+		     admin_queue->comp_ctx,
+		     (admin_queue->q_depth * sizeof(struct ena_comp_ctx)));
+
+	admin_queue->comp_ctx = NULL;
+}
+
 void ena_com_admin_destroy(struct ena_com_dev *ena_dev)
 {
 	struct ena_com_admin_queue *admin_queue = &ena_dev->admin_queue;
@@ -1679,14 +1695,8 @@ void ena_com_admin_destroy(struct ena_com_dev *ena_dev)
 	struct ena_com_aenq *aenq = &ena_dev->aenq;
 	u16 size;
 
-	if (admin_queue->comp_ctx) {
-		ENA_WAIT_EVENT_DESTROY(admin_queue->comp_ctx->wait_event);
-		ENA_MEM_FREE(ena_dev->dmadev,
-			     admin_queue->comp_ctx,
-			     (admin_queue->q_depth * sizeof(struct ena_comp_ctx)));
-	}
+	ena_com_free_ena_admin_queue_comp_ctx(ena_dev, admin_queue);
 
-	admin_queue->comp_ctx = NULL;
 	size = ADMIN_SQ_SIZE(admin_queue->q_depth);
 	if (sq->entries)
 		ENA_MEM_FREE_COHERENT(ena_dev->dmadev, size, sq->entries,
drivers/net/ena/base/ena_plat_dpdk.h +2 -2
index 231d44e0e0..ad7b07b374 100644
@@ -166,7 +166,7 @@ extern int ena_logtype_com;
 #define ENA_WAIT_EVENT_SIGNAL(waitevent) pthread_cond_signal(&waitevent.cond)
 /* pthread condition doesn't need to be rearmed after usage */
 #define ENA_WAIT_EVENT_CLEAR(...)
-#define ENA_WAIT_EVENT_DESTROY(waitqueue) ((void)(waitqueue))
+#define ENA_WAIT_EVENT_DESTROY(admin_queue) ((void)(admin_queue))
 
 #define ena_wait_event_t ena_wait_queue_t
 #define ENA_MIGHT_SLEEP()
@@ -298,7 +298,7 @@ extern rte_atomic32_t ena_alloc_cnt;
 #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_WAIT_EVENT_DESTROY(waitqueue) ((void)(waitqueue))
+#define ENA_WAIT_EVENTS_DESTROY(waitqueue) ((void)(waitqueue))
 
 #ifndef READ_ONCE
 #define READ_ONCE(var) (*((volatile typeof(var) *)(&(var))))
#54 lore raw

Re: [dpdk-dev] [PATCH v3 06/22] net/ena/base: destroy multiple "wait events"

pt., 7 maj 2021 o 18:47 Ferruh Yigit <[email protected]> napisał(a):

Quoted 42 lines · Michal Krawczyk
Quoted 24 lines

Although the ENA DPDK PMD doesn't have to perform any actions for destroying the wait event, some other platforms have to.

The macro "ENA_WAIT_EVENT_DESTROY" was renamed to "ENA_WAIT_EVENTS_DESTROY" and also whole implementation responsible for that was moved to a separate function for better readability.

Fixes 3adcba9a8987 ("net/ena: update HAL to the newer version")
---
 drivers/net/ena/base/ena_com.c       | 24 +++++++++++++++++-------
 drivers/net/ena/base/ena_plat_dpdk.h |  4 ++--
 2 files changed, 19 insertions(+), 9 deletions(-)
drivers/net/ena/base/ena_com.c +0 -0
index 0cdeb1a2d9..d025c9cee1 100644
@@ -1671,6 +1671,22 @@ int ena_com_validate_version(struct ena_com_dev *ena_dev)
      return 0;
 }

drivers/net/ena/base/ena_com.c int ena_com_validate_version(struct ena_com_dev *ena_dev) · line 1682

Quoted 10 lines
drivers/net/ena/base/ena_com.c +9 -0
 
+static void
+ena_com_free_ena_admin_queue_comp_ctx(struct ena_com_dev *ena_dev,
+                                   struct ena_com_admin_queue *admin_queue)
+
+{
+     if (!admin_queue->comp_ctx)
+             return;
+
+     ENA_WAIT_EVENTS_DESTROY(admin_queue);

I can see both 'ENA_WAIT_EVENT_DESTROY' & 'ENA_WAIT_EVENTS_DESTROY' does nothing but, according their definitions:
+#define ENA_WAIT_EVENT_DESTROY(admin_queue) ((void)(admin_queue)) +#define ENA_WAIT_EVENTS_DESTROY(waitqueue) ((void)(waitqueue)

Quoted 6 lines

If 'ENA_WAIT_EVENTS_DESTROY' also gets 'admin_queue' as parameter, does it make sense to update the definition of it to get 'admin_queue', like:
#define ENA_WAIT_EVENTS_DESTROY(admin_queue) ((void)(admin_queue)

And I can see that is updated in next patches, so may be better to update here.

I agree, the ENA_WAIT_EVENTS_DESTROY() should take as an argument admin_queue. The ENA_WAIT_EVENT_DESTROY shouldn't be touched by this patch. I will fix that in v4.

Quoted 50 lines
Quoted 49 lines
drivers/net/ena/base/ena_com.c +8 -7
+     ENA_MEM_FREE(ena_dev->dmadev,
+                  admin_queue->comp_ctx,
+                  (admin_queue->q_depth * sizeof(struct ena_comp_ctx)));
+
+     admin_queue->comp_ctx = NULL;
+}
+
 void ena_com_admin_destroy(struct ena_com_dev *ena_dev)
 {
      struct ena_com_admin_queue *admin_queue = &ena_dev->admin_queue;
@@ -1679,14 +1695,8 @@ void ena_com_admin_destroy(struct ena_com_dev *ena_dev)
      struct ena_com_aenq *aenq = &ena_dev->aenq;
      u16 size;
 
-     if (admin_queue->comp_ctx) {
-             ENA_WAIT_EVENT_DESTROY(admin_queue->comp_ctx->wait_event);
-             ENA_MEM_FREE(ena_dev->dmadev,
-                          admin_queue->comp_ctx,
-                          (admin_queue->q_depth * sizeof(struct ena_comp_ctx)));
-     }
+     ena_com_free_ena_admin_queue_comp_ctx(ena_dev, admin_queue);
 
-     admin_queue->comp_ctx = NULL;
      size = ADMIN_SQ_SIZE(admin_queue->q_depth);
      if (sq->entries)
              ENA_MEM_FREE_COHERENT(ena_dev->dmadev, size, sq->entries,
drivers/net/ena/base/ena_plat_dpdk.h +2 -2
index 231d44e0e0..ad7b07b374 100644
@@ -166,7 +166,7 @@ extern int ena_logtype_com;
 #define ENA_WAIT_EVENT_SIGNAL(waitevent) pthread_cond_signal(&waitevent.cond)
 /* pthread condition doesn't need to be rearmed after usage */
 #define ENA_WAIT_EVENT_CLEAR(...)
-#define ENA_WAIT_EVENT_DESTROY(waitqueue) ((void)(waitqueue))
+#define ENA_WAIT_EVENT_DESTROY(admin_queue) ((void)(admin_queue))
 
 #define ena_wait_event_t ena_wait_queue_t
 #define ENA_MIGHT_SLEEP()
@@ -298,7 +298,7 @@ extern rte_atomic32_t ena_alloc_cnt;
 #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_WAIT_EVENT_DESTROY(waitqueue) ((void)(waitqueue))
+#define ENA_WAIT_EVENTS_DESTROY(waitqueue) ((void)(waitqueue))
 
 #ifndef READ_ONCE
 #define READ_ONCE(var) (*((volatile typeof(var) *)(&(var))))
#55 lore raw

PATCH v3 7/22 net/ena/base: remove indir table from ENA feat ctx

In reply to Michal Krawczyk

The RSS indirection table shouldn't be included as a part of the device features context.

If the driver has to acquire it, it can be done using the separate API whenever the RSS configuration is needed.

---
 drivers/net/ena/base/ena_com.c | 11 -----------
 drivers/net/ena/base/ena_com.h |  1 -
 2 files changed, 12 deletions(-)
drivers/net/ena/base/ena_com.c +0 -11
index d025c9cee1..5ca36ab6d9 100644
@@ -2054,17 +2054,6 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev,
 	else
 		return rc;
 
-	rc = ena_com_get_feature(ena_dev, &get_resp,
-				 ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG, 0);
-	if (!rc)
-		memcpy(&get_feat_ctx->ind_table, &get_resp.u.ind_table,
-		       sizeof(get_resp.u.ind_table));
-	else if (rc == ENA_COM_UNSUPPORTED)
-		memset(&get_feat_ctx->ind_table, 0x0,
-		       sizeof(get_feat_ctx->ind_table));
-	else
-		return rc;
-
 	return 0;
 }
 
drivers/net/ena/base/ena_com.h +0 -1
index cd116e90e6..ca84e2e8bc 100644
@@ -338,7 +338,6 @@ struct ena_com_dev_get_features_ctx {
 	struct ena_admin_feature_offload_desc offload;
 	struct ena_admin_ena_hw_hints hw_hints;
 	struct ena_admin_feature_llq_desc llq;
-	struct ena_admin_feature_rss_ind_table ind_table;
 };
 
 struct ena_com_create_io_ctx {
Signature · 1 line
2.25.1
#56 lore raw

PATCH v3 8/22 net/ena/base: remove mutable RSS from the host info

In reply to Michal Krawczyk

This feature wasn't used by any of the drivers. Because of that, it was removed.

---
 drivers/net/ena/base/ena_defs/ena_admin_defs.h | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/net/ena/base/ena_defs/ena_admin_defs.h +1 -12
index 40c2db717c..56768e1a1b 100644
@@ -866,7 +866,7 @@ struct ena_admin_host_info {
 
 	uint16_t reserved;
 
-	/* 0 : mutable_rss_table_size
+	/* 0 : reserved
 	 * 1 : rx_offset
 	 * 2 : interrupt_moderation
 	 * 3 : rx_buf_mirroring
@@ -1189,7 +1189,6 @@ struct ena_admin_ena_mmio_req_read_less_resp {
 #define ENA_ADMIN_HOST_INFO_DEVICE_MASK                     GENMASK(7, 3)
 #define ENA_ADMIN_HOST_INFO_BUS_SHIFT                       8
 #define ENA_ADMIN_HOST_INFO_BUS_MASK                        GENMASK(15, 8)
-#define ENA_ADMIN_HOST_INFO_MUTABLE_RSS_TABLE_SIZE_MASK     BIT(0)
 #define ENA_ADMIN_HOST_INFO_RX_OFFSET_SHIFT                 1
 #define ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK                  BIT(1)
 #define ENA_ADMIN_HOST_INFO_INTERRUPT_MODERATION_SHIFT      2
@@ -1619,16 +1618,6 @@ static inline void set_ena_admin_host_info_bus(struct ena_admin_host_info *p, ui
 	p->bdf |= (val << ENA_ADMIN_HOST_INFO_BUS_SHIFT) & ENA_ADMIN_HOST_INFO_BUS_MASK;
 }
 
-static inline uint32_t get_ena_admin_host_info_mutable_rss_table_size(const struct ena_admin_host_info *p)
-{
-	return p->driver_supported_features & ENA_ADMIN_HOST_INFO_MUTABLE_RSS_TABLE_SIZE_MASK;
-}
-
-static inline void set_ena_admin_host_info_mutable_rss_table_size(struct ena_admin_host_info *p, uint32_t val)
-{
-	p->driver_supported_features |= val & ENA_ADMIN_HOST_INFO_MUTABLE_RSS_TABLE_SIZE_MASK;
-}
-
 static inline uint32_t get_ena_admin_host_info_rx_offset(const struct ena_admin_host_info *p)
 {
 	return (p->driver_supported_features & ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK) >> ENA_ADMIN_HOST_INFO_RX_OFFSET_SHIFT;
Signature · 1 line
2.25.1
#57 lore raw

PATCH v3 9/22 net/ena/base: update generation date and commit

In reply to Michal Krawczyk

The current ena_com version was generated on 18.09.2020.

---
 drivers/net/ena/base/ena_defs/ena_gen_info.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ena/base/ena_defs/ena_gen_info.h +2 -2
index 54bbfda11f..49895108d5 100644
@@ -2,5 +2,5 @@
  * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates.
  * All rights reserved.
  */
-#define	ENA_GEN_DATE	"Sun Apr 26 13:45:21 DST 2020"
-#define	ENA_GEN_COMMIT	"37aa7c3"
+#define	ENA_GEN_DATE	"Fri Sep 18 17:09:00 IDT 2020"
+#define	ENA_GEN_COMMIT	"0f80d82"
Signature · 1 line
2.25.1
#58 lore raw

PATCH v3 10/22 net/ena/base: use rte_prefetch0_write

In reply to Michal Krawczyk

As in the v20.11 rte_prefetch0_write API was added, it should be used in the platform file for the definition of the macro prefetchw, instead of using simply prefetch0.

---
 drivers/net/ena/base/ena_plat_dpdk.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ena/base/ena_plat_dpdk.h +1 -1
index ad7b07b374..c6103e3721 100644
@@ -290,7 +290,7 @@ extern rte_atomic32_t ena_alloc_cnt;
 #define might_sleep()
 
 #define prefetch(x) rte_prefetch0(x)
-#define prefetchw(x) prefetch(x)
+#define prefetchw(x) rte_prefetch0_write(x)
 
 #define lower_32_bits(x) ((uint32_t)(x))
 #define upper_32_bits(x) ((uint32_t)(((x) >> 16) >> 16))
Signature · 1 line
2.25.1
#59 lore raw

PATCH v3 11/22 net/ena/base: adjust changes to lastest ena-com

In reply to Michal Krawczyk

From: Amit Bernstein <[email protected]>

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

---
 drivers/net/ena/base/ena_plat_dpdk.h | 244 +++++++++++++--------------
 drivers/net/ena/ena_ethdev.c         |   2 +-
 2 files changed, 115 insertions(+), 131 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +114 -130
index c6103e3721..4498d53703 100644
@@ -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,15 +97,15 @@ 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)
@@ -117,51 +119,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)				\
+#define ENA_SPINLOCK_LOCK(spinlock, flags)				       \
 	({(void)flags; rte_spinlock_lock(&spinlock); })
-#define ENA_SPINLOCK_UNLOCK(spinlock, flags)				\
+#define ENA_SPINLOCK_UNLOCK(spinlock, flags)				       \
 	({(void)flags; rte_spinlock_unlock(&(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 */
@@ -173,104 +175,88 @@ 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)
@@ -296,7 +282,7 @@ 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)				\
+#define ENA_GET_SYSTEM_TIMEOUT(timeout_us)				       \
     (timeout_us * rte_get_timer_hz() / 1000000 + rte_get_timer_cycles())
 #define ENA_WAIT_EVENTS_DESTROY(waitqueue) ((void)(waitqueue))
 
@@ -309,14 +295,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))
@@ -329,7 +315,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_ */
drivers/net/ena/ena_ethdev.c +1 -1
index f1ff4dad36..3c9102cd19 100644
@@ -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),
Signature · 1 line
2.25.1
#60 lore raw

PATCH v3 12/22 net/ena: fix parsing of large_llq_hdr argument

In reply to Michal Krawczyk

From: Igor Chauskin <[email protected]>

The code incorrectly checked the return value of comparison when parsing the argument key name. The return value of strcmp should be compared to 0 to identify a match.

Fixes 8a7a73f26cc9 ("net/ena: support large LLQ headers")
---
 drivers/net/ena/ena_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ena/ena_ethdev.c +1 -1
index 3c9102cd19..cb8ad5c3d0 100644
@@ -2865,7 +2865,7 @@ static int ena_process_bool_devarg(const char *key,
 	}
 
 	/* Now, assign it to the proper adapter field. */
-	if (strcmp(key, ENA_DEVARG_LARGE_LLQ_HDR))
+	if (strcmp(key, ENA_DEVARG_LARGE_LLQ_HDR) == 0)
 		adapter->use_large_llq_hdr = bool_value;
 
 	return 0;
Signature · 1 line
2.25.1
#61 lore raw

PATCH v3 13/22 net/ena: terminate devargs allowed keys with NULL

In reply to Michal Krawczyk

As the documentation of rte_kvargs_parse() states, the valid_keys argument must be NULL terminated. Lack of this feature may cause segmentation fault if the passed devarg will be different then the supported value.

Fixes 8a7a73f26cc9 ("net/ena: support large LLQ headers")
---
 drivers/net/ena/ena_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ena/ena_ethdev.c +1 -0
index cb8ad5c3d0..6092288239 100644
@@ -2876,6 +2876,7 @@ static int ena_parse_devargs(struct ena_adapter *adapter,
 {
 	static const char * const allowed_args[] = {
 		ENA_DEVARG_LARGE_LLQ_HDR,
+		NULL,
 	};
 	struct rte_kvargs *kvlist;
 	int rc;
Signature · 1 line
2.25.1
Acked-by on v3 13/22
#62 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v3 13/22] net/ena: terminate devargs allowed keys with NULL

Quoted 21 lines · Michal Krawczyk

As the documentation of rte_kvargs_parse() states, the valid_keys argument must be NULL terminated. Lack of this feature may cause segmentation fault if the passed devarg will be different then the supported value.

Fixes 8a7a73f26cc9 ("net/ena: support large LLQ headers")
---
 drivers/net/ena/ena_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ena/ena_ethdev.c +0 -0
index cb8ad5c3d0..6092288239 100644

drivers/net/ena/ena_ethdev.c static int ena_parse_devargs(struct ena_adapter *adapter, · line 2882

Quoted 7 lines
drivers/net/ena/ena_ethdev.c +1 -0
@@ -2876,6 +2876,7 @@ static int ena_parse_devargs(struct ena_adapter *adapter,
 {
 	static const char * const allowed_args[] = {
 		ENA_DEVARG_LARGE_LLQ_HDR,
+		NULL,
 	};
 	struct rte_kvargs *kvlist;
 	int rc;
#63 lore raw

PATCH v3 14/22 net/ena: indicate Rx RSS hash presence

In reply to Michal Krawczyk

To make it possible to the app to determine if the hash was calculated for the packet or not, the PKT_RX_RSS_HASH should be set in the mbuf's ol_flags.

As the PMD wasn't setting that, the application couldn't check if there is a hash in a proper way.

The hash is valid only if it's UDP or TCP and the IP packet wasn't fragmented.

Fixes e5df9f33db00 ("net/ena: fix passing RSS hash to mbuf")
---
 drivers/net/ena/ena_ethdev.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ena/ena_ethdev.c +7 -2
index 6092288239..5d107775f4 100644
@@ -51,6 +51,8 @@
 
 #define ENA_MIN_RING_DESC	128
 
+#define ENA_PTYPE_HAS_HASH	(RTE_PTYPE_L4_TCP | RTE_PTYPE_L4_UDP)
+
 enum ethtool_stringset {
 	ETH_SS_TEST             = 0,
 	ETH_SS_STATS,
@@ -314,6 +316,11 @@ static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
 		else
 			ol_flags |= PKT_RX_L4_CKSUM_GOOD;
 
+	if (likely((packet_type & ENA_PTYPE_HAS_HASH) && !ena_rx_ctx->frag)) {
+		ol_flags |= PKT_RX_RSS_HASH;
+		mbuf->hash.rss = ena_rx_ctx->hash;
+	}
+
 	mbuf->ol_flags = ol_flags;
 	mbuf->packet_type = packet_type;
 }
@@ -2245,8 +2252,6 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 			++rx_ring->rx_stats.bad_csum;
 		}
 
-		mbuf->hash.rss = ena_rx_ctx.hash;
-
 		rx_pkts[completed] = mbuf;
 		rx_ring->rx_stats.bytes += mbuf->pkt_len;
 	}
Signature · 1 line
2.25.1
#64 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v3 14/22] net/ena: indicate Rx RSS hash presence

Quoted 34 lines · Michal Krawczyk

To make it possible to the app to determine if the hash was calculated for the packet or not, the PKT_RX_RSS_HASH should be set in the mbuf's ol_flags.

As the PMD wasn't setting that, the application couldn't check if there is a hash in a proper way.

The hash is valid only if it's UDP or TCP and the IP packet wasn't fragmented.

Fixes e5df9f33db00 ("net/ena: fix passing RSS hash to mbuf")
---
 drivers/net/ena/ena_ethdev.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ena/ena_ethdev.c +2 -0
index 6092288239..5d107775f4 100644
@@ -51,6 +51,8 @@
 
 #define ENA_MIN_RING_DESC	128
 
+#define ENA_PTYPE_HAS_HASH	(RTE_PTYPE_L4_TCP | RTE_PTYPE_L4_UDP)
+
 enum ethtool_stringset {
 	ETH_SS_TEST             = 0,
 	ETH_SS_STATS,

drivers/net/ena/ena_ethdev.c static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf, · line 322

Quoted 7 lines
drivers/net/ena/ena_ethdev.c +4 -0
@@ -314,6 +316,11 @@ static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
 		else
 			ol_flags |= PKT_RX_L4_CKSUM_GOOD;
 
+	if (likely((packet_type & ENA_PTYPE_HAS_HASH) && !ena_rx_ctx->frag)) {
+		ol_flags |= PKT_RX_RSS_HASH;
+		mbuf->hash.rss = ena_rx_ctx->hash;
+	}

The driver should announce the 'DEV_RX_OFFLOAD_RSS_HASH' offload capability first, and should set 'PKT_RX_RSS_HASH' only if application requests the 'DEV_RX_OFFLOAD_RSS_HASH'.

Normally this is an optimization to not always update the 'mbuf->hash.rss' but wait for explicit request from application for it.

But there is no practical performance gain for some PMDs and they enable it even user does not ask for it [1] (of course if RSS is enabled), if this is same for 'ena' you can do the same.

[1]
https://git.dpdk.org/dpdk/tree/drivers/net/ixgbe/ixgbe_ethdev.c?h=v21.05-rc2#n2384

Quoted 14 lines
drivers/net/ena/ena_ethdev.c +1 -2
+
 	mbuf->ol_flags = ol_flags;
 	mbuf->packet_type = packet_type;
 }
@@ -2245,8 +2252,6 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 			++rx_ring->rx_stats.bad_csum;
 		}
 
-		mbuf->hash.rss = ena_rx_ctx.hash;
-
 		rx_pkts[completed] = mbuf;
 		rx_ring->rx_stats.bytes += mbuf->pkt_len;
 	}
#65 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v3 14/22] net/ena: indicate Rx RSS hash presence

pt., 7 maj 2021 o 18:47 Ferruh Yigit <[email protected]> napisał(a):

Quoted 49 lines · Michal Krawczyk
Quoted 34 lines

To make it possible to the app to determine if the hash was calculated for the packet or not, the PKT_RX_RSS_HASH should be set in the mbuf's ol_flags.

As the PMD wasn't setting that, the application couldn't check if there is a hash in a proper way.

The hash is valid only if it's UDP or TCP and the IP packet wasn't fragmented.

Fixes e5df9f33db00 ("net/ena: fix passing RSS hash to mbuf")
---
 drivers/net/ena/ena_ethdev.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ena/ena_ethdev.c +2 -0
index 6092288239..5d107775f4 100644
@@ -51,6 +51,8 @@
 
 #define ENA_MIN_RING_DESC    128
 
+#define ENA_PTYPE_HAS_HASH   (RTE_PTYPE_L4_TCP | RTE_PTYPE_L4_UDP)
+
 enum ethtool_stringset {
      ETH_SS_TEST             = 0,
      ETH_SS_STATS,

drivers/net/ena/ena_ethdev.c static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf, · line 322

Quoted 7 lines
drivers/net/ena/ena_ethdev.c +4 -0
@@ -314,6 +316,11 @@ static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
              else
                      ol_flags |= PKT_RX_L4_CKSUM_GOOD;
 
+     if (likely((packet_type & ENA_PTYPE_HAS_HASH) && !ena_rx_ctx->frag)) {
+             ol_flags |= PKT_RX_RSS_HASH;
+             mbuf->hash.rss = ena_rx_ctx->hash;
+     }

The driver should announce the 'DEV_RX_OFFLOAD_RSS_HASH' offload capability first, and should set 'PKT_RX_RSS_HASH' only if application requests the 'DEV_RX_OFFLOAD_RSS_HASH'.

Quoted 7 lines

Normally this is an optimization to not always update the 'mbuf->hash.rss' but wait for explicit request from application for it.

But there is no practical performance gain for some PMDs and they enable it even user does not ask for it [1] (of course if RSS is enabled), if this is same for 'ena' you can do the same.

Thanks for the reference - ENA should do the same, I will change that in v4.

Quoted 18 lines

[1]
https://git.dpdk.org/dpdk/tree/drivers/net/ixgbe/ixgbe_ethdev.c?h=v21.05-rc2#n2384

Quoted 14 lines
drivers/net/ena/ena_ethdev.c +1 -2
+
      mbuf->ol_flags = ol_flags;
      mbuf->packet_type = packet_type;
 }
@@ -2245,8 +2252,6 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
                      ++rx_ring->rx_stats.bad_csum;
              }
 
-             mbuf->hash.rss = ena_rx_ctx.hash;
-
              rx_pkts[completed] = mbuf;
              rx_ring->rx_stats.bytes += mbuf->pkt_len;
      }
#66 lore raw

PATCH v3 15/22 net/ena: remove endian swap functions

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

swap*_*_le() functions are not used anywhere and besides there are rte alternatives already present.

Fixes 1173fca25af9 ("ena: add polling-mode driver")
---
 drivers/net/ena/ena_platform.h | 12 ------------
 1 file changed, 12 deletions(-)
drivers/net/ena/ena_platform.h +0 -12
index d3e40e0e9e..748928b2d9 100644
@@ -6,18 +6,6 @@
 #ifndef __ENA_PLATFORM_H__
 #define __ENA_PLATFORM_H__
 
-#define swap16_to_le(x)		(x)
-
-#define swap32_to_le(x)		(x)
-
-#define swap64_to_le(x)		(x)
-
-#define swap16_from_le(x)       (x)
-
-#define swap32_from_le(x)	(x)
-
-#define swap64_from_le(x)	(x)
-
 #define ena_assert_msg(cond, msg)		\
 	do {					\
 		if (unlikely(!(cond))) {	\
Signature · 1 line
2.25.1
#67 lore raw

PATCH v3 16/22 net/ena: handle spurious wakeups in ENA_WAIT_EVENT

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

pthread_cond_timedwait() may spuriously wakeup according to POSIX. Therefore it is required to check whether predicate is actually true before finishing the waiting loop.

---
 drivers/net/ena/base/ena_plat_dpdk.h | 75 +++++++++++++++++-----------
 1 file changed, 47 insertions(+), 28 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +47 -28
index 4498d53703..1d0454bebe 100644
@@ -77,6 +77,14 @@ typedef uint64_t dma_addr_t;
 #define mmiowb rte_io_wmb
 #define __iomem
 
+#ifndef READ_ONCE
+#define READ_ONCE(var) (*((volatile typeof(var) *)(&(var))))
+#endif
+
+#define READ_ONCE8(var) READ_ONCE(var)
+#define READ_ONCE16(var) READ_ONCE(var)
+#define READ_ONCE32(var) READ_ONCE(var)
+
 #define US_PER_S 1000000
 #define ENA_GET_SYSTEM_USECS()						       \
 	(rte_get_timer_cycles() * US_PER_S / rte_get_timer_hz())
@@ -137,40 +145,59 @@ extern int ena_logtype_com;
 	({(void)flags; rte_spinlock_unlock(&(spinlock)); })
 #define ENA_SPINLOCK_DESTROY(spinlock) ((void)spinlock)
 
-#define q_waitqueue_t							       \
-	struct {							       \
-		pthread_cond_t cond;					       \
-		pthread_mutex_t mutex;					       \
-	}
+typedef struct {
+	pthread_cond_t cond;
+	pthread_mutex_t mutex;
+	uint8_t flag;
+} ena_wait_event_t;
 
-#define ena_wait_queue_t q_waitqueue_t
-
-#define ENA_WAIT_EVENT_INIT(waitqueue)					       \
+#define ENA_WAIT_EVENT_INIT(waitevent)					       \
 	do {								       \
-		pthread_mutex_init(&(waitqueue).mutex, NULL);		       \
-		pthread_cond_init(&(waitqueue).cond, NULL);		       \
+		ena_wait_event_t *_we = &(waitevent);			       \
+		pthread_mutex_init(&_we->mutex, NULL);			       \
+		pthread_cond_init(&_we->cond, NULL);			       \
+		_we->flag = 0;						       \
 	} while (0)
 
 #define ENA_WAIT_EVENT_WAIT(waitevent, timeout)				       \
 	do {								       \
+		ena_wait_event_t *_we = &(waitevent);			       \
+		typeof(timeout) _tmo = (timeout);			       \
+		int ret = 0;						       \
 		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_sec = now.tv_sec + _tmo / 1000000UL;		       \
+		timeout_us = _tmo % 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);			       \
+		pthread_mutex_lock(&_we->mutex);			       \
+		while (ret == 0 && !_we->flag) {			       \
+			ret = pthread_cond_timedwait(&_we->cond,	       \
+				&_we->mutex, &wait);			       \
+		}							       \
+		/* Asserts only if not working on ena_wait_event_t */	       \
+		if (unlikely(ret != 0 && ret != ETIMEDOUT))		       \
+			rte_panic("Invalid wait event. pthread ret: %d\n",     \
+				  ret);					       \
+		else if (unlikely(ret == ETIMEDOUT))			       \
+			ena_trc_err(NULL,				       \
+				"Timeout waiting for " #waitevent "\n");       \
+		_we->flag = 0;						       \
+		pthread_mutex_unlock(&_we->mutex);			       \
+	} while (0)
+#define ENA_WAIT_EVENT_SIGNAL(waitevent)				       \
+	do {								       \
+		ena_wait_event_t *_we = &(waitevent);			       \
+		pthread_mutex_lock(&_we->mutex);			       \
+		_we->flag = 1;						       \
+		pthread_cond_signal(&_we->cond);			       \
+		pthread_mutex_unlock(&_we->mutex);			       \
 	} while (0)
-#define ENA_WAIT_EVENT_SIGNAL(waitevent) pthread_cond_signal(&waitevent.cond)
 /* pthread condition doesn't need to be rearmed after usage */
 #define ENA_WAIT_EVENT_CLEAR(...)
-#define ENA_WAIT_EVENT_DESTROY(admin_queue) ((void)(admin_queue))
+#define ENA_WAIT_EVENT_DESTROY(waitevent) ((void)(waitevent))
 
-#define ena_wait_event_t ena_wait_queue_t
 #define ENA_MIGHT_SLEEP()
 
 #define ena_time_t uint64_t
@@ -284,15 +311,7 @@ extern rte_atomic64_t ena_alloc_cnt;
 #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_WAIT_EVENTS_DESTROY(waitqueue) ((void)(waitqueue))
-
-#ifndef READ_ONCE
-#define READ_ONCE(var) (*((volatile typeof(var) *)(&(var))))
-#endif
-
-#define READ_ONCE8(var) READ_ONCE(var)
-#define READ_ONCE16(var) READ_ONCE(var)
-#define READ_ONCE32(var) READ_ONCE(var)
+#define ENA_WAIT_EVENTS_DESTROY(admin_queue) ((void)(admin_queue))
 
 /* The size must be 8 byte align */
 #define ENA_MEMCPY_TO_DEVICE_64(dst, src, size)				       \
Signature · 1 line
2.25.1
#68 lore raw

Re: [dpdk-dev] [PATCH v3 16/22] net/ena: handle spurious wakeups in ENA_WAIT_EVENT

Quoted 78 lines · Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

pthread_cond_timedwait() may spuriously wakeup according to POSIX. Therefore it is required to check whether predicate is actually true before finishing the waiting loop.

---
 drivers/net/ena/base/ena_plat_dpdk.h | 75 +++++++++++++++++-----------
 1 file changed, 47 insertions(+), 28 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +23 -15
index 4498d53703..1d0454bebe 100644
@@ -77,6 +77,14 @@ typedef uint64_t dma_addr_t;
 #define mmiowb rte_io_wmb
 #define __iomem
 
+#ifndef READ_ONCE
+#define READ_ONCE(var) (*((volatile typeof(var) *)(&(var))))
+#endif
+
+#define READ_ONCE8(var) READ_ONCE(var)
+#define READ_ONCE16(var) READ_ONCE(var)
+#define READ_ONCE32(var) READ_ONCE(var)
+
 #define US_PER_S 1000000
 #define ENA_GET_SYSTEM_USECS()						       \
 	(rte_get_timer_cycles() * US_PER_S / rte_get_timer_hz())
@@ -137,40 +145,59 @@ extern int ena_logtype_com;
 	({(void)flags; rte_spinlock_unlock(&(spinlock)); })
 #define ENA_SPINLOCK_DESTROY(spinlock) ((void)spinlock)
 
-#define q_waitqueue_t							       \
-	struct {							       \
-		pthread_cond_t cond;					       \
-		pthread_mutex_t mutex;					       \
-	}
+typedef struct {
+	pthread_cond_t cond;
+	pthread_mutex_t mutex;
+	uint8_t flag;
+} ena_wait_event_t;
 
-#define ena_wait_queue_t q_waitqueue_t
-
-#define ENA_WAIT_EVENT_INIT(waitqueue)					       \
+#define ENA_WAIT_EVENT_INIT(waitevent)					       \
 	do {								       \
-		pthread_mutex_init(&(waitqueue).mutex, NULL);		       \
-		pthread_cond_init(&(waitqueue).cond, NULL);		       \
+		ena_wait_event_t *_we = &(waitevent);			       \
+		pthread_mutex_init(&_we->mutex, NULL);			       \
+		pthread_cond_init(&_we->cond, NULL);			       \
+		_we->flag = 0;						       \
 	} while (0)
 
 #define ENA_WAIT_EVENT_WAIT(waitevent, timeout)				       \
 	do {								       \
+		ena_wait_event_t *_we = &(waitevent);			       \
+		typeof(timeout) _tmo = (timeout);			       \
+		int ret = 0;						       \
 		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_sec = now.tv_sec + _tmo / 1000000UL;		       \
+		timeout_us = _tmo % 1000000UL;				       \
 		wait.tv_nsec = (now.tv_usec + timeout_us) * 1000UL;	       \
-		pthread_mutex_lock(&waitevent.mutex);			       \
-		pthread_cond_timedwait(&waitevent.cond,			       \
-				&waitevent.mutex, &wait);		       \

drivers/net/ena/base/ena_plat_dpdk.h extern int ena_logtype_com; · line 182

Quoted 10 lines
drivers/net/ena/base/ena_plat_dpdk.h +9 -1
-		pthread_mutex_unlock(&waitevent.mutex);			       \
+		pthread_mutex_lock(&_we->mutex);			       \
+		while (ret == 0 && !_we->flag) {			       \
+			ret = pthread_cond_timedwait(&_we->cond,	       \
+				&_we->mutex, &wait);			       \
+		}							       \
+		/* Asserts only if not working on ena_wait_event_t */	       \
+		if (unlikely(ret != 0 && ret != ETIMEDOUT))		       \
+			rte_panic("Invalid wait event. pthread ret: %d\n",     \
+				  ret);		

Drivers are not allowed to call 'rte_panic', please remove it.

Application should decide to exit or not. Maybe application is OK to run without 'ena' device if it has multiple other devices.

			       \
Quoted 42 lines
drivers/net/ena/base/ena_plat_dpdk.h +15 -12
+		else if (unlikely(ret == ETIMEDOUT))			       \
+			ena_trc_err(NULL,				       \
+				"Timeout waiting for " #waitevent "\n");       \
+		_we->flag = 0;						       \
+		pthread_mutex_unlock(&_we->mutex);			       \
+	} while (0)
+#define ENA_WAIT_EVENT_SIGNAL(waitevent)				       \
+	do {								       \
+		ena_wait_event_t *_we = &(waitevent);			       \
+		pthread_mutex_lock(&_we->mutex);			       \
+		_we->flag = 1;						       \
+		pthread_cond_signal(&_we->cond);			       \
+		pthread_mutex_unlock(&_we->mutex);			       \
 	} while (0)
-#define ENA_WAIT_EVENT_SIGNAL(waitevent) pthread_cond_signal(&waitevent.cond)
 /* pthread condition doesn't need to be rearmed after usage */
 #define ENA_WAIT_EVENT_CLEAR(...)
-#define ENA_WAIT_EVENT_DESTROY(admin_queue) ((void)(admin_queue))
+#define ENA_WAIT_EVENT_DESTROY(waitevent) ((void)(waitevent))
 
-#define ena_wait_event_t ena_wait_queue_t
 #define ENA_MIGHT_SLEEP()
 
 #define ena_time_t uint64_t
@@ -284,15 +311,7 @@ extern rte_atomic64_t ena_alloc_cnt;
 #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_WAIT_EVENTS_DESTROY(waitqueue) ((void)(waitqueue))
-
-#ifndef READ_ONCE
-#define READ_ONCE(var) (*((volatile typeof(var) *)(&(var))))
-#endif
-
-#define READ_ONCE8(var) READ_ONCE(var)
-#define READ_ONCE16(var) READ_ONCE(var)
-#define READ_ONCE32(var) READ_ONCE(var)
+#define ENA_WAIT_EVENTS_DESTROY(admin_queue) ((void)(admin_queue))
 
 /* The size must be 8 byte align */
 #define ENA_MEMCPY_TO_DEVICE_64(dst, src, size)				       \
#69 lore raw

PATCH v3 17/22 net/ena: support SMP for mz alloc counter

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

Introduce a memory area for ENA driver shared between all the processes of a same prefix (memzone backed).
Move the memzone allocation counter for ENA_MEM_ALLOC_COHERENT there so that all processes may utilize it.

---
 drivers/net/ena/base/ena_plat_dpdk.h |  6 ++--
 drivers/net/ena/ena_ethdev.c         | 46 +++++++++++++++++++++++++++-
 drivers/net/ena/ena_ethdev.h         |  8 +++++
 3 files changed, 56 insertions(+), 4 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +3 -3
index 1d0454bebe..e17970361a 100644
@@ -209,7 +209,7 @@ typedef struct {
  * Each rte_memzone should have unique name.
  * To satisfy it, count number of allocations and add it to name.
  */
-extern rte_atomic64_t ena_alloc_cnt;
+extern rte_atomic64_t *ena_alloc_cnt;
 
 #define ENA_MEM_ALLOC_COHERENT_ALIGNED(					       \
 	dmadev, size, virt, phys, mem_handle, alignment)		       \
@@ -219,7 +219,7 @@ extern rte_atomic64_t ena_alloc_cnt;
 		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));   \
+				rte_atomic64_add_return(ena_alloc_cnt, 1));    \
 			mz = rte_memzone_reserve_aligned(z_name, size,	       \
 					SOCKET_ID_ANY, RTE_MEMZONE_IOVA_CONTIG,\
 					alignment);			       \
@@ -249,7 +249,7 @@ extern rte_atomic64_t ena_alloc_cnt;
 		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));   \
+				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;				       \
drivers/net/ena/ena_ethdev.c +45 -1

68 lines not on this page · raw message

drivers/net/ena/ena_ethdev.h +8 -0
index ae235897ee..e8858c6118 100644
@@ -207,6 +207,14 @@ struct ena_offloads {
 	bool rx_csum_supported;
 };
 
+/* Holds data shared between all instances of ENA PMD. */
+struct ena_shared_data {
+	/* Each rte_memzone should have unique name.
+	 * To satisfy it, count number of allocation and add it to name.
+	 */
+	rte_atomic64_t mz_alloc_cnt;
+};
+
 /* board specific private data structure */
 struct ena_adapter {
 	/* OS defined structs */
Signature · 1 line
2.25.1
#70 lore raw

Re: [dpdk-dev] [PATCH v3 17/22] net/ena: support SMP for mz alloc counter

Quoted 6 lines · Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

Introduce a memory area for ENA driver shared between all the processes of a same prefix (memzone backed).
Move the memzone allocation counter for ENA_MEM_ALLOC_COHERENT there so that all processes may utilize it.

Device private data is already shared between primary/secondary processes, why not using it, it is already there.

Next patch sharing RSS key using this shared area, can you device private data so all devices can access it.

Quoted 137 lines
---
 drivers/net/ena/base/ena_plat_dpdk.h |  6 ++--
 drivers/net/ena/ena_ethdev.c         | 46 +++++++++++++++++++++++++++-
 drivers/net/ena/ena_ethdev.h         |  8 +++++
 3 files changed, 56 insertions(+), 4 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +3 -3
index 1d0454bebe..e17970361a 100644
@@ -209,7 +209,7 @@ typedef struct {
  * Each rte_memzone should have unique name.
  * To satisfy it, count number of allocations and add it to name.
  */
-extern rte_atomic64_t ena_alloc_cnt;
+extern rte_atomic64_t *ena_alloc_cnt;
 
 #define ENA_MEM_ALLOC_COHERENT_ALIGNED(					       \
 	dmadev, size, virt, phys, mem_handle, alignment)		       \
@@ -219,7 +219,7 @@ extern rte_atomic64_t ena_alloc_cnt;
 		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));   \
+				rte_atomic64_add_return(ena_alloc_cnt, 1));    \
 			mz = rte_memzone_reserve_aligned(z_name, size,	       \
 					SOCKET_ID_ANY, RTE_MEMZONE_IOVA_CONTIG,\
 					alignment);			       \
@@ -249,7 +249,7 @@ extern rte_atomic64_t ena_alloc_cnt;
 		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));   \
+				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;				       \
drivers/net/ena/ena_ethdev.c +45 -1
index 5d107775f4..0780e2fee2 100644
@@ -83,11 +83,15 @@ struct ena_stats {
 /* Device arguments */
 #define ENA_DEVARG_LARGE_LLQ_HDR "large_llq_hdr"
 
+#define ENA_MZ_SHARED_DATA "ena_shared_data"
+
 /*
  * Each rte_memzone should have unique name.
  * To satisfy it, count number of allocation and add it to name.
  */
-rte_atomic64_t ena_alloc_cnt;
+rte_atomic64_t *ena_alloc_cnt;
+
+struct ena_shared_data *ena_shared_data;
 
 static const struct ena_stats ena_stats_global_strings[] = {
 	ENA_STAT_GLOBAL_ENTRY(wd_expired),
@@ -1752,6 +1756,42 @@ static uint32_t ena_calc_max_io_queue_num(struct ena_com_dev *ena_dev,
 	return max_num_io_queues;
 }
 
+static void ena_prepare_shared_data(struct ena_shared_data *shared_data)
+{
+	memset(shared_data, 0, sizeof(*shared_data));
+}
+
+static int ena_shared_data_init(void)
+{
+	const struct rte_memzone *mz;
+
+	if (ena_shared_data != NULL)
+		return 0;
+
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		/* Allocate shared memory. */
+		mz = rte_memzone_reserve(ENA_MZ_SHARED_DATA,
+					 sizeof(*ena_shared_data),
+					 SOCKET_ID_ANY, 0);
+		if (mz == NULL) {
+			PMD_INIT_LOG(CRIT, "Cannot allocate ena shared data");
+			return -rte_errno;
+		}
+		ena_prepare_shared_data(mz->addr);
+	} else {
+		/* Lookup allocated shared memory. */
+		mz = rte_memzone_lookup(ENA_MZ_SHARED_DATA);
+		if (mz == NULL) {
+			PMD_INIT_LOG(CRIT, "Cannot attach ena shared data");
+			return -rte_errno;
+		}
+	}
+	ena_shared_data = mz->addr;
+	/* Setup ENA_MEM memzone name counter. */
+	ena_alloc_cnt = &ena_shared_data->mz_alloc_cnt;
+	return 0;
+}
+
 static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 {
 	struct ena_calc_queue_size_ctx calc_queue_ctx = { 0 };
@@ -1773,6 +1813,10 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	eth_dev->tx_pkt_burst = &eth_ena_xmit_pkts;
 	eth_dev->tx_pkt_prepare = &eth_ena_prep_pkts;
 
+	rc = ena_shared_data_init();
+	if (rc != 0)
+		return rc;
+
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
drivers/net/ena/ena_ethdev.h +8 -0
index ae235897ee..e8858c6118 100644
@@ -207,6 +207,14 @@ struct ena_offloads {
 	bool rx_csum_supported;
 };
 
+/* Holds data shared between all instances of ENA PMD. */
+struct ena_shared_data {
+	/* Each rte_memzone should have unique name.
+	 * To satisfy it, count number of allocation and add it to name.
+	 */
+	rte_atomic64_t mz_alloc_cnt;
+};
+
 /* board specific private data structure */
 struct ena_adapter {
 	/* OS defined structs */
#71 lore raw

Re: [dpdk-dev] [PATCH v3 17/22] net/ena: support SMP for mz alloc counter

Quoted 10 lines · Ferruh Yigit
Quoted 6 lines · Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

Introduce a memory area for ENA driver shared between all the processes of a same prefix (memzone backed).
Move the memzone allocation counter for ENA_MEM_ALLOC_COHERENT there so that all processes may utilize it.

Device private data is already shared between primary/secondary processes, why not using it, it is already there.

Please correct me if I'm wrong, the dev->data->dev_private is a per-device space, whereas the memzone here is used as a shared memory between all ena devices.
More precisely the memzone counter used here is required to wrap some of the base ena code we are calling and may be called from the context of any device. Given that memzone names have to be unique, I need this counter to be unique too.
I believe similar thing is done in mlx5 driver (mlx5_init_shared_data()). If there is a better way to register such a shared segment that is going to be preserved until all processes (primary and secondary) are closed I would be happy to rework this.

Quoted 3 lines

Next patch sharing RSS key using this shared area, can you device private data so all devices can access it.

It is somewhat similar case. The default key there is generated once for all devices and then used in each of them.

Quoted 139 lines
Quoted 138 lines
---
 drivers/net/ena/base/ena_plat_dpdk.h |  6 ++--
 drivers/net/ena/ena_ethdev.c         | 46 +++++++++++++++++++++++++++-
 drivers/net/ena/ena_ethdev.h         |  8 +++++
 3 files changed, 56 insertions(+), 4 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +3 -3
index 1d0454bebe..e17970361a 100644
@@ -209,7 +209,7 @@ typedef struct {
  * Each rte_memzone should have unique name.
  * To satisfy it, count number of allocations and add it to name.
  */
-extern rte_atomic64_t ena_alloc_cnt;
+extern rte_atomic64_t *ena_alloc_cnt;
 
 #define ENA_MEM_ALLOC_COHERENT_ALIGNED(					       \
 	dmadev, size, virt, phys, mem_handle, alignment)		       \
@@ -219,7 +219,7 @@ extern rte_atomic64_t ena_alloc_cnt;
 		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));   \
+				rte_atomic64_add_return(ena_alloc_cnt, 1));    \
 			mz = rte_memzone_reserve_aligned(z_name, size,	       \
 					SOCKET_ID_ANY, RTE_MEMZONE_IOVA_CONTIG,\
 					alignment);			       \
@@ -249,7 +249,7 @@ extern rte_atomic64_t ena_alloc_cnt;
 		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));   \
+				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;				       \
drivers/net/ena/ena_ethdev.c +45 -1
index 5d107775f4..0780e2fee2 100644
@@ -83,11 +83,15 @@ struct ena_stats {
 /* Device arguments */
 #define ENA_DEVARG_LARGE_LLQ_HDR "large_llq_hdr"
 
+#define ENA_MZ_SHARED_DATA "ena_shared_data"
+
 /*
  * Each rte_memzone should have unique name.
  * To satisfy it, count number of allocation and add it to name.
  */
-rte_atomic64_t ena_alloc_cnt;
+rte_atomic64_t *ena_alloc_cnt;
+
+struct ena_shared_data *ena_shared_data;
 
 static const struct ena_stats ena_stats_global_strings[] = {
 	ENA_STAT_GLOBAL_ENTRY(wd_expired),
@@ -1752,6 +1756,42 @@ static uint32_t ena_calc_max_io_queue_num(struct ena_com_dev *ena_dev,
 	return max_num_io_queues;
 }
 
+static void ena_prepare_shared_data(struct ena_shared_data *shared_data)
+{
+	memset(shared_data, 0, sizeof(*shared_data));
+}
+
+static int ena_shared_data_init(void)
+{
+	const struct rte_memzone *mz;
+
+	if (ena_shared_data != NULL)
+		return 0;
+
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		/* Allocate shared memory. */
+		mz = rte_memzone_reserve(ENA_MZ_SHARED_DATA,
+					 sizeof(*ena_shared_data),
+					 SOCKET_ID_ANY, 0);
+		if (mz == NULL) {
+			PMD_INIT_LOG(CRIT, "Cannot allocate ena shared data");
+			return -rte_errno;
+		}
+		ena_prepare_shared_data(mz->addr);
+	} else {
+		/* Lookup allocated shared memory. */
+		mz = rte_memzone_lookup(ENA_MZ_SHARED_DATA);
+		if (mz == NULL) {
+			PMD_INIT_LOG(CRIT, "Cannot attach ena shared data");
+			return -rte_errno;
+		}
+	}
+	ena_shared_data = mz->addr;
+	/* Setup ENA_MEM memzone name counter. */
+	ena_alloc_cnt = &ena_shared_data->mz_alloc_cnt;
+	return 0;
+}
+
 static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 {
 	struct ena_calc_queue_size_ctx calc_queue_ctx = { 0 };
@@ -1773,6 +1813,10 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	eth_dev->tx_pkt_burst = &eth_ena_xmit_pkts;
 	eth_dev->tx_pkt_prepare = &eth_ena_prep_pkts;
 
+	rc = ena_shared_data_init();
+	if (rc != 0)
+		return rc;
+
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
drivers/net/ena/ena_ethdev.h +8 -0
index ae235897ee..e8858c6118 100644
@@ -207,6 +207,14 @@ struct ena_offloads {
 	bool rx_csum_supported;
 };
 
+/* Holds data shared between all instances of ENA PMD. */
+struct ena_shared_data {
+	/* Each rte_memzone should have unique name.
+	 * To satisfy it, count number of allocation and add it to name.
+	 */
+	rte_atomic64_t mz_alloc_cnt;
+};
+
 /* board specific private data structure */
 struct ena_adapter {
 	/* OS defined structs */
Signature · 2 lines
Best Regards,
Stanislaw Kardach
#72 lore raw

Re: [dpdk-dev] [PATCH v3 17/22] net/ena: support SMP for mz alloc counter

Quoted 9 lines · Stanislaw Kardach
Quoted 8 lines · Ferruh Yigit
Quoted 6 lines · Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

Introduce a memory area for ENA driver shared between all the processes of a same prefix (memzone backed).
Move the memzone allocation counter for ENA_MEM_ALLOC_COHERENT there so that all processes may utilize it.

Quoted 5 lines
Quoted 2 lines

Device private data is already shared between primary/secondary processes, why not using it, it is already there.

Please correct me if I'm wrong, the dev->data->dev_private is a per-device space, whereas the memzone here is used as a shared memory between all ena devices.

Yes it is per-device, so instead of keeping the shared are pointer as global variable, it is possible to keep this pointer in the device private area, and initialize per device. This way shared area can be reached by both primary and secondary applications without additional check.
I think this works better to store device related shared data, like RSS key.

But I am not sure about 'ena_alloc_cnt', I am not clear what it is, it looks like intention is to make it accesible from all devices and all processes.

Btw, How this shared memory freed?

Quoted 153 lines

More precisely the memzone counter used here is required to wrap some of the base ena code we are calling and may be called from the context of any device. Given that memzone names have to be unique, I need this counter to be unique too.
I believe similar thing is done in mlx5 driver (mlx5_init_shared_data()). If there is a better way to register such a shared segment that is going to be preserved until all processes (primary and secondary) are closed I would be happy to rework this.

Quoted 3 lines

Next patch sharing RSS key using this shared area, can you device private data so all devices can access it.

It is somewhat similar case. The default key there is generated once for all devices and then used in each of them.

Quoted 139 lines
Quoted 138 lines
---
 drivers/net/ena/base/ena_plat_dpdk.h |  6 ++--
 drivers/net/ena/ena_ethdev.c         | 46 +++++++++++++++++++++++++++-
 drivers/net/ena/ena_ethdev.h         |  8 +++++
 3 files changed, 56 insertions(+), 4 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +3 -3
index 1d0454bebe..e17970361a 100644
@@ -209,7 +209,7 @@ typedef struct {
  * Each rte_memzone should have unique name.
  * To satisfy it, count number of allocations and add it to name.
  */
-extern rte_atomic64_t ena_alloc_cnt;
+extern rte_atomic64_t *ena_alloc_cnt;
 
 #define ENA_MEM_ALLOC_COHERENT_ALIGNED(					       \
 	dmadev, size, virt, phys, mem_handle, alignment)		       \
@@ -219,7 +219,7 @@ extern rte_atomic64_t ena_alloc_cnt;
 		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));   \
+				rte_atomic64_add_return(ena_alloc_cnt, 1));    \
 			mz = rte_memzone_reserve_aligned(z_name, size,	       \
 					SOCKET_ID_ANY, RTE_MEMZONE_IOVA_CONTIG,\
 					alignment);			       \
@@ -249,7 +249,7 @@ extern rte_atomic64_t ena_alloc_cnt;
 		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));   \
+				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;				       \
drivers/net/ena/ena_ethdev.c +45 -1
index 5d107775f4..0780e2fee2 100644
@@ -83,11 +83,15 @@ struct ena_stats {
 /* Device arguments */
 #define ENA_DEVARG_LARGE_LLQ_HDR "large_llq_hdr"
 
+#define ENA_MZ_SHARED_DATA "ena_shared_data"
+
 /*
  * Each rte_memzone should have unique name.
  * To satisfy it, count number of allocation and add it to name.
  */
-rte_atomic64_t ena_alloc_cnt;
+rte_atomic64_t *ena_alloc_cnt;
+
+struct ena_shared_data *ena_shared_data;
 
 static const struct ena_stats ena_stats_global_strings[] = {
 	ENA_STAT_GLOBAL_ENTRY(wd_expired),
@@ -1752,6 +1756,42 @@ static uint32_t ena_calc_max_io_queue_num(struct ena_com_dev *ena_dev,
 	return max_num_io_queues;
 }
 
+static void ena_prepare_shared_data(struct ena_shared_data *shared_data)
+{
+	memset(shared_data, 0, sizeof(*shared_data));
+}
+
+static int ena_shared_data_init(void)
+{
+	const struct rte_memzone *mz;
+
+	if (ena_shared_data != NULL)
+		return 0;
+
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		/* Allocate shared memory. */
+		mz = rte_memzone_reserve(ENA_MZ_SHARED_DATA,
+					 sizeof(*ena_shared_data),
+					 SOCKET_ID_ANY, 0);
+		if (mz == NULL) {
+			PMD_INIT_LOG(CRIT, "Cannot allocate ena shared data");
+			return -rte_errno;
+		}
+		ena_prepare_shared_data(mz->addr);
+	} else {
+		/* Lookup allocated shared memory. */
+		mz = rte_memzone_lookup(ENA_MZ_SHARED_DATA);
+		if (mz == NULL) {
+			PMD_INIT_LOG(CRIT, "Cannot attach ena shared data");
+			return -rte_errno;
+		}
+	}
+	ena_shared_data = mz->addr;
+	/* Setup ENA_MEM memzone name counter. */
+	ena_alloc_cnt = &ena_shared_data->mz_alloc_cnt;
+	return 0;
+}
+
 static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 {
 	struct ena_calc_queue_size_ctx calc_queue_ctx = { 0 };
@@ -1773,6 +1813,10 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	eth_dev->tx_pkt_burst = &eth_ena_xmit_pkts;
 	eth_dev->tx_pkt_prepare = &eth_ena_prep_pkts;
 
+	rc = ena_shared_data_init();
+	if (rc != 0)
+		return rc;
+
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
drivers/net/ena/ena_ethdev.h +8 -0
index ae235897ee..e8858c6118 100644
@@ -207,6 +207,14 @@ struct ena_offloads {
 	bool rx_csum_supported;
 };
 
+/* Holds data shared between all instances of ENA PMD. */
+struct ena_shared_data {
+	/* Each rte_memzone should have unique name.
+	 * To satisfy it, count number of allocation and add it to name.
+	 */
+	rte_atomic64_t mz_alloc_cnt;
+};
+
 /* board specific private data structure */
 struct ena_adapter {
 	/* OS defined structs */
#73 lore raw

Re: [dpdk-dev] [PATCH v3 17/22] net/ena: support SMP for mz alloc counter

Quoted 16 lines · Ferruh Yigit
Quoted 9 lines · Stanislaw Kardach
Quoted 8 lines · Ferruh Yigit
Quoted 6 lines · Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

Introduce a memory area for ENA driver shared between all the processes of a same prefix (memzone backed).
Move the memzone allocation counter for ENA_MEM_ALLOC_COHERENT there so that all processes may utilize it.

Quoted 5 lines
Quoted 2 lines

Device private data is already shared between primary/secondary processes, why not using it, it is already there.

Please correct me if I'm wrong, the dev->data->dev_private is a per-device space, whereas the memzone here is used as a shared memory between all ena devices.

Quoted 8 lines

Yes it is per-device, so instead of keeping the shared are pointer as global variable, it is possible to keep this pointer in the device private area, and initialize per device. This way shared area can be reached by both primary and secondary applications without additional check.
I think this works better to store device related shared data, like RSS key.

But I am not sure about 'ena_alloc_cnt', I am not clear what it is, it looks like intention is to make it accesible from all devices and all processes.

Come to think of it, I think we can completely eliminate this memzone. ena_alloc_cnt is used for unique memzone name generation but same could be achieved with port_id + per_device_counter.
Thanks for the suggestion, we'll re-think this patch.

Quoted 3 lines

Btw, How this shared memory freed?

Since I think we can get by without it, this question becomes academic, though interesting.
Short answer is can't be freed. The reason for that is in multi-process mode the primary process may die while secondaries continue. It means the daemon thread which handles FD passing will die and hence secondaries cannot perform memory alloc/free.
So even using reference count to delay memzone free won't help us if the primary is dead.

Quoted 155 lines
Quoted 154 lines

More precisely the memzone counter used here is required to wrap some of the base ena code we are calling and may be called from the context of any device. Given that memzone names have to be unique, I need this counter to be unique too.
I believe similar thing is done in mlx5 driver (mlx5_init_shared_data()). If there is a better way to register such a shared segment that is going to be preserved until all processes (primary and secondary) are closed I would be happy to rework this.

Quoted 3 lines

Next patch sharing RSS key using this shared area, can you device private data so all devices can access it.

It is somewhat similar case. The default key there is generated once for all devices and then used in each of them.

Quoted 139 lines
Quoted 138 lines
---
 drivers/net/ena/base/ena_plat_dpdk.h |  6 ++--
 drivers/net/ena/ena_ethdev.c         | 46 +++++++++++++++++++++++++++-
 drivers/net/ena/ena_ethdev.h         |  8 +++++
 3 files changed, 56 insertions(+), 4 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +3 -3
index 1d0454bebe..e17970361a 100644
@@ -209,7 +209,7 @@ typedef struct {
  * Each rte_memzone should have unique name.
  * To satisfy it, count number of allocations and add it to name.
  */
-extern rte_atomic64_t ena_alloc_cnt;
+extern rte_atomic64_t *ena_alloc_cnt;
 
 #define ENA_MEM_ALLOC_COHERENT_ALIGNED(					       \
 	dmadev, size, virt, phys, mem_handle, alignment)		       \
@@ -219,7 +219,7 @@ extern rte_atomic64_t ena_alloc_cnt;
 		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));   \
+				rte_atomic64_add_return(ena_alloc_cnt, 1));    \
 			mz = rte_memzone_reserve_aligned(z_name, size,	       \
 					SOCKET_ID_ANY, RTE_MEMZONE_IOVA_CONTIG,\
 					alignment);			       \
@@ -249,7 +249,7 @@ extern rte_atomic64_t ena_alloc_cnt;
 		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));   \
+				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;				       \
drivers/net/ena/ena_ethdev.c +45 -1
index 5d107775f4..0780e2fee2 100644
@@ -83,11 +83,15 @@ struct ena_stats {
 /* Device arguments */
 #define ENA_DEVARG_LARGE_LLQ_HDR "large_llq_hdr"
 
+#define ENA_MZ_SHARED_DATA "ena_shared_data"
+
 /*
  * Each rte_memzone should have unique name.
  * To satisfy it, count number of allocation and add it to name.
  */
-rte_atomic64_t ena_alloc_cnt;
+rte_atomic64_t *ena_alloc_cnt;
+
+struct ena_shared_data *ena_shared_data;
 
 static const struct ena_stats ena_stats_global_strings[] = {
 	ENA_STAT_GLOBAL_ENTRY(wd_expired),
@@ -1752,6 +1756,42 @@ static uint32_t ena_calc_max_io_queue_num(struct ena_com_dev *ena_dev,
 	return max_num_io_queues;
 }
 
+static void ena_prepare_shared_data(struct ena_shared_data *shared_data)
+{
+	memset(shared_data, 0, sizeof(*shared_data));
+}
+
+static int ena_shared_data_init(void)
+{
+	const struct rte_memzone *mz;
+
+	if (ena_shared_data != NULL)
+		return 0;
+
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		/* Allocate shared memory. */
+		mz = rte_memzone_reserve(ENA_MZ_SHARED_DATA,
+					 sizeof(*ena_shared_data),
+					 SOCKET_ID_ANY, 0);
+		if (mz == NULL) {
+			PMD_INIT_LOG(CRIT, "Cannot allocate ena shared data");
+			return -rte_errno;
+		}
+		ena_prepare_shared_data(mz->addr);
+	} else {
+		/* Lookup allocated shared memory. */
+		mz = rte_memzone_lookup(ENA_MZ_SHARED_DATA);
+		if (mz == NULL) {
+			PMD_INIT_LOG(CRIT, "Cannot attach ena shared data");
+			return -rte_errno;
+		}
+	}
+	ena_shared_data = mz->addr;
+	/* Setup ENA_MEM memzone name counter. */
+	ena_alloc_cnt = &ena_shared_data->mz_alloc_cnt;
+	return 0;
+}
+
 static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 {
 	struct ena_calc_queue_size_ctx calc_queue_ctx = { 0 };
@@ -1773,6 +1813,10 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	eth_dev->tx_pkt_burst = &eth_ena_xmit_pkts;
 	eth_dev->tx_pkt_prepare = &eth_ena_prep_pkts;
 
+	rc = ena_shared_data_init();
+	if (rc != 0)
+		return rc;
+
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
 		return 0;
 
drivers/net/ena/ena_ethdev.h +8 -0
index ae235897ee..e8858c6118 100644
@@ -207,6 +207,14 @@ struct ena_offloads {
 	bool rx_csum_supported;
 };
 
+/* Holds data shared between all instances of ENA PMD. */
+struct ena_shared_data {
+	/* Each rte_memzone should have unique name.
+	 * To satisfy it, count number of allocation and add it to name.
+	 */
+	rte_atomic64_t mz_alloc_cnt;
+};
+
 /* board specific private data structure */
 struct ena_adapter {
 	/* OS defined structs */
Signature · 2 lines
Best Regards,
Stanislaw Kardach
#74 lore raw

PATCH v3 18/22 net/ena: move default RSS key to shared mem

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

Make sure the same random generated RSS key is available to all ENA PMD instances in all processes.

---
 drivers/net/ena/ena_ethdev.c | 16 +++++-----------
 drivers/net/ena/ena_ethdev.h |  1 +
 2 files changed, 6 insertions(+), 11 deletions(-)
drivers/net/ena/ena_ethdev.c +5 -11
index 0780e2fee2..5c365e1ab5 100644
@@ -276,19 +276,9 @@ static const struct eth_dev_ops ena_dev_ops = {
 
 void ena_rss_key_fill(void *key, size_t size)
 {
-	static bool key_generated;
-	static uint8_t default_key[ENA_HASH_KEY_SIZE];
-	size_t i;
-
 	RTE_ASSERT(size <= ENA_HASH_KEY_SIZE);
 
-	if (!key_generated) {
-		for (i = 0; i < ENA_HASH_KEY_SIZE; ++i)
-			default_key[i] = rte_rand() & 0xff;
-		key_generated = true;
-	}
-
-	rte_memcpy(key, default_key, size);
+	rte_memcpy(key, ena_shared_data->default_key, size);
 }
 
 static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
@@ -1758,7 +1748,11 @@ static uint32_t ena_calc_max_io_queue_num(struct ena_com_dev *ena_dev,
 
 static void ena_prepare_shared_data(struct ena_shared_data *shared_data)
 {
+	size_t i;
+
 	memset(shared_data, 0, sizeof(*shared_data));
+	for (i = 0; i < ENA_HASH_KEY_SIZE; ++i)
+		shared_data->default_key[i] = rte_rand() & 0xff;
 }
 
 static int ena_shared_data_init(void)
drivers/net/ena/ena_ethdev.h +1 -0
index e8858c6118..1f7383dce0 100644
@@ -209,6 +209,7 @@ struct ena_offloads {
 
 /* Holds data shared between all instances of ENA PMD. */
 struct ena_shared_data {
+	uint8_t default_key[ENA_HASH_KEY_SIZE];
 	/* Each rte_memzone should have unique name.
 	 * To satisfy it, count number of allocation and add it to name.
 	 */
Signature · 1 line
2.25.1
#75 lore raw

Re: [dpdk-dev] [PATCH v3 18/22] net/ena: move default RSS key to shared mem

Quoted 56 lines · Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

Make sure the same random generated RSS key is available to all ENA PMD instances in all processes.

---
 drivers/net/ena/ena_ethdev.c | 16 +++++-----------
 drivers/net/ena/ena_ethdev.h |  1 +
 2 files changed, 6 insertions(+), 11 deletions(-)
drivers/net/ena/ena_ethdev.c +5 -11
index 0780e2fee2..5c365e1ab5 100644
@@ -276,19 +276,9 @@ static const struct eth_dev_ops ena_dev_ops = {
 
 void ena_rss_key_fill(void *key, size_t size)
 {
-	static bool key_generated;
-	static uint8_t default_key[ENA_HASH_KEY_SIZE];
-	size_t i;
-
 	RTE_ASSERT(size <= ENA_HASH_KEY_SIZE);
 
-	if (!key_generated) {
-		for (i = 0; i < ENA_HASH_KEY_SIZE; ++i)
-			default_key[i] = rte_rand() & 0xff;
-		key_generated = true;
-	}
-
-	rte_memcpy(key, default_key, size);
+	rte_memcpy(key, ena_shared_data->default_key, size);
 }
 
 static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
@@ -1758,7 +1748,11 @@ static uint32_t ena_calc_max_io_queue_num(struct ena_com_dev *ena_dev,
 
 static void ena_prepare_shared_data(struct ena_shared_data *shared_data)
 {
+	size_t i;
+
 	memset(shared_data, 0, sizeof(*shared_data));
+	for (i = 0; i < ENA_HASH_KEY_SIZE; ++i)
+		shared_data->default_key[i] = rte_rand() & 0xff;
 }
 
 static int ena_shared_data_init(void)
drivers/net/ena/ena_ethdev.h +0 -0
index e8858c6118..1f7383dce0 100644

drivers/net/ena/ena_ethdev.h struct ena_offloads { · line 212

Quoted 4 lines
drivers/net/ena/ena_ethdev.h +1 -0
@@ -209,6 +209,7 @@ struct ena_offloads {
 
 /* Holds data shared between all instances of ENA PMD. */
 struct ena_shared_data {
+	uint8_t default_key[ENA_HASH_KEY_SIZE];

Given Ferruh's comments on "[PATCH 17/22] net/ena: support SMP for mz alloc counter" it is probably a better idea to have this default key generated per-device and keep it in rte_eth_dev.data. This will allow to eliminate the shared memory segment (freeing issues) and increase entropy for the different devices.

Quoted 6 lines
drivers/net/ena/ena_ethdev.h +0 -0
 	/* Each rte_memzone should have unique name.
 	 * To satisfy it, count number of allocation and add it to name.
 	 */
Signature · 1 line
2.25.1
Signature · 2 lines
Best Regards,
Stanislaw Kardach
#76 lore raw

PATCH v3 19/22 net/ena: make ethdev references smp safe

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

rte_pci_device and rte_eth_dev are process-local structures. Therefore ena_adapter::pdev and ena_adapter::rte_dev cannot be used universally. Switch this to extracting those structures via rte_eth_devices indexing and remove pdev since it's not used outside of init.

---
 drivers/net/ena/ena_ethdev.c | 47 ++++++++++++++++++------------------
 drivers/net/ena/ena_ethdev.h |  5 ++--
 2 files changed, 25 insertions(+), 27 deletions(-)
drivers/net/ena/ena_ethdev.c +23 -24
index 5c365e1ab5..90ea40513a 100644
@@ -168,6 +168,7 @@ static const struct rte_pci_id pci_id_ena_map[] = {
 static struct ena_aenq_handlers aenq_handlers;
 
 static int ena_device_init(struct ena_com_dev *ena_dev,
+			   struct rte_pci_device *pdev,
 			   struct ena_com_dev_get_features_ctx *get_feat_ctx,
 			   bool *wd_state);
 static int ena_dev_configure(struct rte_eth_dev *dev);
@@ -451,11 +452,11 @@ static void ena_config_host_info(struct ena_com_dev *ena_dev)
 }
 
 /* This function calculates the number of xstats based on the current config */
-static unsigned int ena_xstats_calc_num(struct rte_eth_dev *dev)
+static unsigned int ena_xstats_calc_num(struct rte_eth_dev_data *data)
 {
 	return ENA_STATS_ARRAY_GLOBAL + ENA_STATS_ARRAY_ENI +
-		(dev->data->nb_tx_queues * ENA_STATS_ARRAY_TX) +
-		(dev->data->nb_rx_queues * ENA_STATS_ARRAY_RX);
+		(data->nb_tx_queues * ENA_STATS_ARRAY_TX) +
+		(data->nb_rx_queues * ENA_STATS_ARRAY_RX);
 }
 
 static void ena_config_debug_area(struct ena_adapter *adapter)
@@ -463,7 +464,7 @@ static void ena_config_debug_area(struct ena_adapter *adapter)
 	u32 debug_area_size;
 	int rc, ss_count;
 
-	ss_count = ena_xstats_calc_num(adapter->rte_dev);
+	ss_count = ena_xstats_calc_num(adapter->edev_data);
 
 	/* allocate 32 bytes for each string and 64bit for the value */
 	debug_area_size = ss_count * ETH_GSTRING_LEN + sizeof(u64) * ss_count;
@@ -587,7 +588,7 @@ static int ena_rss_reta_update(struct rte_eth_dev *dev,
 	}
 
 	PMD_DRV_LOG(DEBUG, "%s(): RSS configured %d entries  for port %d\n",
-		__func__, reta_size, adapter->rte_dev->data->port_id);
+		__func__, reta_size, dev->data->port_id);
 
 	return 0;
 }
@@ -631,7 +632,7 @@ static int ena_rss_reta_query(struct rte_eth_dev *dev,
 static int ena_rss_init_default(struct ena_adapter *adapter)
 {
 	struct ena_com_dev *ena_dev = &adapter->ena_dev;
-	uint16_t nb_rx_queues = adapter->rte_dev->data->nb_rx_queues;
+	uint16_t nb_rx_queues = adapter->edev_data->nb_rx_queues;
 	int rc, i;
 	u32 val;
 
@@ -669,8 +670,7 @@ static int ena_rss_init_default(struct ena_adapter *adapter)
 		PMD_DRV_LOG(ERR, "Cannot flush the indirect table\n");
 		goto err_fill_indir;
 	}
-	PMD_DRV_LOG(DEBUG, "RSS configured for port %d\n",
-		adapter->rte_dev->data->port_id);
+	PMD_DRV_LOG(DEBUG, "RSS configured for port %d\n", adapter->port_id);
 
 	return 0;
 
@@ -841,10 +841,10 @@ static uint32_t ena_get_mtu_conf(struct ena_adapter *adapter)
 {
 	uint32_t max_frame_len = adapter->max_mtu;
 
-	if (adapter->rte_eth_dev_data->dev_conf.rxmode.offloads &
+	if (adapter->edev_data->dev_conf.rxmode.offloads &
 	    DEV_RX_OFFLOAD_JUMBO_FRAME)
 		max_frame_len =
-			adapter->rte_eth_dev_data->dev_conf.rxmode.max_rx_pkt_len;
+			adapter->edev_data->dev_conf.rxmode.max_rx_pkt_len;
 
 	return max_frame_len;
 }
@@ -1064,8 +1064,8 @@ static int ena_start(struct rte_eth_dev *dev)
 	if (rc)
 		goto err_start_tx;
 
-	if (adapter->rte_dev->data->dev_conf.rxmode.mq_mode &
-	    ETH_MQ_RX_RSS_FLAG && adapter->rte_dev->data->nb_rx_queues > 0) {
+	if (adapter->edev_data->dev_conf.rxmode.mq_mode &
+	    ETH_MQ_RX_RSS_FLAG && adapter->edev_data->nb_rx_queues > 0) {
 		rc = ena_rss_init_default(adapter);
 		if (rc)
 			goto err_rss_init;
@@ -1505,6 +1505,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count)
 }
 
 static int ena_device_init(struct ena_com_dev *ena_dev,
+			   struct rte_pci_device *pdev,
 			   struct ena_com_dev_get_features_ctx *get_feat_ctx,
 			   bool *wd_state)
 {
@@ -1522,9 +1523,7 @@ static int ena_device_init(struct ena_com_dev *ena_dev,
 	/* The PCIe configuration space revision id indicate if mmio reg
 	 * read is disabled.
 	 */
-	readless_supported =
-		!(((struct rte_pci_device *)ena_dev->dmadev)->id.class_id
-			       & ENA_MMIO_DISABLE_REG_READ);
+	readless_supported = !(pdev->id.class_id & ENA_MMIO_DISABLE_REG_READ);
 	ena_com_set_mmio_read_mode(ena_dev, readless_supported);
 
 	/* reset device */
@@ -1634,7 +1633,7 @@ static void ena_timer_wd_callback(__rte_unused struct rte_timer *timer,
 				  void *arg)
 {
 	struct ena_adapter *adapter = arg;
-	struct rte_eth_dev *dev = adapter->rte_dev;
+	struct rte_eth_dev *dev = &rte_eth_devices[adapter->port_id];
 
 	check_for_missing_keep_alive(adapter);
 	check_for_admin_com_state(adapter);
@@ -1819,11 +1818,10 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	memset(adapter, 0, sizeof(struct ena_adapter));
 	ena_dev = &adapter->ena_dev;
 
-	adapter->rte_eth_dev_data = eth_dev->data;
-	adapter->rte_dev = eth_dev;
+	adapter->edev_data = eth_dev->data;
+	adapter->port_id = eth_dev->data->port_id;
 
 	pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
-	adapter->pdev = pci_dev;
 
 	PMD_INIT_LOG(INFO, "Initializing %x:%x:%x.%d",
 		     pci_dev->addr.domain,
@@ -1843,7 +1841,8 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	ena_dev->reg_bar = adapter->regs;
-	ena_dev->dmadev = adapter->pdev;
+	/* This is a dummy pointer for ena_com functions. */
+	ena_dev->dmadev = adapter;
 
 	adapter->id_number = adapters_found;
 
@@ -1857,7 +1856,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	/* device specific initialization routine */
-	rc = ena_device_init(ena_dev, &get_feat_ctx, &wd_state);
+	rc = ena_device_init(ena_dev, pci_dev, &get_feat_ctx, &wd_state);
 	if (rc) {
 		PMD_INIT_LOG(CRIT, "Failed to init ENA device");
 		goto err;
@@ -2716,7 +2715,7 @@ static int ena_xstats_get_names(struct rte_eth_dev *dev,
 				struct rte_eth_xstat_name *xstats_names,
 				unsigned int n)
 {
-	unsigned int xstats_count = ena_xstats_calc_num(dev);
+	unsigned int xstats_count = ena_xstats_calc_num(dev->data);
 	unsigned int stat, i, count = 0;
 
 	if (n < xstats_count || !xstats_names)
@@ -2765,7 +2764,7 @@ static int ena_xstats_get(struct rte_eth_dev *dev,
 			  unsigned int n)
 {
 	struct ena_adapter *adapter = dev->data->dev_private;
-	unsigned int xstats_count = ena_xstats_calc_num(dev);
+	unsigned int xstats_count = ena_xstats_calc_num(dev->data);
 	unsigned int stat, i, count = 0;
 	int stat_offset;
 	void *stats_begin;
@@ -2997,7 +2996,7 @@ static void ena_update_on_link_change(void *adapter_data,
 
 	adapter = adapter_data;
 	aenq_link_desc = (struct ena_admin_aenq_link_change_desc *)aenq_e;
-	eth_dev = adapter->rte_dev;
+	eth_dev = &rte_eth_devices[adapter->port_id];
 
 	status = get_ena_admin_aenq_link_change_desc_link_status(aenq_link_desc);
 	adapter->link_status = status;
drivers/net/ena/ena_ethdev.h +2 -3
index 1f7383dce0..32e92e1d6b 100644
@@ -219,9 +219,8 @@ struct ena_shared_data {
 /* board specific private data structure */
 struct ena_adapter {
 	/* OS defined structs */
-	struct rte_pci_device *pdev;
-	struct rte_eth_dev_data *rte_eth_dev_data;
-	struct rte_eth_dev *rte_dev;
+	struct rte_eth_dev_data *edev_data;
+	int port_id;
 
 	struct ena_com_dev ena_dev __rte_cache_aligned;
 
Signature · 1 line
2.25.1
#77 lore raw

Re: [dpdk-dev] [PATCH v3 19/22] net/ena: make ethdev references smp safe

Quoted 11 lines · Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

rte_pci_device and rte_eth_dev are process-local structures. Therefore ena_adapter::pdev and ena_adapter::rte_dev cannot be used universally. Switch this to extracting those structures via rte_eth_devices indexing and remove pdev since it's not used outside of init.

<...>

drivers/net/ena/ena_ethdev.c static void ena_timer_wd_callback(__rte_unused struct rte_timer *timer, · line 1637

Quoted 7 lines
drivers/net/ena/ena_ethdev.c +1 -1
@@ -1634,7 +1633,7 @@ static void ena_timer_wd_callback(__rte_unused struct rte_timer *timer,
 				  void *arg)
 {
 	struct ena_adapter *adapter = arg;
-	struct rte_eth_dev *dev = adapter->rte_dev;
+	struct rte_eth_dev *dev = &rte_eth_devices[adapter->port_id];
 

I think better to try to avoid using 'rte_eth_devices' global variable as much as possible, although it may not be possible always, but for this case it seems it can be done.

Why not just pass "struct rte_eth_dev" as 'arg', instead of "struct ena_adapter"?

Quoted 54 lines
drivers/net/ena/ena_ethdev.c +7 -7
 	check_for_missing_keep_alive(adapter);
 	check_for_admin_com_state(adapter);
@@ -1819,11 +1818,10 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	memset(adapter, 0, sizeof(struct ena_adapter));
 	ena_dev = &adapter->ena_dev;
 
-	adapter->rte_eth_dev_data = eth_dev->data;
-	adapter->rte_dev = eth_dev;
+	adapter->edev_data = eth_dev->data;
+	adapter->port_id = eth_dev->data->port_id;
 
 	pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
-	adapter->pdev = pci_dev;
 
 	PMD_INIT_LOG(INFO, "Initializing %x:%x:%x.%d",
 		     pci_dev->addr.domain,
@@ -1843,7 +1841,8 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	ena_dev->reg_bar = adapter->regs;
-	ena_dev->dmadev = adapter->pdev;
+	/* This is a dummy pointer for ena_com functions. */
+	ena_dev->dmadev = adapter;
 
 	adapter->id_number = adapters_found;
 
@@ -1857,7 +1856,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	/* device specific initialization routine */
-	rc = ena_device_init(ena_dev, &get_feat_ctx, &wd_state);
+	rc = ena_device_init(ena_dev, pci_dev, &get_feat_ctx, &wd_state);
 	if (rc) {
 		PMD_INIT_LOG(CRIT, "Failed to init ENA device");
 		goto err;
@@ -2716,7 +2715,7 @@ static int ena_xstats_get_names(struct rte_eth_dev *dev,
 				struct rte_eth_xstat_name *xstats_names,
 				unsigned int n)
 {
-	unsigned int xstats_count = ena_xstats_calc_num(dev);
+	unsigned int xstats_count = ena_xstats_calc_num(dev->data);
 	unsigned int stat, i, count = 0;
 
 	if (n < xstats_count || !xstats_names)
@@ -2765,7 +2764,7 @@ static int ena_xstats_get(struct rte_eth_dev *dev,
 			  unsigned int n)
 {
 	struct ena_adapter *adapter = dev->data->dev_private;
-	unsigned int xstats_count = ena_xstats_calc_num(dev);
+	unsigned int xstats_count = ena_xstats_calc_num(dev->data);
 	unsigned int stat, i, count = 0;
 	int stat_offset;
 	void *stats_begin;

drivers/net/ena/ena_ethdev.c static void ena_update_on_link_change(void *adapter_data, · line 3000

Quoted 6 lines
drivers/net/ena/ena_ethdev.c +1 -1
@@ -2997,7 +2996,7 @@ static void ena_update_on_link_change(void *adapter_data,
 
 	adapter = adapter_data;
 	aenq_link_desc = (struct ena_admin_aenq_link_change_desc *)aenq_e;
-	eth_dev = adapter->rte_dev;
+	eth_dev = &rte_eth_devices[adapter->port_id];
 

Similarly, instead of passing "struct ena_adapter" as "void *adapter_data", it can be possible to pass "struct rte_eth_dev", as far as I can that chain has more layers but still possible.

Meanhile, you can use "void *process_private;" field of "struct rte_eth_dev" to keep process private eth_dev data, if you want.

#78 lore raw

Re: [dpdk-dev] [PATCH v3 19/22] net/ena: make ethdev references smp safe

pt., 7 maj 2021 o 18:49 Ferruh Yigit <[email protected]> napisał(a):

Quoted 28 lines · Michal Krawczyk
Quoted 11 lines

From: Stanislaw Kardach <[email protected]>

rte_pci_device and rte_eth_dev are process-local structures. Therefore ena_adapter::pdev and ena_adapter::rte_dev cannot be used universally. Switch this to extracting those structures via rte_eth_devices indexing and remove pdev since it's not used outside of init.

<...>

drivers/net/ena/ena_ethdev.c static void ena_timer_wd_callback(__rte_unused struct rte_timer *timer, · line 1637

Quoted 7 lines
drivers/net/ena/ena_ethdev.c +1 -1
@@ -1634,7 +1633,7 @@ static void ena_timer_wd_callback(__rte_unused struct rte_timer *timer,
                                void *arg)
 {
      struct ena_adapter *adapter = arg;
-     struct rte_eth_dev *dev = adapter->rte_dev;
+     struct rte_eth_dev *dev = &rte_eth_devices[adapter->port_id];
 

I think better to try to avoid using 'rte_eth_devices' global variable as much as possible, although it may not be possible always, but for this case it seems it can be done.

Quoted 1 line

Why not just pass "struct rte_eth_dev" as 'arg', instead of "struct ena_adapter"?

Good suggestion, it will be changed in the v4.

Quoted 56 lines
Quoted 56 lines
drivers/net/ena/ena_ethdev.c +7 -7
      check_for_missing_keep_alive(adapter);
      check_for_admin_com_state(adapter);
@@ -1819,11 +1818,10 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
      memset(adapter, 0, sizeof(struct ena_adapter));
      ena_dev = &adapter->ena_dev;
 
-     adapter->rte_eth_dev_data = eth_dev->data;
-     adapter->rte_dev = eth_dev;
+     adapter->edev_data = eth_dev->data;
+     adapter->port_id = eth_dev->data->port_id;
 
      pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
-     adapter->pdev = pci_dev;
 
      PMD_INIT_LOG(INFO, "Initializing %x:%x:%x.%d",
                   pci_dev->addr.domain,
@@ -1843,7 +1841,8 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
      }
 
      ena_dev->reg_bar = adapter->regs;
-     ena_dev->dmadev = adapter->pdev;
+     /* This is a dummy pointer for ena_com functions. */
+     ena_dev->dmadev = adapter;
 
      adapter->id_number = adapters_found;
 
@@ -1857,7 +1856,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
      }
 
      /* device specific initialization routine */
-     rc = ena_device_init(ena_dev, &get_feat_ctx, &wd_state);
+     rc = ena_device_init(ena_dev, pci_dev, &get_feat_ctx, &wd_state);
      if (rc) {
              PMD_INIT_LOG(CRIT, "Failed to init ENA device");
              goto err;
@@ -2716,7 +2715,7 @@ static int ena_xstats_get_names(struct rte_eth_dev *dev,
                              struct rte_eth_xstat_name *xstats_names,
                              unsigned int n)
 {
-     unsigned int xstats_count = ena_xstats_calc_num(dev);
+     unsigned int xstats_count = ena_xstats_calc_num(dev->data);
      unsigned int stat, i, count = 0;
 
      if (n < xstats_count || !xstats_names)
@@ -2765,7 +2764,7 @@ static int ena_xstats_get(struct rte_eth_dev *dev,
                        unsigned int n)
 {
      struct ena_adapter *adapter = dev->data->dev_private;
-     unsigned int xstats_count = ena_xstats_calc_num(dev);
+     unsigned int xstats_count = ena_xstats_calc_num(dev->data);
      unsigned int stat, i, count = 0;
      int stat_offset;
      void *stats_begin;
@@ -2997,7 +2996,7 @@ static void ena_update_on_link_change(void *adapter_data,
 
Quoted 10 lines

drivers/net/ena/ena_ethdev.c static void ena_update_on_link_change(void *adapter_data, · line 3000

Quoted 5 lines
drivers/net/ena/ena_ethdev.c +1 -1
      adapter = adapter_data;
      aenq_link_desc = (struct ena_admin_aenq_link_change_desc *)aenq_e;
-     eth_dev = adapter->rte_dev;
+     eth_dev = &rte_eth_devices[adapter->port_id];
 

Similarly, instead of passing "struct ena_adapter" as "void *adapter_data", it can be possible to pass "struct rte_eth_dev", as far as I can that chain has more layers but still possible.

Yes, it's being executed directly in the callback associated with the admin interrupt, so as long as the interrupt callbacks are being executed in the same process which registered them (and from what I read in the documentation, it should be so, but please correct me if I'm wrong), the "struct rte_eth_dev" pointer should be valid.

Quoted 4 lines

Meanhile, you can use "void *process_private;" field of "struct rte_eth_dev" to keep process private eth_dev data, if you want.

#79 lore raw

PATCH v3 20/22 net/ena: disable dev_ops not supported in SMP

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

For dev_ops not supported in SMP, either return -EPERM or return without doing anything. In both cases log a warning.

---
 drivers/net/ena/ena_ethdev.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/net/ena/ena_ethdev.c +18 -0
index 90ea40513a..73e99e956a 100644
@@ -529,6 +529,12 @@ ena_dev_reset(struct rte_eth_dev *dev)
 {
 	int rc = 0;
 
+	/* Cannot release memory in secondary process */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		PMD_DRV_LOG(WARNING, "dev_reset not supported in secondary.\n");
+		return -EPERM;
+	}
+
 	ena_destroy_device(dev);
 	rc = eth_ena_dev_init(dev);
 	if (rc)
@@ -1052,6 +1058,12 @@ static int ena_start(struct rte_eth_dev *dev)
 	uint64_t ticks;
 	int rc = 0;
 
+	/* Cannot allocate memory in secondary process */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		PMD_DRV_LOG(WARNING, "dev_start not supported in secondary.\n");
+		return -EPERM;
+	}
+
 	rc = ena_check_valid_conf(adapter);
 	if (rc)
 		return rc;
@@ -1098,6 +1110,12 @@ static int ena_stop(struct rte_eth_dev *dev)
 	struct ena_com_dev *ena_dev = &adapter->ena_dev;
 	int rc;
 
+	/* Cannot free memory in secondary process */
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		PMD_DRV_LOG(WARNING, "dev_stop not supported in secondary.\n");
+		return -EPERM;
+	}
+
 	rte_timer_stop_sync(&adapter->timer_wd);
 	ena_queue_stop_all(dev, ENA_RING_TYPE_TX);
 	ena_queue_stop_all(dev, ENA_RING_TYPE_RX);
Signature · 1 line
2.25.1
#80 lore raw

PATCH v3 21/22 net/ena: report default ring size

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

Remove invalid ring size alignment logic and add default rx and tx port ring sizes to the device info spec.

The logic in lines 1297 and 1371 is invalid. The RTE_ETH_DEV_FALLBACK_RX_RINGSIZE (and the TX counterpart) is a value that rte_eth_rx_queue_setup() will set if dev_info.default_rxportconf.ring_size is 0 and user provided 0 in nb_rx_desc argument. However the current code treats it as a hint for the PMD to change the ring size to internal defaults.

Additionally since the ENA_DEFAULT_RING_SIZE is defined, report it in the device capabilities so that both rte_ethdev code and the user can utilize it for device configuration.

Fixes ea93d37eb49d ("net/ena: add HW queues depth setup")
---
 drivers/net/ena/ena_ethdev.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/ena/ena_ethdev.c +3 -6
index 73e99e956a..c5d8e7d43e 100644
@@ -1294,9 +1294,6 @@ static int ena_tx_queue_setup(struct rte_eth_dev *dev,
 		return -EINVAL;
 	}
 
-	if (nb_desc == RTE_ETH_DEV_FALLBACK_TX_RINGSIZE)
-		nb_desc = adapter->max_tx_ring_size;
-
 	txq->port_id = dev->data->port_id;
 	txq->next_to_clean = 0;
 	txq->next_to_use = 0;
@@ -1368,9 +1365,6 @@ static int ena_rx_queue_setup(struct rte_eth_dev *dev,
 		return ENA_COM_FAULT;
 	}
 
-	if (nb_desc == RTE_ETH_DEV_FALLBACK_RX_RINGSIZE)
-		nb_desc = adapter->max_rx_ring_size;
-
 	if (!rte_is_power_of_2(nb_desc)) {
 		PMD_DRV_LOG(ERR,
 			"Unsupported size of RX queue: %d is not a power of 2.\n",
@@ -2130,6 +2124,9 @@ static int ena_infos_get(struct rte_eth_dev *dev,
 	dev_info->tx_desc_lim.nb_mtu_seg_max = RTE_MIN(ENA_PKT_MAX_BUFS,
 					adapter->max_tx_sgl_size);
 
+	dev_info->default_rxportconf.ring_size = ENA_DEFAULT_RING_SIZE;
+	dev_info->default_txportconf.ring_size = ENA_DEFAULT_RING_SIZE;
+
 	return 0;
 }
 
Signature · 1 line
2.25.1
#81 lore raw

PATCH v3 22/22 net/ena: update version to v2.3.0

In reply to Michal Krawczyk

This version update contains:
* memcpy mapping to the dpdk-optimized version.
* ena_com (HAL) update to the latest version.
* Bug fixes for the large LLQ headers and devargs parsing.
* Mbuf RSS hash presence indication.
* Bug fix for the default ring size.
* Various fixes for SMP mode (although ENA is not fully MP aware, yet).

---
v3:
* Fix typo in the commit log (double "the")

 doc/guides/rel_notes/release_21_05.rst | 13 +++++++++++++
 drivers/net/ena/ena_ethdev.c           |  4 ++--
 2 files changed, 15 insertions(+), 2 deletions(-)
doc/guides/rel_notes/release_21_05.rst +13 -0
index 30dec1c1d1..8cf9afa050 100644
@@ -287,6 +287,19 @@ New Features
   * Added support for crypto adapter forward mode in octeontx2 event and crypto
     device driver.
 
+* **Updated Amazon ENA PMD.**
+
+  The new driver version (v2.3.0) introduces bug fixes and improvements,
+  including:
+
+  * Changed memcpy mapping to the dpdk-optimized version.
+  * Updated ena_com (HAL) to the latest version.
+  * Fixed bugs when requesting large LLQ headers using the devargs.
+  * Added indication of the RSS hash presence in the mbuf.
+  * Fixed bug when the default ring size was set.
+  * Add multiple fixes for the SMP mode (although ENA is not fully MP aware,
+    yet).
+
 
 Removed Items
 -------------
drivers/net/ena/ena_ethdev.c +2 -2
index c5d8e7d43e..e1e086f31e 100644
@@ -27,8 +27,8 @@
 #include <ena_eth_io_defs.h>
 
 #define DRV_MODULE_VER_MAJOR	2
-#define DRV_MODULE_VER_MINOR	2
-#define DRV_MODULE_VER_SUBMINOR	1
+#define DRV_MODULE_VER_MINOR	3
+#define DRV_MODULE_VER_SUBMINOR	0
 
 #define ENA_IO_TXQ_IDX(q)	(2 * (q))
 #define ENA_IO_RXQ_IDX(q)	(2 * (q) + 1)
Signature · 1 line
2.25.1
#82 lore raw

Re: [dpdk-dev] [PATCH v3 22/22] net/ena: update version to v2.3.0

Quoted 8 lines · Michal Krawczyk

This version update contains:
* memcpy mapping to the dpdk-optimized version.
* ena_com (HAL) update to the latest version.
* Bug fixes for the large LLQ headers and devargs parsing.
* Mbuf RSS hash presence indication.
* Bug fix for the default ring size.
* Various fixes for SMP mode (although ENA is not fully MP aware, yet).

There is another patch (09/22) updates "update generation date and commit", not sure what it is but it looks like base code generation date, does it make sense to squash that patch to this one?

Quoted 21 lines

---
v3:
* Fix typo in the commit log (double "the")

 doc/guides/rel_notes/release_21_05.rst | 13 +++++++++++++
 drivers/net/ena/ena_ethdev.c           |  4 ++--
 2 files changed, 15 insertions(+), 2 deletions(-)
doc/guides/rel_notes/release_21_05.rst +4 -0
index 30dec1c1d1..8cf9afa050 100644
@@ -287,6 +287,19 @@ New Features
   * Added support for crypto adapter forward mode in octeontx2 event and crypto
     device driver.
 
+* **Updated Amazon ENA PMD.**
+
+  The new driver version (v2.3.0) introduces bug fixes and improvements,
+  including:

doc/guides/rel_notes/release_21_05.rst New Features · line 303

Quoted 10 lines
doc/guides/rel_notes/release_21_05.rst +9 -0
+
+  * Changed memcpy mapping to the dpdk-optimized version.
+  * Updated ena_com (HAL) to the latest version.
+  * Fixed bugs when requesting large LLQ headers using the devargs.
+  * Added indication of the RSS hash presence in the mbuf.
+  * Fixed bug when the default ring size was set.
+  * Add multiple fixes for the SMP mode (although ENA is not fully MP aware,
+    yet).
+
 

Instead of a separate patch for release updates, can you please distribute the items here to the patch that introduces it?

Quoted 18 lines
doc/guides/rel_notes/release_21_05.rst +0 -0
 Removed Items
 -------------
drivers/net/ena/ena_ethdev.c +2 -2
index c5d8e7d43e..e1e086f31e 100644
@@ -27,8 +27,8 @@
 #include <ena_eth_io_defs.h>
 
 #define DRV_MODULE_VER_MAJOR	2
-#define DRV_MODULE_VER_MINOR	2
-#define DRV_MODULE_VER_SUBMINOR	1
+#define DRV_MODULE_VER_MINOR	3
+#define DRV_MODULE_VER_SUBMINOR	0
 
 #define ENA_IO_TXQ_IDX(q)	(2 * (q))
 #define ENA_IO_RXQ_IDX(q)	(2 * (q) + 1)
#83 lore raw

Re: [dpdk-dev] [PATCH v3 22/22] net/ena: update version to v2.3.0

pt., 7 maj 2021 o 18:50 Ferruh Yigit <[email protected]> napisał(a):

Quoted 11 lines · Michal Krawczyk
Quoted 8 lines

This version update contains:
* memcpy mapping to the dpdk-optimized version.
* ena_com (HAL) update to the latest version.
* Bug fixes for the large LLQ headers and devargs parsing.
* Mbuf RSS hash presence indication.
* Bug fix for the default ring size.
* Various fixes for SMP mode (although ENA is not fully MP aware, yet).

Quoted 4 lines

There is another patch (09/22) updates "update generation date and commit", not sure what it is but it looks like base code generation date, does it make sense to squash that patch to this one?

In general I try to avoid mixing ena_com (HAL) and core driver commits whenever it's possible. But it could make sense to squash them, as they're interconnected. I will change that in the v4.

The 09/22 patch (with the generation date) helps to identify the exact HAL version which is used for the current driver as it may vary depending on the platform and is used for the debugging purposes.

Quoted 54 lines
Quoted 21 lines

---
v3:
* Fix typo in the commit log (double "the")

 doc/guides/rel_notes/release_21_05.rst | 13 +++++++++++++
 drivers/net/ena/ena_ethdev.c           |  4 ++--
 2 files changed, 15 insertions(+), 2 deletions(-)
doc/guides/rel_notes/release_21_05.rst +4 -0
index 30dec1c1d1..8cf9afa050 100644
@@ -287,6 +287,19 @@ New Features
   * Added support for crypto adapter forward mode in octeontx2 event and crypto
     device driver.
 
+* **Updated Amazon ENA PMD.**
+
+  The new driver version (v2.3.0) introduces bug fixes and improvements,
+  including:

doc/guides/rel_notes/release_21_05.rst New Features · line 303

Quoted 10 lines
doc/guides/rel_notes/release_21_05.rst +9 -0
+
+  * Changed memcpy mapping to the dpdk-optimized version.
+  * Updated ena_com (HAL) to the latest version.
+  * Fixed bugs when requesting large LLQ headers using the devargs.
+  * Added indication of the RSS hash presence in the mbuf.
+  * Fixed bug when the default ring size was set.
+  * Add multiple fixes for the SMP mode (although ENA is not fully MP aware,
+    yet).
+
 

Instead of a separate patch for release updates, can you please distribute the items here to the patch that introduces it?

Quoted 18 lines
doc/guides/rel_notes/release_21_05.rst +0 -0
 Removed Items
 -------------
drivers/net/ena/ena_ethdev.c +2 -2
index c5d8e7d43e..e1e086f31e 100644
@@ -27,8 +27,8 @@
 #include <ena_eth_io_defs.h>
 
 #define DRV_MODULE_VER_MAJOR 2
-#define DRV_MODULE_VER_MINOR 2
-#define DRV_MODULE_VER_SUBMINOR      1
+#define DRV_MODULE_VER_MINOR 3
+#define DRV_MODULE_VER_SUBMINOR      0
 
 #define ENA_IO_TXQ_IDX(q)    (2 * (q))
 #define ENA_IO_RXQ_IDX(q)    (2 * (q) + 1)
#84 lore raw
In reply to Michal Krawczyk
Quoted 42 lines · Michal Krawczyk

Hi,

this version updates the driver to version 2.3.0, which fixes multiple bugs, contains part of the work on making the ENA PMD fully MP aware, and also updates HAL to the latest version.

More detailed list of changes:
* memcpy mapping to the dpdk-optimized version.
* ena_com (HAL) update to the latest version.
* Bug fixes for the large LLQ headers and devargs parsing.
* Mbuf RSS hash presence indication.
* Bug fix for the default ring size.
* Various fixes for the SMP mode.

v3:
* Fix build of the PMD with the debug flags enabled.
* Fix typo in the commit log of the version upgrade patch.

v2:
* Fix nested declaration of the rte_memcpy on arm64 architecture.

Amit Bernstein (1):
net/ena/base: adjust changes to lastest ena-com

Igor Chauskin (2):
net/ena: switch memcpy to dpdk-optimized version net/ena: fix parsing of large_llq_hdr argument

Michal Krawczyk (12):
net/ena/base: unify arg names for the functions net/ena/base: add dev arg to the logging macros net/ena/base: typos, style and comments improvements net/ena/base: fix issues from the static code scan net/ena/base: destroy multiple "wait events" net/ena/base: remove indir table from ENA feat ctx net/ena/base: remove mutable RSS from the host info net/ena/base: update generation date and commit net/ena/base: use rte_prefetch0_write net/ena: terminate devargs allowed keys with NULL net/ena: indicate Rx RSS hash presence net/ena: update version to v2.3.0

Quoted 9 lines

Stanislaw Kardach (7):
net/ena: remove endian swap functions net/ena: handle spurious wakeups in ENA_WAIT_EVENT net/ena: support SMP for mz alloc counter net/ena: move default RSS key to shared mem net/ena: make ethdev references smp safe net/ena: disable dev_ops not supported in SMP net/ena: report default ring size

Hi Michal,

There are some checkpatch and check-git-log.sh [1] warnings, can you please check them?

You can see checkpatch warnings from patchwork:
https://patches.dpdk.org/project/dpdk/list/?series=16861
The ones with yellow marker in the warning column.

Additionally I am getting following checkpatch warning, that is not seen in CI:
### net/ena/base: add dev arg to the logging macros

WARNING:UNNECESSARY_MODIFIER: Integer promotion: Using 'h' in '%hu' is unnecessary
#331: FILE: drivers/net/ena/base/ena_com.c:861:

+ ena_trc_err(ena_dev, "Reading reg failed for timeout. expected:
req id[%hu] offset[%hu] actual: req id[%hu] offset[%hu]\n",

                            mmio_read->seq_num,

                            offset,

                            read_resp->req_id,

@@ -854,7 +868,7 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev *ena_dev, u16 offset)

[1]
./devtools/check-git-log.sh -22

#85 lore raw
Quoted 59 lines · Ferruh Yigit
Quoted 42 lines · Michal Krawczyk

Hi,

this version updates the driver to version 2.3.0, which fixes multiple bugs, contains part of the work on making the ENA PMD fully MP aware, and also updates HAL to the latest version.

More detailed list of changes:
* memcpy mapping to the dpdk-optimized version.
* ena_com (HAL) update to the latest version.
* Bug fixes for the large LLQ headers and devargs parsing.
* Mbuf RSS hash presence indication.
* Bug fix for the default ring size.
* Various fixes for the SMP mode.

v3:
* Fix build of the PMD with the debug flags enabled.
* Fix typo in the commit log of the version upgrade patch.

v2:
* Fix nested declaration of the rte_memcpy on arm64 architecture.

Amit Bernstein (1):
net/ena/base: adjust changes to lastest ena-com

Igor Chauskin (2):
net/ena: switch memcpy to dpdk-optimized version net/ena: fix parsing of large_llq_hdr argument

Michal Krawczyk (12):
net/ena/base: unify arg names for the functions net/ena/base: add dev arg to the logging macros net/ena/base: typos, style and comments improvements net/ena/base: fix issues from the static code scan net/ena/base: destroy multiple "wait events" net/ena/base: remove indir table from ENA feat ctx net/ena/base: remove mutable RSS from the host info net/ena/base: update generation date and commit net/ena/base: use rte_prefetch0_write net/ena: terminate devargs allowed keys with NULL net/ena: indicate Rx RSS hash presence net/ena: update version to v2.3.0

Quoted 9 lines

Stanislaw Kardach (7):
net/ena: remove endian swap functions net/ena: handle spurious wakeups in ENA_WAIT_EVENT net/ena: support SMP for mz alloc counter net/ena: move default RSS key to shared mem net/ena: make ethdev references smp safe net/ena: disable dev_ops not supported in SMP net/ena: report default ring size

Hi Michal,

There are some checkpatch and check-git-log.sh [1] warnings, can you please check them?

Quoted 5 lines

You can see checkpatch warnings from patchwork:
https://patches.dpdk.org/project/dpdk/list/?series=16861
The ones with yellow marker in the warning column.

Additionally I am getting following checkpatch warning, that is not seen in CI:

This must be because of the script version difference, cc'e Thomas, David & Aaron for it.

Quoted 24 lines

### net/ena/base: add dev arg to the logging macros

WARNING:UNNECESSARY_MODIFIER: Integer promotion: Using 'h' in '%hu' is unnecessary
#331: FILE: drivers/net/ena/base/ena_com.c:861:

+ ena_trc_err(ena_dev, "Reading reg failed for timeout. expected:
req id[%hu] offset[%hu] actual: req id[%hu] offset[%hu]\n",

                            mmio_read->seq_num,

                            offset,

                            read_resp->req_id,
(quoted diff) +0 -0
@@ -854,7 +868,7 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev
 *ena_dev, u16 offset)
 
 
 

[1]
./devtools/check-git-log.sh -22

#86 lore raw
In reply to Ferruh Yigit

pt., 7 maj 2021 o 16:59 Ferruh Yigit <[email protected]> napisał(a):

Quoted 54 lines · Michal Krawczyk
Quoted 42 lines

Hi,

this version updates the driver to version 2.3.0, which fixes multiple bugs, contains part of the work on making the ENA PMD fully MP aware, and also updates HAL to the latest version.

More detailed list of changes:
* memcpy mapping to the dpdk-optimized version.
* ena_com (HAL) update to the latest version.
* Bug fixes for the large LLQ headers and devargs parsing.
* Mbuf RSS hash presence indication.
* Bug fix for the default ring size.
* Various fixes for the SMP mode.

v3:
* Fix build of the PMD with the debug flags enabled.
* Fix typo in the commit log of the version upgrade patch.

v2:
* Fix nested declaration of the rte_memcpy on arm64 architecture.

Amit Bernstein (1):
net/ena/base: adjust changes to lastest ena-com

Igor Chauskin (2):
net/ena: switch memcpy to dpdk-optimized version net/ena: fix parsing of large_llq_hdr argument

Michal Krawczyk (12):
net/ena/base: unify arg names for the functions net/ena/base: add dev arg to the logging macros net/ena/base: typos, style and comments improvements net/ena/base: fix issues from the static code scan net/ena/base: destroy multiple "wait events" net/ena/base: remove indir table from ENA feat ctx net/ena/base: remove mutable RSS from the host info net/ena/base: update generation date and commit net/ena/base: use rte_prefetch0_write net/ena: terminate devargs allowed keys with NULL net/ena: indicate Rx RSS hash presence net/ena: update version to v2.3.0

Quoted 9 lines

Stanislaw Kardach (7):
net/ena: remove endian swap functions net/ena: handle spurious wakeups in ENA_WAIT_EVENT net/ena: support SMP for mz alloc counter net/ena: move default RSS key to shared mem net/ena: make ethdev references smp safe net/ena: disable dev_ops not supported in SMP net/ena: report default ring size

Quoted 5 lines

Hi Michal,

There are some checkpatch and check-git-log.sh [1] warnings, can you please check them?

Hi Ferruh,

sure, I'll check them all and fix whatever is possible. The problem is with some of the HAL patches, which are just touching some lines on which the checkpatch returns a warning. Many of them aren't related to those patches, so I don't think we should fix them as part of those commits (like the one you listed below, the following patch just adds ena_dev as an extra input argument). Please let me know what you think about that.

Thanks,
Michal

Quoted 29 lines

You can see checkpatch warnings from patchwork:
https://patches.dpdk.org/project/dpdk/list/?series=16861
The ones with yellow marker in the warning column.

Additionally I am getting following checkpatch warning, that is not seen in CI:
### net/ena/base: add dev arg to the logging macros

WARNING:UNNECESSARY_MODIFIER: Integer promotion: Using 'h' in '%hu' is unnecessary
#331: FILE: drivers/net/ena/base/ena_com.c:861:

+ ena_trc_err(ena_dev, "Reading reg failed for timeout. expected:
req id[%hu] offset[%hu] actual: req id[%hu] offset[%hu]\n",

                            mmio_read->seq_num,

                            offset,

                            read_resp->req_id,
(quoted diff) +0 -0
@@ -854,7 +868,7 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev
 *ena_dev, u16 offset)
 
 
 

[1]
./devtools/check-git-log.sh -22

#87 lore raw
Quoted 63 lines · Michał Krawczyk

pt., 7 maj 2021 o 16:59 Ferruh Yigit <[email protected]> napisał(a):

Quoted 54 lines · Michal Krawczyk
Quoted 42 lines

Hi,

this version updates the driver to version 2.3.0, which fixes multiple bugs, contains part of the work on making the ENA PMD fully MP aware, and also updates HAL to the latest version.

More detailed list of changes:
* memcpy mapping to the dpdk-optimized version.
* ena_com (HAL) update to the latest version.
* Bug fixes for the large LLQ headers and devargs parsing.
* Mbuf RSS hash presence indication.
* Bug fix for the default ring size.
* Various fixes for the SMP mode.

v3:
* Fix build of the PMD with the debug flags enabled.
* Fix typo in the commit log of the version upgrade patch.

v2:
* Fix nested declaration of the rte_memcpy on arm64 architecture.

Amit Bernstein (1):
net/ena/base: adjust changes to lastest ena-com

Igor Chauskin (2):
net/ena: switch memcpy to dpdk-optimized version net/ena: fix parsing of large_llq_hdr argument

Michal Krawczyk (12):
net/ena/base: unify arg names for the functions net/ena/base: add dev arg to the logging macros net/ena/base: typos, style and comments improvements net/ena/base: fix issues from the static code scan net/ena/base: destroy multiple "wait events" net/ena/base: remove indir table from ENA feat ctx net/ena/base: remove mutable RSS from the host info net/ena/base: update generation date and commit net/ena/base: use rte_prefetch0_write net/ena: terminate devargs allowed keys with NULL net/ena: indicate Rx RSS hash presence net/ena: update version to v2.3.0

Quoted 9 lines

Stanislaw Kardach (7):
net/ena: remove endian swap functions net/ena: handle spurious wakeups in ENA_WAIT_EVENT net/ena: support SMP for mz alloc counter net/ena: move default RSS key to shared mem net/ena: make ethdev references smp safe net/ena: disable dev_ops not supported in SMP net/ena: report default ring size

Quoted 5 lines

Hi Michal,

There are some checkpatch and check-git-log.sh [1] warnings, can you please check them?

Hi Ferruh,

Quoted 8 lines

sure, I'll check them all and fix whatever is possible. The problem is with some of the HAL patches, which are just touching some lines on which the checkpatch returns a warning. Many of them aren't related to those patches, so I don't think we should fix them as part of those commits (like the one you listed below, the following patch just adds ena_dev as an extra input argument). Please let me know what you think about that.

Hi Michal,

For the new code I think expectation is clear that it should fully comply the coding convention, but for the base code we are more flexible, since it is shared I understand that the small fixes may cause more maintenance cost.

Please try to fix as much as possible, at least please fix the obviously wrong ones and fix the ones like below with best effort.

Thanks,
ferruh

Quoted 32 lines

Thanks,
Michal

Quoted 29 lines

You can see checkpatch warnings from patchwork:
https://patches.dpdk.org/project/dpdk/list/?series=16861
The ones with yellow marker in the warning column.

Additionally I am getting following checkpatch warning, that is not seen in CI:
### net/ena/base: add dev arg to the logging macros

WARNING:UNNECESSARY_MODIFIER: Integer promotion: Using 'h' in '%hu' is unnecessary
#331: FILE: drivers/net/ena/base/ena_com.c:861:

+ ena_trc_err(ena_dev, "Reading reg failed for timeout. expected:
req id[%hu] offset[%hu] actual: req id[%hu] offset[%hu]\n",

                            mmio_read->seq_num,

                            offset,

                            read_resp->req_id,
(quoted diff) +0 -0
@@ -854,7 +868,7 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev
 *ena_dev, u16 offset)
 
 
 

[1]
./devtools/check-git-log.sh -22

#88 lore raw

v4 cover net/ena: update ENA PMD to v2.3.0

Hi,

this version updates the driver to version 2.3.0, which fixes multiple bugs, contains part of the work on making the ENA PMD fully MP aware, and also updates HAL to the latest version.

More detailed list of changes:
* memcpy mapping to the dpdk-optimized version.
* ena_com (HAL) update to the latest version.
* Bug fixes for the large LLQ headers and devargs parsing.
* Mbuf RSS hash presence indication.
* Bug fix for the default ring size.
* Various fixes for the SMP mode.

v4:
* Remove patches adding shared memory for SMP:
- net/ena: move default RSS key to shared mem
- net/ena: support SMP for mz alloc counter
* Move release notes to the related patches.
* Squash HAL version update patch with the same commit for the core driver.
* Change names fo the macros arguments in the "net/ena/base: destroy multiple "wait events" patch.
* Removed call to the rte_panic().
* Squashed ena_com version update with the driver version update.
* Fix multiple checkpatch warnings.
* Fix issues found in the commit logs.

v3:
* Fix build of the PMD with the debug flags enabled.
* Fix typo in the commit log of the version upgrade patch.

v2:
* Fix nested declaration of the rte_memcpy on arm64 architecture.

Amit Bernstein (1):
net/ena/base: adjust changes to lastest ena-com

Igor Chauskin (2):
net/ena: switch memcpy to dpdk-optimized version net/ena: fix parsing of large LLQ header devarg

Michal Krawczyk (11):
net/ena/base: unify arg names for the functions net/ena/base: add dev arg to the logging macros net/ena/base: style and comments improvements net/ena/base: fix issues from the static code scan net/ena/base: destroy multiple "wait events" net/ena/base: remove indir table from ENA feat ctx net/ena/base: remove mutable RSS from the host info net/ena/base: use rte prefetch0 write net/ena: terminate devargs allowed keys with null net/ena: indicate Rx RSS hash presence net/ena: update version to v2.3.0

Stanislaw Kardach (5):
net/ena: remove endian swap functions net/ena: handle spurious wakeups in ENA wait event net/ena: make ethdev references SMP safe net/ena: disable dev ops not supported in SMP net/ena: report default ring size

 doc/guides/rel_notes/release_21_05.rst        |  11 +
 drivers/net/ena/base/ena_com.c                | 379 +++++++++---------
 drivers/net/ena/base/ena_com.h                |  24 +-
 .../net/ena/base/ena_defs/ena_admin_defs.h    |  98 ++---
 drivers/net/ena/base/ena_defs/ena_gen_info.h  |   4 +-
 drivers/net/ena/base/ena_eth_com.c            |  94 +++--
 drivers/net/ena/base/ena_eth_com.h            |  17 +-
 drivers/net/ena/base/ena_plat_dpdk.h          | 337 ++++++++--------
 drivers/net/ena/ena_ethdev.c                  | 124 +++---
 drivers/net/ena/ena_ethdev.h                  |   5 +-
 drivers/net/ena/ena_platform.h                |  12 -
 11 files changed, 600 insertions(+), 505 deletions(-)
Signature · 1 line
2.25.1
#89 lore raw

PATCH v4 1/19 net/ena: switch memcpy to dpdk-optimized version

From: Igor Chauskin <[email protected]>

memcpy is now mapped to rte_memcpy macro on x86 architectures.

Fixes 9ba7981ec992 ("ena: add communication layer for DPDK")

---
v4:
* Add release notes

v2:
* Fix nested declaration of the rte_memcpy on arm64 architecture.

 doc/guides/rel_notes/release_21_05.rst | 7 +++++++
 drivers/net/ena/base/ena_plat_dpdk.h   | 7 ++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_21_05.rst +7 -0
index 30dec1c1d1..eb1107729a 100644
@@ -202,6 +202,13 @@ New Features
 
   Added packed ring support for async vhost.
 
+* **Updated Amazon ENA PMD.**
+
+  The new driver version (v2.3.0) introduces bug fixes and improvements,
+  including:
+
+  * Changed memcpy mapping to the dpdk-optimized version.
+
 * **Added support of multiple data-units in cryptodev API.**
 
   The cryptodev library has been enhanced to allow operations on multiple
drivers/net/ena/base/ena_plat_dpdk.h +6 -1
index a1d749f83f..ae68f860a5 100644
@@ -25,6 +25,7 @@
 #include <rte_spinlock.h>
 
 #include <sys/time.h>
+#include <rte_memcpy.h>
 
 typedef uint64_t u64;
 typedef uint32_t u32;
@@ -62,7 +63,11 @@ typedef uint64_t dma_addr_t;
 #define ENA_UDELAY(x) rte_delay_us_block(x)
 
 #define ENA_TOUCH(x) ((void)(x))
-#define memcpy_toio memcpy
+/* Avoid nested declaration on arm64, as it may define rte_memcpy as memcpy. */
+#if defined(RTE_ARCH_X86)
+#undef memcpy
+#define memcpy rte_memcpy
+#endif
 #define wmb rte_wmb
 #define rmb rte_rmb
 #define mb rte_mb
Signature · 1 line
2.25.1
#90 lore raw

PATCH v4 2/19 net/ena/base: unify arg names for the functions

In reply to Michal Krawczyk

Instead of using 'queue' for struct ena_com_admin_queue and 'dev' for struct ena_com_dev variables, use more descriptive 'admin_queue' and 'ena_dev'.

This also unifies the names of variables of the type struct ena_com_dev in the driver.

---
v4:
* Add release notes

 doc/guides/rel_notes/release_21_05.rst |  1 +
 drivers/net/ena/base/ena_com.c         | 74 +++++++++++++-------------
 drivers/net/ena/base/ena_com.h         |  2 +-
 3 files changed, 39 insertions(+), 38 deletions(-)
doc/guides/rel_notes/release_21_05.rst +1 -0
index eb1107729a..6e4fcde1bc 100644
@@ -208,6 +208,7 @@ New Features
   including:
 
   * Changed memcpy mapping to the dpdk-optimized version.
+  * Updated ena_com (HAL) to the latest version.
 
 * **Added support of multiple data-units in cryptodev API.**
 
drivers/net/ena/base/ena_com.c +37 -37

179 lines not on this page · raw message

drivers/net/ena/base/ena_com.h +1 -1
index 64d8f247cb..e9601b1a8e 100644
@@ -522,7 +522,7 @@ void ena_com_admin_q_comp_intr_handler(struct ena_com_dev *ena_dev);
  * This method goes over the async event notification queue and calls the proper
  * aenq handler.
  */
-void ena_com_aenq_intr_handler(struct ena_com_dev *dev, void *data);
+void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data);
 
 /* ena_com_abort_admin_commands - Abort all the outstanding admin commands.
  * @ena_dev: ENA communication layer struct
Signature · 1 line
2.25.1
#91 lore raw

PATCH v4 3/19 net/ena/base: add dev arg to the logging macros

In reply to Michal Krawczyk

Some platforms may make use of the device argument to make the logs more verbose and specific for the appropriate device.

As it's not used by the ENA DPDK PMD for the logging, the type is just defined, but never used.

It may be reconsidered to change this in the future by adding port ID to the message logs, but as for now the logging behavior won't change.

---
v4:
* Fix checkpatch warning regarding line length.

v3:
* Fix ena_trc_log macro, by adding missing '\' and removing extra ')'.

 drivers/net/ena/base/ena_com.c       | 238 ++++++++++++++-------------
 drivers/net/ena/base/ena_com.h       |  21 +++
 drivers/net/ena/base/ena_eth_com.c   |  78 ++++++---
 drivers/net/ena/base/ena_eth_com.h   |  17 +-
 drivers/net/ena/base/ena_plat_dpdk.h |  45 ++---
 5 files changed, 237 insertions(+), 162 deletions(-)
drivers/net/ena/base/ena_com.c +128 -110
index f7258254a5..9931819bbb 100644
@@ -70,7 +70,7 @@ static int ena_com_mem_addr_set(struct ena_com_dev *ena_dev,
 				       dma_addr_t addr)
 {
 	if ((addr & GENMASK_ULL(ena_dev->dma_addr_bits - 1, 0)) != addr) {
-		ena_trc_err("dma address has more bits that the device supports\n");
+		ena_trc_err(ena_dev, "DMA address has more bits than the device supports\n");
 		return ENA_COM_INVAL;
 	}
 
@@ -82,6 +82,7 @@ static int ena_com_mem_addr_set(struct ena_com_dev *ena_dev,
 
 static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue)
 {
+	struct ena_com_dev *ena_dev = admin_queue->ena_dev;
 	struct ena_com_admin_sq *sq = &admin_queue->sq;
 	u16 size = ADMIN_SQ_SIZE(admin_queue->q_depth);
 
@@ -89,7 +90,7 @@ static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue)
 			       sq->mem_handle);
 
 	if (!sq->entries) {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -104,6 +105,7 @@ static int ena_com_admin_init_sq(struct ena_com_admin_queue *admin_queue)
 
 static int ena_com_admin_init_cq(struct ena_com_admin_queue *admin_queue)
 {
+	struct ena_com_dev *ena_dev = admin_queue->ena_dev;
 	struct ena_com_admin_cq *cq = &admin_queue->cq;
 	u16 size = ADMIN_CQ_SIZE(admin_queue->q_depth);
 
@@ -111,7 +113,7 @@ static int ena_com_admin_init_cq(struct ena_com_admin_queue *admin_queue)
 			       cq->mem_handle);
 
 	if (!cq->entries)  {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -136,7 +138,7 @@ static int ena_com_admin_init_aenq(struct ena_com_dev *ena_dev,
 			aenq->mem_handle);
 
 	if (!aenq->entries) {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -157,7 +159,7 @@ static int ena_com_admin_init_aenq(struct ena_com_dev *ena_dev,
 	ENA_REG_WRITE32(ena_dev->bus, aenq_caps, ena_dev->reg_bar + ENA_REGS_AENQ_CAPS_OFF);
 
 	if (unlikely(!aenq_handlers)) {
-		ena_trc_err("aenq handlers pointer is NULL\n");
+		ena_trc_err(ena_dev, "AENQ handlers pointer is NULL\n");
 		return ENA_COM_INVAL;
 	}
 
@@ -177,18 +179,21 @@ static struct ena_comp_ctx *get_comp_ctxt(struct ena_com_admin_queue *admin_queu
 					  u16 command_id, bool capture)
 {
 	if (unlikely(command_id >= admin_queue->q_depth)) {
-		ena_trc_err("command id is larger than the queue size. cmd_id: %u queue size %d\n",
+		ena_trc_err(admin_queue->ena_dev,
+			    "Command id is larger than the queue size. cmd_id: %u queue size %d\n",
 			    command_id, admin_queue->q_depth);
 		return NULL;
 	}
 
 	if (unlikely(!admin_queue->comp_ctx)) {
-		ena_trc_err("Completion context is NULL\n");
+		ena_trc_err(admin_queue->ena_dev,
+			    "Completion context is NULL\n");
 		return NULL;
 	}
 
 	if (unlikely(admin_queue->comp_ctx[command_id].occupied && capture)) {
-		ena_trc_err("Completion context is occupied\n");
+		ena_trc_err(admin_queue->ena_dev,
+			    "Completion context is occupied\n");
 		return NULL;
 	}
 
@@ -218,7 +223,7 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queu
 	/* In case of queue FULL */
 	cnt = (u16)ATOMIC32_READ(&admin_queue->outstanding_cmds);
 	if (cnt >= admin_queue->q_depth) {
-		ena_trc_dbg("admin queue is full.\n");
+		ena_trc_dbg(admin_queue->ena_dev, "Admin queue is full.\n");
 		admin_queue->stats.out_of_space++;
 		return ERR_PTR(ENA_COM_NO_SPACE);
 	}
@@ -262,13 +267,14 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queu
 
 static int ena_com_init_comp_ctxt(struct ena_com_admin_queue *admin_queue)
 {
+	struct ena_com_dev *ena_dev = admin_queue->ena_dev;
 	size_t size = admin_queue->q_depth * sizeof(struct ena_comp_ctx);
 	struct ena_comp_ctx *comp_ctx;
 	u16 i;
 
 	admin_queue->comp_ctx = ENA_MEM_ALLOC(admin_queue->q_dmadev, size);
 	if (unlikely(!admin_queue->comp_ctx)) {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -341,7 +347,7 @@ static int ena_com_init_io_sq(struct ena_com_dev *ena_dev,
 		}
 
 		if (!io_sq->desc_addr.virt_addr) {
-			ena_trc_err("memory allocation failed\n");
+			ena_trc_err(ena_dev, "Memory allocation failed\n");
 			return ENA_COM_NO_MEM;
 		}
 	}
@@ -366,7 +372,7 @@ static int ena_com_init_io_sq(struct ena_com_dev *ena_dev,
 			io_sq->bounce_buf_ctrl.base_buffer = ENA_MEM_ALLOC(ena_dev->dmadev, size);
 
 		if (!io_sq->bounce_buf_ctrl.base_buffer) {
-			ena_trc_err("bounce buffer memory allocation failed\n");
+			ena_trc_err(ena_dev, "Bounce buffer memory allocation failed\n");
 			return ENA_COM_NO_MEM;
 		}
 
@@ -431,7 +437,7 @@ static int ena_com_init_io_cq(struct ena_com_dev *ena_dev,
 	}
 
 	if (!io_cq->cdesc_addr.virt_addr) {
-		ena_trc_err("memory allocation failed\n");
+		ena_trc_err(ena_dev, "Memory allocation failed\n");
 		return ENA_COM_NO_MEM;
 	}
 
@@ -452,7 +458,8 @@ static void ena_com_handle_single_admin_completion(struct ena_com_admin_queue *a
 
 	comp_ctx = get_comp_ctxt(admin_queue, cmd_id, false);
 	if (unlikely(!comp_ctx)) {
-		ena_trc_err("comp_ctx is NULL. Changing the admin queue running state\n");
+		ena_trc_err(admin_queue->ena_dev,
+			    "comp_ctx is NULL. Changing the admin queue running state\n");
 		admin_queue->running_state = false;
 		return;
 	}
@@ -504,10 +511,12 @@ static void ena_com_handle_admin_completion(struct ena_com_admin_queue *admin_qu
 	admin_queue->stats.completed_cmd += comp_num;
 }
 
-static int ena_com_comp_status_to_errno(u8 comp_status)
+static int ena_com_comp_status_to_errno(struct ena_com_admin_queue *admin_queue,
+					u8 comp_status)
 {
 	if (unlikely(comp_status != 0))
-		ena_trc_err("admin command failed[%u]\n", comp_status);
+		ena_trc_err(admin_queue->ena_dev,
+			    "Admin command failed[%u]\n", comp_status);
 
 	switch (comp_status) {
 	case ENA_ADMIN_SUCCESS:
@@ -554,7 +563,8 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
 			break;
 
 		if (ENA_TIME_EXPIRE(timeout)) {
-			ena_trc_err("Wait for completion (polling) timeout\n");
+			ena_trc_err(admin_queue->ena_dev,
+				    "Wait for completion (polling) timeout\n");
 			/* ENA didn't have any completion */
 			ENA_SPINLOCK_LOCK(admin_queue->q_lock, flags);
 			admin_queue->stats.no_completion++;
@@ -570,7 +580,7 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
 	}
 
 	if (unlikely(comp_ctx->status == ENA_CMD_ABORTED)) {
-		ena_trc_err("Command was aborted\n");
+		ena_trc_err(admin_queue->ena_dev, "Command was aborted\n");
 		ENA_SPINLOCK_LOCK(admin_queue->q_lock, flags);
 		admin_queue->stats.aborted_cmd++;
 		ENA_SPINLOCK_UNLOCK(admin_queue->q_lock, flags);
@@ -579,9 +589,10 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
 	}
 
 	ENA_WARN(comp_ctx->status != ENA_CMD_COMPLETED,
-		 "Invalid comp status %d\n", comp_ctx->status);
+		 admin_queue->ena_dev, "Invalid comp status %d\n",
+		 comp_ctx->status);
 
-	ret = ena_com_comp_status_to_errno(comp_ctx->comp_status);
+	ret = ena_com_comp_status_to_errno(admin_queue, comp_ctx->comp_status);
 err:
 	comp_ctxt_release(admin_queue, comp_ctx);
 	return ret;
@@ -623,7 +634,7 @@ static int ena_com_set_llq(struct ena_com_dev *ena_dev)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to set LLQ configurations: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to set LLQ configurations: %d\n", ret);
 
 	return ret;
 }
@@ -645,7 +656,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 		llq_info->header_location_ctrl =
 			llq_default_cfg->llq_header_location;
 	} else {
-		ena_trc_err("Invalid header location control, supported: 0x%x\n",
+		ena_trc_err(ena_dev, "Invalid header location control, supported: 0x%x\n",
 			    supported_feat);
 		return -EINVAL;
 	}
@@ -660,12 +671,12 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 			} else if (supported_feat & ENA_ADMIN_SINGLE_DESC_PER_ENTRY) {
 				llq_info->desc_stride_ctrl = ENA_ADMIN_SINGLE_DESC_PER_ENTRY;
 			} else {
-				ena_trc_err("Invalid desc_stride_ctrl, supported: 0x%x\n",
+				ena_trc_err(ena_dev, "Invalid desc_stride_ctrl, supported: 0x%x\n",
 					    supported_feat);
 				return -EINVAL;
 			}
 
-			ena_trc_err("Default llq stride ctrl is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
+			ena_trc_err(ena_dev, "Default llq stride ctrl is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
 				    llq_default_cfg->llq_stride_ctrl,
 				    supported_feat,
 				    llq_info->desc_stride_ctrl);
@@ -689,11 +700,12 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 			llq_info->desc_list_entry_size_ctrl = ENA_ADMIN_LIST_ENTRY_SIZE_256B;
 			llq_info->desc_list_entry_size = 256;
 		} else {
-			ena_trc_err("Invalid entry_size_ctrl, supported: 0x%x\n", supported_feat);
+			ena_trc_err(ena_dev, "Invalid entry_size_ctrl, supported: 0x%x\n",
+				    supported_feat);
 			return -EINVAL;
 		}
 
-		ena_trc_err("Default llq ring entry size is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
+		ena_trc_err(ena_dev, "Default llq ring entry size is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
 			    llq_default_cfg->llq_ring_entry_size,
 			    supported_feat,
 			    llq_info->desc_list_entry_size);
@@ -702,7 +714,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 		/* The desc list entry size should be whole multiply of 8
 		 * This requirement comes from __iowrite64_copy()
 		 */
-		ena_trc_err("illegal entry size %d\n",
+		ena_trc_err(ena_dev, "Illegal entry size %d\n",
 			    llq_info->desc_list_entry_size);
 		return -EINVAL;
 	}
@@ -726,12 +738,12 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 		} else if (supported_feat & ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_8) {
 			llq_info->descs_num_before_header = ENA_ADMIN_LLQ_NUM_DESCS_BEFORE_HEADER_8;
 		} else {
-			ena_trc_err("Invalid descs_num_before_header, supported: 0x%x\n",
+			ena_trc_err(ena_dev, "Invalid descs_num_before_header, supported: 0x%x\n",
 				    supported_feat);
 			return -EINVAL;
 		}
 
-		ena_trc_err("Default llq num descs before header is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
+		ena_trc_err(ena_dev, "Default llq num descs before header is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n",
 			    llq_default_cfg->llq_num_decs_before_header,
 			    supported_feat,
 			    llq_info->descs_num_before_header);
@@ -750,7 +762,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev,
 
 	rc = ena_com_set_llq(ena_dev);
 	if (rc)
-		ena_trc_err("Cannot set LLQ configuration: %d\n", rc);
+		ena_trc_err(ena_dev, "Cannot set LLQ configuration: %d\n", rc);
 
 	return rc;
 }
@@ -776,13 +788,15 @@ static int ena_com_wait_and_process_admin_cq_interrupts(struct ena_comp_ctx *com
 		ENA_SPINLOCK_UNLOCK(admin_queue->q_lock, flags);
 
 		if (comp_ctx->status == ENA_CMD_COMPLETED) {
-			ena_trc_err("The ena device sent a completion but the driver didn't receive a MSI-X interrupt (cmd %d), autopolling mode is %s\n",
+			ena_trc_err(admin_queue->ena_dev,
+				    "The ena device sent a completion but the driver didn't receive a MSI-X interrupt (cmd %d), autopolling mode is %s\n",
 				    comp_ctx->cmd_opcode, admin_queue->auto_polling ? "ON" : "OFF");
 			/* Check if fallback to polling is enabled */
 			if (admin_queue->auto_polling)
 				admin_queue->polling = true;
 		} else {
-			ena_trc_err("The ena device didn't send a completion for the admin cmd %d status %d\n",
+			ena_trc_err(admin_queue->ena_dev,
+				    "The ena device didn't send a completion for the admin cmd %d status %d\n",
 				    comp_ctx->cmd_opcode, comp_ctx->status);
 		}
 		/* Check if shifted to polling mode.
@@ -796,7 +810,7 @@ static int ena_com_wait_and_process_admin_cq_interrupts(struct ena_comp_ctx *com
 		}
 	}
 
-	ret = ena_com_comp_status_to_errno(comp_ctx->comp_status);
+	ret = ena_com_comp_status_to_errno(admin_queue, comp_ctx->comp_status);
 err:
 	comp_ctxt_release(admin_queue, comp_ctx);
 	return ret;
@@ -844,7 +858,7 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev *ena_dev, u16 offset)
 	}
 
 	if (unlikely(i == timeout)) {
-		ena_trc_err("reading reg failed for timeout. expected: req id[%hu] offset[%hu] actual: req id[%hu] offset[%hu]\n",
+		ena_trc_err(ena_dev, "Reading reg failed for timeout. expected: req id[%hu] offset[%hu] actual: req id[%hu] offset[%hu]\n",
 			    mmio_read->seq_num,
 			    offset,
 			    read_resp->req_id,
@@ -854,7 +868,7 @@ static u32 ena_com_reg_bar_read32(struct ena_com_dev *ena_dev, u16 offset)
 	}
 
 	if (read_resp->reg_off != offset) {
-		ena_trc_err("Read failure: wrong offset provided\n");
+		ena_trc_err(ena_dev, "Read failure: wrong offset provided\n");
 		ret = ENA_MMIO_READ_TIMEOUT;
 	} else {
 		ret = read_resp->reg_val;
@@ -913,7 +927,7 @@ static int ena_com_destroy_io_sq(struct ena_com_dev *ena_dev,
 					    sizeof(destroy_resp));
 
 	if (unlikely(ret && (ret != ENA_COM_NO_DEVICE)))
-		ena_trc_err("failed to destroy io sq error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to destroy io sq error: %d\n", ret);
 
 	return ret;
 }
@@ -969,7 +983,7 @@ static int wait_for_reset_state(struct ena_com_dev *ena_dev, u32 timeout,
 		val = ena_com_reg_bar_read32(ena_dev, ENA_REGS_DEV_STS_OFF);
 
 		if (unlikely(val == ENA_MMIO_READ_TIMEOUT)) {
-			ena_trc_err("Reg read timeout occurred\n");
+			ena_trc_err(ena_dev, "Reg read timeout occurred\n");
 			return ENA_COM_TIMER_EXPIRED;
 		}
 
@@ -1009,7 +1023,7 @@ static int ena_com_get_feature_ex(struct ena_com_dev *ena_dev,
 	int ret;
 
 	if (!ena_com_check_supported_feature_id(ena_dev, feature_id)) {
-		ena_trc_dbg("Feature %d isn't supported\n", feature_id);
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n", feature_id);
 		return ENA_COM_UNSUPPORTED;
 	}
 
@@ -1028,7 +1042,7 @@ static int ena_com_get_feature_ex(struct ena_com_dev *ena_dev,
 				   &get_cmd.control_buffer.address,
 				   control_buf_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -1045,7 +1059,7 @@ static int ena_com_get_feature_ex(struct ena_com_dev *ena_dev,
 					    sizeof(*get_resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to submit get_feature command %d error: %d\n",
+		ena_trc_err(ena_dev, "Failed to submit get_feature command %d error: %d\n",
 			    feature_id, ret);
 
 	return ret;
@@ -1157,7 +1171,7 @@ static int ena_com_indirect_table_allocate(struct ena_com_dev *ena_dev,
 
 	if ((get_resp.u.ind_table.min_size > log_size) ||
 	    (get_resp.u.ind_table.max_size < log_size)) {
-		ena_trc_err("indirect table size doesn't fit. requested size: %d while min is:%d and max %d\n",
+		ena_trc_err(ena_dev, "Indirect table size doesn't fit. requested size: %d while min is:%d and max %d\n",
 			    1 << log_size,
 			    1 << get_resp.u.ind_table.min_size,
 			    1 << get_resp.u.ind_table.max_size);
@@ -1261,7 +1275,7 @@ static int ena_com_create_io_sq(struct ena_com_dev *ena_dev,
 					   &create_cmd.sq_ba,
 					   io_sq->desc_addr.phys_addr);
 		if (unlikely(ret)) {
-			ena_trc_err("memory address set failed\n");
+			ena_trc_err(ena_dev, "Memory address set failed\n");
 			return ret;
 		}
 	}
@@ -1272,7 +1286,7 @@ static int ena_com_create_io_sq(struct ena_com_dev *ena_dev,
 					    (struct ena_admin_acq_entry *)&cmd_completion,
 					    sizeof(cmd_completion));
 	if (unlikely(ret)) {
-		ena_trc_err("Failed to create IO SQ. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to create IO SQ. error: %d\n", ret);
 		return ret;
 	}
 
@@ -1290,7 +1304,7 @@ static int ena_com_create_io_sq(struct ena_com_dev *ena_dev,
 			cmd_completion.llq_descriptors_offset);
 	}
 
-	ena_trc_dbg("created sq[%u], depth[%u]\n", io_sq->idx, io_sq->q_depth);
+	ena_trc_dbg(ena_dev, "Created sq[%u], depth[%u]\n", io_sq->idx, io_sq->q_depth);
 
 	return ret;
 }
@@ -1324,7 +1338,7 @@ static void ena_com_update_intr_delay_resolution(struct ena_com_dev *ena_dev,
 	u16 prev_intr_delay_resolution = ena_dev->intr_delay_resolution;
 
 	if (unlikely(!intr_delay_resolution)) {
-		ena_trc_err("Illegal intr_delay_resolution provided. Going to use default 1 usec resolution\n");
+		ena_trc_err(ena_dev, "Illegal intr_delay_resolution provided. Going to use default 1 usec resolution\n");
 		intr_delay_resolution = ENA_DEFAULT_INTR_DELAY_RESOLUTION;
 	}
 
@@ -1360,10 +1374,12 @@ int ena_com_execute_admin_command(struct ena_com_admin_queue *admin_queue,
 					    comp, comp_size);
 	if (IS_ERR(comp_ctx)) {
 		if (comp_ctx == ERR_PTR(ENA_COM_NO_DEVICE))
-			ena_trc_dbg("Failed to submit command [%ld]\n",
+			ena_trc_dbg(admin_queue->ena_dev,
+				    "Failed to submit command [%ld]\n",
 				    PTR_ERR(comp_ctx));
 		else
-			ena_trc_err("Failed to submit command [%ld]\n",
+			ena_trc_err(admin_queue->ena_dev,
+				    "Failed to submit command [%ld]\n",
 				    PTR_ERR(comp_ctx));
 
 		return PTR_ERR(comp_ctx);
@@ -1372,11 +1388,11 @@ int ena_com_execute_admin_command(struct ena_com_admin_queue *admin_queue,
 	ret = ena_com_wait_and_process_admin_cq(comp_ctx, admin_queue);
 	if (unlikely(ret)) {
 		if (admin_queue->running_state)
-			ena_trc_err("Failed to process command. ret = %d\n",
-				    ret);
+			ena_trc_err(admin_queue->ena_dev,
+				    "Failed to process command. ret = %d\n", ret);
 		else
-			ena_trc_dbg("Failed to process command. ret = %d\n",
-				    ret);
+			ena_trc_dbg(admin_queue->ena_dev,
+				    "Failed to process command. ret = %d\n", ret);
 	}
 	return ret;
 }
@@ -1405,7 +1421,7 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev,
 				   &create_cmd.cq_ba,
 				   io_cq->cdesc_addr.phys_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -1415,7 +1431,7 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev,
 					    (struct ena_admin_acq_entry *)&cmd_completion,
 					    sizeof(cmd_completion));
 	if (unlikely(ret)) {
-		ena_trc_err("Failed to create IO CQ. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to create IO CQ. error: %d\n", ret);
 		return ret;
 	}
 
@@ -1434,7 +1450,7 @@ int ena_com_create_io_cq(struct ena_com_dev *ena_dev,
 			(u32 __iomem *)((uintptr_t)ena_dev->reg_bar +
 			cmd_completion.numa_node_register_offset);
 
-	ena_trc_dbg("created cq[%u], depth[%u]\n", io_cq->idx, io_cq->q_depth);
+	ena_trc_dbg(ena_dev, "Created cq[%u], depth[%u]\n", io_cq->idx, io_cq->q_depth);
 
 	return ret;
 }
@@ -1444,7 +1460,7 @@ int ena_com_get_io_handlers(struct ena_com_dev *ena_dev, u16 qid,
 			    struct ena_com_io_cq **io_cq)
 {
 	if (qid >= ENA_TOTAL_NUM_QUEUES) {
-		ena_trc_err("Invalid queue number %d but the max is %d\n",
+		ena_trc_err(ena_dev, "Invalid queue number %d but the max is %d\n",
 			    qid, ENA_TOTAL_NUM_QUEUES);
 		return ENA_COM_INVAL;
 	}
@@ -1510,7 +1526,7 @@ int ena_com_destroy_io_cq(struct ena_com_dev *ena_dev,
 					    sizeof(destroy_resp));
 
 	if (unlikely(ret && (ret != ENA_COM_NO_DEVICE)))
-		ena_trc_err("Failed to destroy IO CQ. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to destroy IO CQ. error: %d\n", ret);
 
 	return ret;
 }
@@ -1534,7 +1550,7 @@ void ena_com_admin_aenq_enable(struct ena_com_dev *ena_dev)
 {
 	u16 depth = ena_dev->aenq.q_depth;
 
-	ENA_WARN(ena_dev->aenq.head != depth, "Invalid AENQ state\n");
+	ENA_WARN(ena_dev->aenq.head != depth, ena_dev, "Invalid AENQ state\n");
 
 	/* Init head_db to mark that all entries in the queue
 	 * are initially available
@@ -1552,12 +1568,12 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_dev, u32 groups_flag)
 
 	ret = ena_com_get_feature(ena_dev, &get_resp, ENA_ADMIN_AENQ_CONFIG, 0);
 	if (ret) {
-		ena_trc_info("Can't get aenq configuration\n");
+		ena_trc_info(ena_dev, "Can't get aenq configuration\n");
 		return ret;
 	}
 
 	if ((get_resp.u.aenq.supported_groups & groups_flag) != groups_flag) {
-		ena_trc_warn("Trying to set unsupported aenq events. supported flag: 0x%x asked flag: 0x%x\n",
+		ena_trc_warn(ena_dev, "Trying to set unsupported aenq events. supported flag: 0x%x asked flag: 0x%x\n",
 			     get_resp.u.aenq.supported_groups,
 			     groups_flag);
 		return ENA_COM_UNSUPPORTED;
@@ -1578,7 +1594,7 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_dev, u32 groups_flag)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to config AENQ ret: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to config AENQ ret: %d\n", ret);
 
 	return ret;
 }
@@ -1589,17 +1605,17 @@ int ena_com_get_dma_width(struct ena_com_dev *ena_dev)
 	int width;
 
 	if (unlikely(caps == ENA_MMIO_READ_TIMEOUT)) {
-		ena_trc_err("Reg read timeout occurred\n");
+		ena_trc_err(ena_dev, "Reg read timeout occurred\n");
 		return ENA_COM_TIMER_EXPIRED;
 	}
 
 	width = (caps & ENA_REGS_CAPS_DMA_ADDR_WIDTH_MASK) >>
 		ENA_REGS_CAPS_DMA_ADDR_WIDTH_SHIFT;
 
-	ena_trc_dbg("ENA dma width: %d\n", width);
+	ena_trc_dbg(ena_dev, "ENA dma width: %d\n", width);
 
 	if ((width < 32) || width > ENA_MAX_PHYS_ADDR_SIZE_BITS) {
-		ena_trc_err("DMA width illegal value: %d\n", width);
+		ena_trc_err(ena_dev, "DMA width illegal value: %d\n", width);
 		return ENA_COM_INVAL;
 	}
 
@@ -1623,16 +1639,16 @@ int ena_com_validate_version(struct ena_com_dev *ena_dev)
 
 	if (unlikely((ver == ENA_MMIO_READ_TIMEOUT) ||
 		     (ctrl_ver == ENA_MMIO_READ_TIMEOUT))) {
-		ena_trc_err("Reg read timeout occurred\n");
+		ena_trc_err(ena_dev, "Reg read timeout occurred\n");
 		return ENA_COM_TIMER_EXPIRED;
 	}
 
-	ena_trc_info("ena device version: %d.%d\n",
+	ena_trc_info(ena_dev, "ENA device version: %d.%d\n",
 		     (ver & ENA_REGS_VERSION_MAJOR_VERSION_MASK) >>
 		     ENA_REGS_VERSION_MAJOR_VERSION_SHIFT,
 		     ver & ENA_REGS_VERSION_MINOR_VERSION_MASK);
 
-	ena_trc_info("ena controller version: %d.%d.%d implementation version %d\n",
+	ena_trc_info(ena_dev, "ENA controller version: %d.%d.%d implementation version %d\n",
 		     (ctrl_ver & ENA_REGS_CONTROLLER_VERSION_MAJOR_VERSION_MASK)
 		     >> ENA_REGS_CONTROLLER_VERSION_MAJOR_VERSION_SHIFT,
 		     (ctrl_ver & ENA_REGS_CONTROLLER_VERSION_MINOR_VERSION_MASK)
@@ -1648,7 +1664,7 @@ int ena_com_validate_version(struct ena_com_dev *ena_dev)
 
 	/* Validate the ctrl version without the implementation ID */
 	if (ctrl_ver_masked < MIN_ENA_CTRL_VER) {
-		ena_trc_err("ENA ctrl version is lower than the minimal ctrl version the driver supports\n");
+		ena_trc_err(ena_dev, "ENA ctrl version is lower than the minimal ctrl version the driver supports\n");
 		return -1;
 	}
 
@@ -1786,12 +1802,12 @@ int ena_com_admin_init(struct ena_com_dev *ena_dev,
 	dev_sts = ena_com_reg_bar_read32(ena_dev, ENA_REGS_DEV_STS_OFF);
 
 	if (unlikely(dev_sts == ENA_MMIO_READ_TIMEOUT)) {
-		ena_trc_err("Reg read timeout occurred\n");
+		ena_trc_err(ena_dev, "Reg read timeout occurred\n");
 		return ENA_COM_TIMER_EXPIRED;
 	}
 
 	if (!(dev_sts & ENA_REGS_DEV_STS_READY_MASK)) {
-		ena_trc_err("Device isn't ready, abort com init\n");
+		ena_trc_err(ena_dev, "Device isn't ready, abort com init\n");
 		return ENA_COM_NO_DEVICE;
 	}
 
@@ -1869,7 +1885,7 @@ int ena_com_create_io_queue(struct ena_com_dev *ena_dev,
 	int ret;
 
 	if (ctx->qid >= ENA_TOTAL_NUM_QUEUES) {
-		ena_trc_err("Qid (%d) is bigger than max num of queues (%d)\n",
+		ena_trc_err(ena_dev, "Qid (%d) is bigger than max num of queues (%d)\n",
 			    ctx->qid, ENA_TOTAL_NUM_QUEUES);
 		return ENA_COM_INVAL;
 	}
@@ -1928,7 +1944,7 @@ void ena_com_destroy_io_queue(struct ena_com_dev *ena_dev, u16 qid)
 	struct ena_com_io_cq *io_cq;
 
 	if (qid >= ENA_TOTAL_NUM_QUEUES) {
-		ena_trc_err("Qid (%d) is bigger than max num of queues (%d)\n",
+		ena_trc_err(ena_dev, "Qid (%d) is bigger than max num of queues (%d)\n",
 			    qid, ENA_TOTAL_NUM_QUEUES);
 		return;
 	}
@@ -2090,7 +2106,7 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data)
 		timestamp = (u64)aenq_common->timestamp_low |
 			((u64)aenq_common->timestamp_high << 32);
 		ENA_TOUCH(timestamp); /* In case debug is disabled */
-		ena_trc_dbg("AENQ! Group[%x] Syndrom[%x] timestamp: [%" ENA_PRIu64 "s]\n",
+		ena_trc_dbg(ena_dev, "AENQ! Group[%x] Syndrom[%x] timestamp: [%" ENA_PRIu64 "s]\n",
 			    aenq_common->group,
 			    aenq_common->syndrom,
 			    timestamp);
@@ -2137,19 +2153,19 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev,
 
 	if (unlikely((stat == ENA_MMIO_READ_TIMEOUT) ||
 		     (cap == ENA_MMIO_READ_TIMEOUT))) {
-		ena_trc_err("Reg read32 timeout occurred\n");
+		ena_trc_err(ena_dev, "Reg read32 timeout occurred\n");
 		return ENA_COM_TIMER_EXPIRED;
 	}
 
 	if ((stat & ENA_REGS_DEV_STS_READY_MASK) == 0) {
-		ena_trc_err("Device isn't ready, can't reset device\n");
+		ena_trc_err(ena_dev, "Device isn't ready, can't reset device\n");
 		return ENA_COM_INVAL;
 	}
 
 	timeout = (cap & ENA_REGS_CAPS_RESET_TIMEOUT_MASK) >>
 			ENA_REGS_CAPS_RESET_TIMEOUT_SHIFT;
 	if (timeout == 0) {
-		ena_trc_err("Invalid timeout value\n");
+		ena_trc_err(ena_dev, "Invalid timeout value\n");
 		return ENA_COM_INVAL;
 	}
 
@@ -2165,7 +2181,7 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev,
 	rc = wait_for_reset_state(ena_dev, timeout,
 				  ENA_REGS_DEV_STS_RESET_IN_PROGRESS_MASK);
 	if (rc != 0) {
-		ena_trc_err("Reset indication didn't turn on\n");
+		ena_trc_err(ena_dev, "Reset indication didn't turn on\n");
 		return rc;
 	}
 
@@ -2173,7 +2189,7 @@ int ena_com_dev_reset(struct ena_com_dev *ena_dev,
 	ENA_REG_WRITE32(ena_dev->bus, 0, ena_dev->reg_bar + ENA_REGS_DEV_CTL_OFF);
 	rc = wait_for_reset_state(ena_dev, timeout, 0);
 	if (rc != 0) {
-		ena_trc_err("Reset indication didn't turn off\n");
+		ena_trc_err(ena_dev, "Reset indication didn't turn off\n");
 		return rc;
 	}
 
@@ -2210,7 +2226,7 @@ static int ena_get_dev_stats(struct ena_com_dev *ena_dev,
 					     sizeof(*get_resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to get stats. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to get stats. error: %d\n", ret);
 
 	return ret;
 }
@@ -2253,7 +2269,7 @@ int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu)
 	int ret;
 
 	if (!ena_com_check_supported_feature_id(ena_dev, ENA_ADMIN_MTU)) {
-		ena_trc_dbg("Feature %d isn't supported\n", ENA_ADMIN_MTU);
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n", ENA_ADMIN_MTU);
 		return ENA_COM_UNSUPPORTED;
 	}
 
@@ -2272,7 +2288,7 @@ int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to set mtu %d. error: %d\n", mtu, ret);
+		ena_trc_err(ena_dev, "Failed to set mtu %d. error: %d\n", mtu, ret);
 
 	return ret;
 }
@@ -2286,7 +2302,7 @@ int ena_com_get_offload_settings(struct ena_com_dev *ena_dev,
 	ret = ena_com_get_feature(ena_dev, &resp,
 				  ENA_ADMIN_STATELESS_OFFLOAD_CONFIG, 0);
 	if (unlikely(ret)) {
-		ena_trc_err("Failed to get offload capabilities %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to get offload capabilities %d\n", ret);
 		return ret;
 	}
 
@@ -2306,7 +2322,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
 
 	if (!ena_com_check_supported_feature_id(ena_dev,
 						ENA_ADMIN_RSS_HASH_FUNCTION)) {
-		ena_trc_dbg("Feature %d isn't supported\n",
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
 			    ENA_ADMIN_RSS_HASH_FUNCTION);
 		return ENA_COM_UNSUPPORTED;
 	}
@@ -2318,7 +2334,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
 		return ret;
 
 	if (!(get_resp.u.flow_hash_func.supported_func & BIT(rss->hash_func))) {
-		ena_trc_err("Func hash %d isn't supported by device, abort\n",
+		ena_trc_err(ena_dev, "Func hash %d isn't supported by device, abort\n",
 			    rss->hash_func);
 		return ENA_COM_UNSUPPORTED;
 	}
@@ -2336,7 +2352,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
 				   &cmd.control_buffer.address,
 				   rss->hash_key_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -2348,7 +2364,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev)
 					    (struct ena_admin_acq_entry *)&resp,
 					    sizeof(resp));
 	if (unlikely(ret)) {
-		ena_trc_err("Failed to set hash function %d. error: %d\n",
+		ena_trc_err(ena_dev, "Failed to set hash function %d. error: %d\n",
 			    rss->hash_func, ret);
 		return ENA_COM_INVAL;
 	}
@@ -2380,7 +2396,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
 		return rc;
 
 	if (!(BIT(func) & get_resp.u.flow_hash_func.supported_func)) {
-		ena_trc_err("Flow hash function %d isn't supported\n", func);
+		ena_trc_err(ena_dev, "Flow hash function %d isn't supported\n", func);
 		return ENA_COM_UNSUPPORTED;
 	}
 
@@ -2388,7 +2404,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
 	case ENA_ADMIN_TOEPLITZ:
 		if (key) {
 			if (key_len != sizeof(hash_key->key)) {
-				ena_trc_err("key len (%hu) doesn't equal the supported size (%zu)\n",
+				ena_trc_err(ena_dev, "key len (%hu) doesn't equal the supported size (%zu)\n",
 					     key_len, sizeof(hash_key->key));
 				return ENA_COM_INVAL;
 			}
@@ -2401,7 +2417,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
 		rss->hash_init_val = init_val;
 		break;
 	default:
-		ena_trc_err("Invalid hash function (%d)\n", func);
+		ena_trc_err(ena_dev, "Invalid hash function (%d)\n", func);
 		return ENA_COM_INVAL;
 	}
 
@@ -2486,7 +2502,7 @@ int ena_com_set_hash_ctrl(struct ena_com_dev *ena_dev)
 
 	if (!ena_com_check_supported_feature_id(ena_dev,
 						ENA_ADMIN_RSS_HASH_INPUT)) {
-		ena_trc_dbg("Feature %d isn't supported\n",
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
 			    ENA_ADMIN_RSS_HASH_INPUT);
 		return ENA_COM_UNSUPPORTED;
 	}
@@ -2505,7 +2521,7 @@ int ena_com_set_hash_ctrl(struct ena_com_dev *ena_dev)
 				   &cmd.control_buffer.address,
 				   rss->hash_ctrl_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 	cmd.control_buffer.length = sizeof(*hash_ctrl);
@@ -2516,7 +2532,7 @@ int ena_com_set_hash_ctrl(struct ena_com_dev *ena_dev)
 					    (struct ena_admin_acq_entry *)&resp,
 					    sizeof(resp));
 	if (unlikely(ret))
-		ena_trc_err("Failed to set hash input. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to set hash input. error: %d\n", ret);
 
 	return ret;
 }
@@ -2566,7 +2582,7 @@ int ena_com_set_default_hash_ctrl(struct ena_com_dev *ena_dev)
 		available_fields = hash_ctrl->selected_fields[i].fields &
 				hash_ctrl->supported_fields[i].fields;
 		if (available_fields != hash_ctrl->selected_fields[i].fields) {
-			ena_trc_err("hash control doesn't support all the desire configuration. proto %x supported %x selected %x\n",
+			ena_trc_err(ena_dev, "Hash control doesn't support all the desire configuration. proto %x supported %x selected %x\n",
 				    i, hash_ctrl->supported_fields[i].fields,
 				    hash_ctrl->selected_fields[i].fields);
 			return ENA_COM_UNSUPPORTED;
@@ -2592,7 +2608,7 @@ int ena_com_fill_hash_ctrl(struct ena_com_dev *ena_dev,
 	int rc;
 
 	if (proto >= ENA_ADMIN_RSS_PROTO_NUM) {
-		ena_trc_err("Invalid proto num (%u)\n", proto);
+		ena_trc_err(ena_dev, "Invalid proto num (%u)\n", proto);
 		return ENA_COM_INVAL;
 	}
 
@@ -2604,7 +2620,7 @@ int ena_com_fill_hash_ctrl(struct ena_com_dev *ena_dev,
 	/* Make sure all the fields are supported */
 	supported_fields = hash_ctrl->supported_fields[proto].fields;
 	if ((hash_fields & supported_fields) != hash_fields) {
-		ena_trc_err("proto %d doesn't support the required fields %x. supports only: %x\n",
+		ena_trc_err(ena_dev, "Proto %d doesn't support the required fields %x. supports only: %x\n",
 			    proto, hash_fields, supported_fields);
 	}
 
@@ -2645,14 +2661,14 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 
 	if (!ena_com_check_supported_feature_id(ena_dev,
 						ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG)) {
-		ena_trc_dbg("Feature %d isn't supported\n",
+		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
 			    ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG);
 		return ENA_COM_UNSUPPORTED;
 	}
 
 	ret = ena_com_ind_tbl_convert_to_device(ena_dev);
 	if (ret) {
-		ena_trc_err("Failed to convert host indirection table to device table\n");
+		ena_trc_err(ena_dev, "Failed to convert host indirection table to device table\n");
 		return ret;
 	}
 
@@ -2669,7 +2685,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 				   &cmd.control_buffer.address,
 				   rss->rss_ind_tbl_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -2683,7 +2699,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to set indirect table. error: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to set indirect table. error: %d\n", ret);
 
 	return ret;
 }
@@ -2848,7 +2864,7 @@ int ena_com_set_host_attributes(struct ena_com_dev *ena_dev)
 				   &cmd.u.host_attr.debug_ba,
 				   host_attr->debug_area_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -2856,7 +2872,7 @@ int ena_com_set_host_attributes(struct ena_com_dev *ena_dev)
 				   &cmd.u.host_attr.os_info_ba,
 				   host_attr->host_info_dma_addr);
 	if (unlikely(ret)) {
-		ena_trc_err("memory address set failed\n");
+		ena_trc_err(ena_dev, "Memory address set failed\n");
 		return ret;
 	}
 
@@ -2869,7 +2885,7 @@ int ena_com_set_host_attributes(struct ena_com_dev *ena_dev)
 					    sizeof(resp));
 
 	if (unlikely(ret))
-		ena_trc_err("Failed to set host attributes: %d\n", ret);
+		ena_trc_err(ena_dev, "Failed to set host attributes: %d\n", ret);
 
 	return ret;
 }
@@ -2881,12 +2897,13 @@ bool ena_com_interrupt_moderation_supported(struct ena_com_dev *ena_dev)
 						  ENA_ADMIN_INTERRUPT_MODERATION);
 }
 
-static int ena_com_update_nonadaptive_moderation_interval(u32 coalesce_usecs,
+static int ena_com_update_nonadaptive_moderation_interval(struct ena_com_dev *ena_dev,
+							  u32 coalesce_usecs,
 							  u32 intr_delay_resolution,
 							  u32 *intr_moder_interval)
 {
 	if (!intr_delay_resolution) {
-		ena_trc_err("Illegal interrupt delay granularity value\n");
+		ena_trc_err(ena_dev, "Illegal interrupt delay granularity value\n");
 		return ENA_COM_FAULT;
 	}
 
@@ -2895,11 +2912,11 @@ static int ena_com_update_nonadaptive_moderation_interval(u32 coalesce_usecs,
 	return 0;
 }
 
-
 int ena_com_update_nonadaptive_moderation_interval_tx(struct ena_com_dev *ena_dev,
 						      u32 tx_coalesce_usecs)
 {
-	return ena_com_update_nonadaptive_moderation_interval(tx_coalesce_usecs,
+	return ena_com_update_nonadaptive_moderation_interval(ena_dev,
+							      tx_coalesce_usecs,
 							      ena_dev->intr_delay_resolution,
 							      &ena_dev->intr_moder_tx_interval);
 }
@@ -2907,7 +2924,8 @@ int ena_com_update_nonadaptive_moderation_interval_tx(struct ena_com_dev *ena_de
 int ena_com_update_nonadaptive_moderation_interval_rx(struct ena_com_dev *ena_dev,
 						      u32 rx_coalesce_usecs)
 {
-	return ena_com_update_nonadaptive_moderation_interval(rx_coalesce_usecs,
+	return ena_com_update_nonadaptive_moderation_interval(ena_dev,
+							      rx_coalesce_usecs,
 							      ena_dev->intr_delay_resolution,
 							      &ena_dev->intr_moder_rx_interval);
 }
@@ -2923,12 +2941,12 @@ int ena_com_init_interrupt_moderation(struct ena_com_dev *ena_dev)
 
 	if (rc) {
 		if (rc == ENA_COM_UNSUPPORTED) {
-			ena_trc_dbg("Feature %d isn't supported\n",
+			ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
 				    ENA_ADMIN_INTERRUPT_MODERATION);
 			rc = 0;
 		} else {
-			ena_trc_err("Failed to get interrupt moderation admin cmd. rc: %d\n",
-				    rc);
+			ena_trc_err(ena_dev,
+				    "Failed to get interrupt moderation admin cmd. rc: %d\n", rc);
 		}
 
 		/* no moderation supported, disable adaptive support */
@@ -2976,7 +2994,7 @@ int ena_com_config_dev_mode(struct ena_com_dev *ena_dev,
 		(llq_info->descs_num_before_header * sizeof(struct ena_eth_io_tx_desc));
 
 	if (unlikely(ena_dev->tx_max_header_size == 0)) {
-		ena_trc_err("the size of the LLQ entry is smaller than needed\n");
+		ena_trc_err(ena_dev, "The size of the LLQ entry is smaller than needed\n");
 		return -EINVAL;
 	}
 
drivers/net/ena/base/ena_com.h +21 -0
index e9601b1a8e..cd116e90e6 100644
@@ -300,6 +300,7 @@ struct ena_com_dev {
 	void __iomem *mem_bar;
 	void *dmadev;
 	void *bus;
+	ena_netdev *net_device;
 
 	enum ena_admin_placement_policy_type tx_mem_queue_type;
 	u32 tx_max_header_size;
@@ -944,6 +945,26 @@ int ena_com_config_dev_mode(struct ena_com_dev *ena_dev,
 			    struct ena_admin_feature_llq_desc *llq_features,
 			    struct ena_llq_configurations *llq_default_config);
 
+/* ena_com_io_sq_to_ena_dev - Extract ena_com_dev using contained field io_sq.
+ * @io_sq: IO submit queue struct
+ *
+ * @return - ena_com_dev struct extracted from io_sq
+ */
+static inline struct ena_com_dev *ena_com_io_sq_to_ena_dev(struct ena_com_io_sq *io_sq)
+{
+	return container_of(io_sq, struct ena_com_dev, io_sq_queues[io_sq->qid]);
+}
+
+/* ena_com_io_cq_to_ena_dev - Extract ena_com_dev using contained field io_cq.
+ * @io_sq: IO submit queue struct
+ *
+ * @return - ena_com_dev struct extracted from io_sq
+ */
+static inline struct ena_com_dev *ena_com_io_cq_to_ena_dev(struct ena_com_io_cq *io_cq)
+{
+	return container_of(io_cq, struct ena_com_dev, io_cq_queues[io_cq->qid]);
+}
+
 static inline bool ena_com_get_adaptive_moderation_enabled(struct ena_com_dev *ena_dev)
 {
 	return ena_dev->adaptive_coalescing;
drivers/net/ena/base/ena_eth_com.c +52 -26

220 lines not on this page · raw message

drivers/net/ena/base/ena_eth_com.h +11 -6
index 7dda16cd9f..0cfd18882e 100644
@@ -143,7 +143,8 @@ static inline bool ena_com_is_doorbell_needed(struct ena_com_io_sq *io_sq,
 						   llq_info->descs_per_entry);
 	}
 
-	ena_trc_dbg("queue: %d num_descs: %d num_entries_needed: %d\n",
+	ena_trc_dbg(ena_com_io_sq_to_ena_dev(io_sq),
+		    "Queue: %d num_descs: %d num_entries_needed: %d\n",
 		    io_sq->qid, num_descs, num_entries_needed);
 
 	return num_entries_needed > io_sq->entries_in_tx_burst_left;
@@ -154,14 +155,16 @@ static inline int ena_com_write_sq_doorbell(struct ena_com_io_sq *io_sq)
 	u16 max_entries_in_tx_burst = io_sq->llq_info.max_entries_in_tx_burst;
 	u16 tail = io_sq->tail;
 
-	ena_trc_dbg("write submission queue doorbell for queue: %d tail: %d\n",
+	ena_trc_dbg(ena_com_io_sq_to_ena_dev(io_sq),
+		    "Write submission queue doorbell for queue: %d tail: %d\n",
 		    io_sq->qid, tail);
 
 	ENA_REG_WRITE32(io_sq->bus, tail, io_sq->db_addr);
 
 	if (is_llq_max_tx_burst_exists(io_sq)) {
-		ena_trc_dbg("reset available entries in tx burst for queue %d to %d\n",
-			     io_sq->qid, max_entries_in_tx_burst);
+		ena_trc_dbg(ena_com_io_sq_to_ena_dev(io_sq),
+			    "Reset available entries in tx burst for queue %d to %d\n",
+			    io_sq->qid, max_entries_in_tx_burst);
 		io_sq->entries_in_tx_burst_left = max_entries_in_tx_burst;
 	}
 
@@ -179,7 +182,8 @@ static inline int ena_com_update_dev_comp_head(struct ena_com_io_cq *io_cq)
 		need_update = unreported_comp > (io_cq->q_depth / ENA_COMP_HEAD_THRESH);
 
 		if (unlikely(need_update)) {
-			ena_trc_dbg("Write completion queue doorbell for queue %d: head: %d\n",
+			ena_trc_dbg(ena_com_io_cq_to_ena_dev(io_cq),
+				    "Write completion queue doorbell for queue %d: head: %d\n",
 				    io_cq->qid, head);
 			ENA_REG_WRITE32(io_cq->bus, head, io_cq->cq_head_db_reg);
 			io_cq->last_head_update = head;
@@ -243,7 +247,8 @@ static inline int ena_com_tx_comp_req_id_get(struct ena_com_io_cq *io_cq,
 
 	*req_id = READ_ONCE16(cdesc->req_id);
 	if (unlikely(*req_id >= io_cq->q_depth)) {
-		ena_trc_err("Invalid req id %d\n", cdesc->req_id);
+		ena_trc_err(ena_com_io_cq_to_ena_dev(io_cq),
+			    "Invalid req id %d\n", cdesc->req_id);
 		return ENA_COM_INVAL;
 	}
 
drivers/net/ena/base/ena_plat_dpdk.h +25 -20

60 lines not on this page · raw message

Signature · 1 line
2.25.1
#92 lore raw

PATCH v4 4/19 net/ena/base: style and comments improvements

In reply to Michal Krawczyk

List of changes:
* Comment style was adjusted for the functions
* The keys_num at "struct ena_admin_feature_rss_flow_hash_control" was renamed to the key_parts to better describe it's meaning
* The RSS indirection table was called "REDIRECTION" -> changed to INDIRECTION
* Change AENQ field "syndrom" -> "syndrome"
* Calculate number of the RSS key parts or whole key by ussing the common way: sizeof of the first element of the RSS key
* Add description of the "enum ena_admin_aq_feature_id"
* Rename "map_rx_buf_bidirectional" field as "rx_buf_mirroring"
* Other minor style fixes (remove extra spaces, add missing line break, improve indentation)
* Remove unused macros ENA_ADMIN_EXTRA_PROPERTIES_*
* Restructure the "if {} else if {} else" conditional statement for setting up the meta descriptor

Fixes 99ecfbf845b3 ("ena: import communication layer")
Fixes b68309be44c0 ("net/ena/base: update communication layer for the ENAv2")
Fixes b2b02edeb0d6 ("net/ena/base: upgrade HAL for new HW features")

---
v4:
* Fix commit heading style.

 drivers/net/ena/base/ena_com.c                | 26 +++---
 .../net/ena/base/ena_defs/ena_admin_defs.h    | 85 +++++++++----------
 drivers/net/ena/base/ena_eth_com.c            | 16 ++--
 drivers/net/ena/ena_ethdev.c                  |  4 +-
 4 files changed, 66 insertions(+), 65 deletions(-)
drivers/net/ena/base/ena_com.c +14 -12
index 9931819bbb..9dc9f280c4 100644
@@ -598,7 +598,7 @@ static int ena_com_wait_and_process_admin_cq_polling(struct ena_comp_ctx *comp_c
 	return ret;
 }
 
-/**
+/*
  * Set the LLQ configurations of the firmware
  *
  * The driver provides only the enabled feature values to the device,
@@ -1092,7 +1092,7 @@ static void ena_com_hash_key_fill_default_key(struct ena_com_dev *ena_dev)
 	/* The key buffer is stored in the device in an array of
 	 * uint32 elements.
 	 */
-	hash_key->keys_num = ENA_ADMIN_RSS_KEY_PARTS;
+	hash_key->key_parts = ENA_ADMIN_RSS_KEY_PARTS;
 }
 
 static int ena_com_hash_key_allocate(struct ena_com_dev *ena_dev)
@@ -1165,7 +1165,7 @@ static int ena_com_indirect_table_allocate(struct ena_com_dev *ena_dev,
 	int ret;
 
 	ret = ena_com_get_feature(ena_dev, &get_resp,
-				  ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG, 0);
+				  ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG, 0);
 	if (unlikely(ret))
 		return ret;
 
@@ -1977,6 +1977,7 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev,
 
 	memcpy(&get_feat_ctx->dev_attr, &get_resp.u.dev_attr,
 	       sizeof(get_resp.u.dev_attr));
+
 	ena_dev->supported_features = get_resp.u.dev_attr.supported_features;
 
 	if (ena_dev->supported_features & BIT(ENA_ADMIN_MAX_QUEUES_EXT)) {
@@ -2044,7 +2045,7 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev,
 		return rc;
 
 	rc = ena_com_get_feature(ena_dev, &get_resp,
-				 ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG, 0);
+				 ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG, 0);
 	if (!rc)
 		memcpy(&get_feat_ctx->ind_table, &get_resp.u.ind_table,
 		       sizeof(get_resp.u.ind_table));
@@ -2106,9 +2107,9 @@ void ena_com_aenq_intr_handler(struct ena_com_dev *ena_dev, void *data)
 		timestamp = (u64)aenq_common->timestamp_low |
 			((u64)aenq_common->timestamp_high << 32);
 		ENA_TOUCH(timestamp); /* In case debug is disabled */
-		ena_trc_dbg(ena_dev, "AENQ! Group[%x] Syndrom[%x] timestamp: [%" ENA_PRIu64 "s]\n",
+		ena_trc_dbg(ena_dev, "AENQ! Group[%x] Syndrome[%x] timestamp: [%" ENA_PRIu64 "s]\n",
 			    aenq_common->group,
-			    aenq_common->syndrom,
+			    aenq_common->syndrome,
 			    timestamp);
 
 		/* Handle specific event*/
@@ -2410,7 +2411,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev,
 			}
 			memcpy(hash_key->key, key, key_len);
 			rss->hash_init_val = init_val;
-			hash_key->keys_num = key_len / sizeof(u32);
+			hash_key->key_parts = key_len / sizeof(hash_key->key[0]);
 		}
 		break;
 	case ENA_ADMIN_CRC32:
@@ -2465,7 +2466,8 @@ int ena_com_get_hash_key(struct ena_com_dev *ena_dev, u8 *key)
 		ena_dev->rss.hash_key;
 
 	if (key)
-		memcpy(key, hash_key->key, (size_t)(hash_key->keys_num) << 2);
+		memcpy(key, hash_key->key,
+		       (size_t)(hash_key->key_parts) * sizeof(hash_key->key[0]));
 
 	return 0;
 }
@@ -2660,9 +2662,9 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 	int ret;
 
 	if (!ena_com_check_supported_feature_id(ena_dev,
-						ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG)) {
+						ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG)) {
 		ena_trc_dbg(ena_dev, "Feature %d isn't supported\n",
-			    ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG);
+			    ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG);
 		return ENA_COM_UNSUPPORTED;
 	}
 
@@ -2677,7 +2679,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 	cmd.aq_common_descriptor.opcode = ENA_ADMIN_SET_FEATURE;
 	cmd.aq_common_descriptor.flags =
 		ENA_ADMIN_AQ_COMMON_DESC_CTRL_DATA_INDIRECT_MASK;
-	cmd.feat_common.feature_id = ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG;
+	cmd.feat_common.feature_id = ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG;
 	cmd.u.ind_table.size = rss->tbl_log_size;
 	cmd.u.ind_table.inline_index = 0xFFFFFFFF;
 
@@ -2715,7 +2717,7 @@ int ena_com_indirect_table_get(struct ena_com_dev *ena_dev, u32 *ind_tbl)
 		sizeof(struct ena_admin_rss_ind_table_entry);
 
 	rc = ena_com_get_feature_ex(ena_dev, &get_resp,
-				    ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG,
+				    ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG,
 				    rss->rss_ind_tbl_dma_addr,
 				    tbl_size, 0);
 	if (unlikely(rc))
drivers/net/ena/base/ena_defs/ena_admin_defs.h +41 -44

224 lines not on this page · raw message

drivers/net/ena/base/ena_eth_com.c +9 -7
index 701e6721e3..92a9a10a9e 100644
@@ -331,16 +331,18 @@ static int ena_com_create_and_store_tx_meta_desc(struct ena_com_io_sq *io_sq,
 
 		*have_meta = true;
 		return ena_com_create_meta(io_sq, ena_meta);
-	} else if (ena_com_meta_desc_changed(io_sq, ena_tx_ctx)) {
+	}
+
+	if (ena_com_meta_desc_changed(io_sq, ena_tx_ctx)) {
 		*have_meta = true;
 		/* Cache the meta desc */
 		memcpy(&io_sq->cached_tx_meta, ena_meta,
 		       sizeof(struct ena_com_tx_meta));
 		return ena_com_create_meta(io_sq, ena_meta);
-	} else {
-		*have_meta = false;
-		return ENA_COM_OK;
 	}
+
+	*have_meta = false;
+	return ENA_COM_OK;
 }
 
 static void ena_com_rx_set_flags(struct ena_com_io_cq *io_cq,
@@ -626,9 +628,9 @@ int ena_com_add_single_rx_desc(struct ena_com_io_sq *io_sq,
 	desc->length = ena_buf->len;
 
 	desc->ctrl = ENA_ETH_IO_RX_DESC_FIRST_MASK |
-		ENA_ETH_IO_RX_DESC_LAST_MASK |
-		(io_sq->phase & ENA_ETH_IO_RX_DESC_PHASE_MASK) |
-		ENA_ETH_IO_RX_DESC_COMP_REQ_MASK;
+		     ENA_ETH_IO_RX_DESC_LAST_MASK |
+		     ENA_ETH_IO_RX_DESC_COMP_REQ_MASK |
+		     (io_sq->phase & ENA_ETH_IO_RX_DESC_PHASE_MASK);
 
 	desc->req_id = req_id;
 
drivers/net/ena/ena_ethdev.c +2 -2
index f60e843b7f..f1ff4dad36 100644
@@ -2973,7 +2973,7 @@ static void ena_notification(void *data,
 			aenq_e->aenq_common_desc.group,
 			ENA_ADMIN_NOTIFICATION);
 
-	switch (aenq_e->aenq_common_desc.syndrom) {
+	switch (aenq_e->aenq_common_desc.syndrome) {
 	case ENA_ADMIN_UPDATE_HINTS:
 		hints = (struct ena_admin_ena_hw_hints *)
 			(&aenq_e->inline_data_w4);
@@ -2981,7 +2981,7 @@ static void ena_notification(void *data,
 		break;
 	default:
 		PMD_DRV_LOG(ERR, "Invalid aenq notification link state %d\n",
-			aenq_e->aenq_common_desc.syndrom);
+			aenq_e->aenq_common_desc.syndrome);
 	}
 }
 
Signature · 1 line
2.25.1
#93 lore raw

PATCH v4 5/19 net/ena/base: fix issues from the static code scan

In reply to Michal Krawczyk

To silence error messages from the static code analysis, make the type conversions explicit where they're intended.

Also fix the type for the DMA width value.

Fixes 99ecfbf845b3 ("ena: import communication layer")

---
v4:
* Add stable dpdk as cc.

 drivers/net/ena/base/ena_com.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ena/base/ena_com.c +5 -5
index 9dc9f280c4..0cdeb1a2d9 100644
@@ -1382,7 +1382,7 @@ int ena_com_execute_admin_command(struct ena_com_admin_queue *admin_queue,
 				    "Failed to submit command [%ld]\n",
 				    PTR_ERR(comp_ctx));
 
-		return PTR_ERR(comp_ctx);
+		return (int)PTR_ERR(comp_ctx);
 	}
 
 	ret = ena_com_wait_and_process_admin_cq(comp_ctx, admin_queue);
@@ -1602,7 +1602,7 @@ int ena_com_set_aenq_config(struct ena_com_dev *ena_dev, u32 groups_flag)
 int ena_com_get_dma_width(struct ena_com_dev *ena_dev)
 {
 	u32 caps = ena_com_reg_bar_read32(ena_dev, ENA_REGS_CAPS_OFF);
-	int width;
+	u32 width;
 
 	if (unlikely(caps == ENA_MMIO_READ_TIMEOUT)) {
 		ena_trc_err(ena_dev, "Reg read timeout occurred\n");
@@ -2280,7 +2280,7 @@ int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu)
 	cmd.aq_common_descriptor.opcode = ENA_ADMIN_SET_FEATURE;
 	cmd.aq_common_descriptor.flags = 0;
 	cmd.feat_common.feature_id = ENA_ADMIN_MTU;
-	cmd.u.mtu.mtu = mtu;
+	cmd.u.mtu.mtu = (u32)mtu;
 
 	ret = ena_com_execute_admin_command(admin_queue,
 					    (struct ena_admin_aq_entry *)&cmd,
@@ -2691,7 +2691,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev)
 		return ret;
 	}
 
-	cmd.control_buffer.length = (1ULL << rss->tbl_log_size) *
+	cmd.control_buffer.length = (u32)(1ULL << rss->tbl_log_size) *
 		sizeof(struct ena_admin_rss_ind_table_entry);
 
 	ret = ena_com_execute_admin_command(admin_queue,
@@ -2713,7 +2713,7 @@ int ena_com_indirect_table_get(struct ena_com_dev *ena_dev, u32 *ind_tbl)
 	u32 tbl_size;
 	int i, rc;
 
-	tbl_size = (1ULL << rss->tbl_log_size) *
+	tbl_size = (u32)(1ULL << rss->tbl_log_size) *
 		sizeof(struct ena_admin_rss_ind_table_entry);
 
 	rc = ena_com_get_feature_ex(ena_dev, &get_resp,
Signature · 1 line
2.25.1
#94 lore raw

PATCH v4 6/19 net/ena/base: destroy multiple "wait events"

In reply to Michal Krawczyk

Although the ENA DPDK PMD doesn't have to perform any actions for destroying the wait event, some other platforms have to.

The macro "ENA_WAIT_EVENT_DESTROY" was renamed to "ENA_WAIT_EVENTS_DESTROY" and also whole implementation responsible for that was moved to a separate function for better readability.

Fixes 3adcba9a8987 ("net/ena: update HAL to the newer version")

---
v4:
* Revert changes to the "ENA_WAIT_EVENT_DESTROY".
* Change name of the argument of "ENA_WAIT_EVENTS_DESTROY" to the "admin_queue".
* Add stable dpdk as cc.

 drivers/net/ena/base/ena_com.c       | 24 +++++++++++++++++-------
 drivers/net/ena/base/ena_plat_dpdk.h |  2 +-
 2 files changed, 18 insertions(+), 8 deletions(-)
drivers/net/ena/base/ena_com.c +17 -7
index 0cdeb1a2d9..d025c9cee1 100644
@@ -1671,6 +1671,22 @@ int ena_com_validate_version(struct ena_com_dev *ena_dev)
 	return 0;
 }
 
+static void
+ena_com_free_ena_admin_queue_comp_ctx(struct ena_com_dev *ena_dev,
+				      struct ena_com_admin_queue *admin_queue)
+
+{
+	if (!admin_queue->comp_ctx)
+		return;
+
+	ENA_WAIT_EVENTS_DESTROY(admin_queue);
+	ENA_MEM_FREE(ena_dev->dmadev,
+		     admin_queue->comp_ctx,
+		     (admin_queue->q_depth * sizeof(struct ena_comp_ctx)));
+
+	admin_queue->comp_ctx = NULL;
+}
+
 void ena_com_admin_destroy(struct ena_com_dev *ena_dev)
 {
 	struct ena_com_admin_queue *admin_queue = &ena_dev->admin_queue;
@@ -1679,14 +1695,8 @@ void ena_com_admin_destroy(struct ena_com_dev *ena_dev)
 	struct ena_com_aenq *aenq = &ena_dev->aenq;
 	u16 size;
 
-	if (admin_queue->comp_ctx) {
-		ENA_WAIT_EVENT_DESTROY(admin_queue->comp_ctx->wait_event);
-		ENA_MEM_FREE(ena_dev->dmadev,
-			     admin_queue->comp_ctx,
-			     (admin_queue->q_depth * sizeof(struct ena_comp_ctx)));
-	}
+	ena_com_free_ena_admin_queue_comp_ctx(ena_dev, admin_queue);
 
-	admin_queue->comp_ctx = NULL;
 	size = ADMIN_SQ_SIZE(admin_queue->q_depth);
 	if (sq->entries)
 		ENA_MEM_FREE_COHERENT(ena_dev->dmadev, size, sq->entries,
drivers/net/ena/base/ena_plat_dpdk.h +1 -1
index df2fdd30f6..ddf54f0ad5 100644
@@ -299,7 +299,7 @@ extern rte_atomic32_t ena_alloc_cnt;
 #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_WAIT_EVENT_DESTROY(waitqueue) ((void)(waitqueue))
+#define ENA_WAIT_EVENTS_DESTROY(admin_queue) ((void)(admin_queue))
 
 #ifndef READ_ONCE
 #define READ_ONCE(var) (*((volatile typeof(var) *)(&(var))))
Signature · 1 line
2.25.1
#95 lore raw

PATCH v4 7/19 net/ena/base: remove indir table from ENA feat ctx

In reply to Michal Krawczyk

The RSS indirection table shouldn't be included as a part of the device features context.

If the driver has to acquire it, it can be done using the separate API whenever the RSS configuration is needed.

---
 drivers/net/ena/base/ena_com.c | 11 -----------
 drivers/net/ena/base/ena_com.h |  1 -
 2 files changed, 12 deletions(-)
drivers/net/ena/base/ena_com.c +0 -11
index d025c9cee1..5ca36ab6d9 100644
@@ -2054,17 +2054,6 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev,
 	else
 		return rc;
 
-	rc = ena_com_get_feature(ena_dev, &get_resp,
-				 ENA_ADMIN_RSS_INDIRECTION_TABLE_CONFIG, 0);
-	if (!rc)
-		memcpy(&get_feat_ctx->ind_table, &get_resp.u.ind_table,
-		       sizeof(get_resp.u.ind_table));
-	else if (rc == ENA_COM_UNSUPPORTED)
-		memset(&get_feat_ctx->ind_table, 0x0,
-		       sizeof(get_feat_ctx->ind_table));
-	else
-		return rc;
-
 	return 0;
 }
 
drivers/net/ena/base/ena_com.h +0 -1
index cd116e90e6..ca84e2e8bc 100644
@@ -338,7 +338,6 @@ struct ena_com_dev_get_features_ctx {
 	struct ena_admin_feature_offload_desc offload;
 	struct ena_admin_ena_hw_hints hw_hints;
 	struct ena_admin_feature_llq_desc llq;
-	struct ena_admin_feature_rss_ind_table ind_table;
 };
 
 struct ena_com_create_io_ctx {
Signature · 1 line
2.25.1