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 2 of 2

lore
Share & tools
lore
#96 lore raw

PATCH v4 8/19 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
#97 lore raw

PATCH v4 9/19 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.

---
v4:
* Fix commit heading style.

 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 ddf54f0ad5..9d1426da0b 100644
@@ -291,7 +291,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
#98 lore raw

PATCH v4 10/19 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

---
v4:
* Fix multiple checkpatch warnings.

 drivers/net/ena/base/ena_plat_dpdk.h | 256 +++++++++++++--------------
 drivers/net/ena/ena_ethdev.c         |   2 +-
 2 files changed, 122 insertions(+), 136 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +121 -135
index 9d1426da0b..13264d021b 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,20 +97,20 @@ extern int ena_logtype_com;
 #define BIT(nr)         (1UL << (nr))
 #define BITS_PER_LONG	(__SIZEOF_LONG__ * 8)
 #define GENMASK(h, l)	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
-#define GENMASK_ULL(h, l) (((~0ULL) - (1ULL << (l)) + 1) & \
+#define GENMASK_ULL(h, l) (((~0ULL) - (1ULL << (l)) + 1) &		       \
 			  (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
 
 #ifdef RTE_LIBRTE_ENA_COM_DEBUG
-#define ena_trc_log(dev, level, fmt, arg...)				\
-	(								\
-		ENA_TOUCH(dev),						\
-		rte_log(RTE_LOG_ ## level, ena_logtype_com,		\
-			"[ENA_COM: %s]" fmt, __func__, ##arg)		\
+#define ena_trc_log(dev, level, fmt, arg...)				       \
+	(								       \
+		ENA_TOUCH(dev),						       \
+		rte_log(RTE_LOG_ ## level, ena_logtype_com,		       \
+			"[ENA_COM: %s]" fmt, __func__, ##arg)		       \
 	)
 
 #define ena_trc_dbg(dev, format, arg...) ena_trc_log(dev, DEBUG, format, ##arg)
 #define ena_trc_info(dev, format, arg...) ena_trc_log(dev, INFO, format, ##arg)
-#define ena_trc_warn(dev, format, arg...)				\
+#define ena_trc_warn(dev, format, arg...)				       \
 	ena_trc_log(dev, WARNING, format, ##arg)
 #define ena_trc_err(dev, format, arg...) ena_trc_log(dev, ERR, format, ##arg)
 #else
@@ -118,51 +120,51 @@ extern int ena_logtype_com;
 #define ena_trc_err(dev, format, arg...) ENA_TOUCH(dev)
 #endif /* RTE_LIBRTE_ENA_COM_DEBUG */
 
-#define ENA_WARN(cond, dev, format, arg...)				\
-	do {								\
-		if (unlikely(cond)) {					\
-			ena_trc_err(dev,				\
-				"Warn failed on %s:%s:%d:" format,	\
-				__FILE__, __func__, __LINE__, ##arg);	\
-		}							\
+#define ENA_WARN(cond, dev, format, arg...)				       \
+	do {								       \
+		if (unlikely(cond)) {					       \
+			ena_trc_err(dev,				       \
+				"Warn failed on %s:%s:%d:" format,	       \
+				__FILE__, __func__, __LINE__, ##arg);	       \
+		}							       \
 	} while (0)
 
 /* Spinlock related methods */
 #define ena_spinlock_t rte_spinlock_t
-#define ENA_SPINLOCK_INIT(spinlock) rte_spinlock_init(&spinlock)
-#define ENA_SPINLOCK_LOCK(spinlock, flags)				\
-	({(void)flags; rte_spinlock_lock(&spinlock); })
-#define ENA_SPINLOCK_UNLOCK(spinlock, flags)				\
+#define ENA_SPINLOCK_INIT(spinlock) rte_spinlock_init(&(spinlock))
+#define ENA_SPINLOCK_LOCK(spinlock, flags)				       \
+	({(void)flags; rte_spinlock_lock(&(spinlock)); })
+#define ENA_SPINLOCK_UNLOCK(spinlock, flags)				       \
 	({(void)flags; rte_spinlock_unlock(&(spinlock)); })
-#define ENA_SPINLOCK_DESTROY(spinlock) ((void)spinlock)
+#define ENA_SPINLOCK_DESTROY(spinlock) ((void)(spinlock))
 
-#define q_waitqueue_t			\
-	struct {			\
-		pthread_cond_t cond;	\
-		pthread_mutex_t mutex;	\
+#define q_waitqueue_t							       \
+	struct {							       \
+		pthread_cond_t cond;					       \
+		pthread_mutex_t mutex;					       \
 	}
 
 #define ena_wait_queue_t q_waitqueue_t
 
-#define ENA_WAIT_EVENT_INIT(waitqueue)					\
-	do {								\
-		pthread_mutex_init(&(waitqueue).mutex, NULL);		\
-		pthread_cond_init(&(waitqueue).cond, NULL);		\
+#define ENA_WAIT_EVENT_INIT(waitqueue)					       \
+	do {								       \
+		pthread_mutex_init(&(waitqueue).mutex, NULL);		       \
+		pthread_cond_init(&(waitqueue).cond, NULL);		       \
 	} while (0)
 
-#define ENA_WAIT_EVENT_WAIT(waitevent, timeout)				\
-	do {								\
-		struct timespec wait;					\
-		struct timeval now;					\
-		unsigned long timeout_us;				\
-		gettimeofday(&now, NULL);				\
-		wait.tv_sec = now.tv_sec + timeout / 1000000UL;		\
-		timeout_us = timeout % 1000000UL;			\
-		wait.tv_nsec = (now.tv_usec + timeout_us) * 1000UL;	\
-		pthread_mutex_lock(&waitevent.mutex);			\
-		pthread_cond_timedwait(&waitevent.cond,			\
-				&waitevent.mutex, &wait);		\
-		pthread_mutex_unlock(&waitevent.mutex);			\
+#define ENA_WAIT_EVENT_WAIT(waitevent, timeout)				       \
+	do {								       \
+		struct timespec wait;					       \
+		struct timeval now;					       \
+		unsigned long timeout_us;				       \
+		gettimeofday(&now, NULL);				       \
+		wait.tv_sec = now.tv_sec + (timeout) / 1000000UL;	       \
+		timeout_us = (timeout) % 1000000UL;			       \
+		wait.tv_nsec = (now.tv_usec + timeout_us) * 1000UL;	       \
+		pthread_mutex_lock(&(waitevent).mutex);			       \
+		pthread_cond_timedwait(&(waitevent).cond,		       \
+				&(waitevent).mutex, &wait);		       \
+		pthread_mutex_unlock(&(waitevent).mutex);		       \
 	} while (0)
 #define ENA_WAIT_EVENT_SIGNAL(waitevent) pthread_cond_signal(&waitevent.cond)
 /* pthread condition doesn't need to be rearmed after usage */
@@ -174,104 +176,90 @@ extern int ena_logtype_com;
 
 #define ena_time_t uint64_t
 #define ENA_TIME_EXPIRE(timeout)  (timeout < rte_get_timer_cycles())
-#define ENA_GET_SYSTEM_TIMEOUT(timeout_us)                             \
-       (timeout_us * rte_get_timer_hz() / 1000000 + rte_get_timer_cycles())
+#define ENA_GET_SYSTEM_TIMEOUT(timeout_us)				       \
+	((timeout_us) * rte_get_timer_hz() / 1000000 + rte_get_timer_cycles())
 
 /*
  * Each rte_memzone should have unique name.
  * To satisfy it, count number of allocations and add it to name.
  */
-extern rte_atomic32_t ena_alloc_cnt;
-
-#define ENA_MEM_ALLOC_COHERENT_ALIGNED(					\
-	dmadev, size, virt, phys, handle, alignment)			\
-	do {								\
-		const struct rte_memzone *mz = NULL;			\
-		ENA_TOUCH(dmadev); ENA_TOUCH(handle);			\
-		if (size > 0) {						\
-			char z_name[RTE_MEMZONE_NAMESIZE];		\
-			snprintf(z_name, sizeof(z_name),		\
-			 "ena_alloc_%d",				\
-			 rte_atomic32_add_return(&ena_alloc_cnt, 1));	\
-			mz = rte_memzone_reserve_aligned(z_name, size,	\
-					SOCKET_ID_ANY,			\
-					RTE_MEMZONE_IOVA_CONTIG,	\
-					alignment);			\
-			handle = mz;					\
-		}							\
-		if (mz == NULL) {					\
-			virt = NULL;					\
-			phys = 0;					\
-		} else {						\
-			memset(mz->addr, 0, size);			\
-			virt = mz->addr;				\
-			phys = mz->iova;				\
-		}							\
+extern rte_atomic64_t ena_alloc_cnt;
+
+#define ENA_MEM_ALLOC_COHERENT_ALIGNED(					       \
+	dmadev, size, virt, phys, mem_handle, alignment)		       \
+	do {								       \
+		const struct rte_memzone *mz = NULL;			       \
+		ENA_TOUCH(dmadev);					       \
+		if ((size) > 0) {					       \
+			char z_name[RTE_MEMZONE_NAMESIZE];		       \
+			snprintf(z_name, sizeof(z_name),		       \
+				"ena_alloc_%" PRIi64 "",		       \
+				rte_atomic64_add_return(&ena_alloc_cnt,	1));   \
+			mz = rte_memzone_reserve_aligned(z_name, (size),       \
+					SOCKET_ID_ANY, RTE_MEMZONE_IOVA_CONTIG,\
+					alignment);			       \
+			mem_handle = mz;				       \
+		}							       \
+		if (mz == NULL) {					       \
+			virt = NULL;					       \
+			phys = 0;					       \
+		} else {						       \
+			memset(mz->addr, 0, (size));			       \
+			virt = mz->addr;				       \
+			phys = mz->iova;				       \
+		}							       \
 	} while (0)
-#define ENA_MEM_ALLOC_COHERENT(dmadev, size, virt, phys, handle)	\
-		ENA_MEM_ALLOC_COHERENT_ALIGNED(				\
-			dmadev,						\
-			size,						\
-			virt,						\
-			phys,						\
-			handle,						\
-			RTE_CACHE_LINE_SIZE)
-#define ENA_MEM_FREE_COHERENT(dmadev, size, virt, phys, handle) 	\
-		({ ENA_TOUCH(size); ENA_TOUCH(phys);			\
-		   ENA_TOUCH(dmadev);					\
-		   rte_memzone_free(handle); })
-
-#define ENA_MEM_ALLOC_COHERENT_NODE_ALIGNED(				\
-	dmadev, size, virt, phys, mem_handle, node, dev_node, alignment) \
-	do {								\
-		const struct rte_memzone *mz = NULL;			\
-		ENA_TOUCH(dmadev); ENA_TOUCH(dev_node);			\
-		if (size > 0) {						\
-			char z_name[RTE_MEMZONE_NAMESIZE];		\
-			snprintf(z_name, sizeof(z_name),		\
-			 "ena_alloc_%d",				\
-			 rte_atomic32_add_return(&ena_alloc_cnt, 1));   \
-			mz = rte_memzone_reserve_aligned(z_name, size, node, \
-				RTE_MEMZONE_IOVA_CONTIG, alignment);	\
-			mem_handle = mz;				\
-		}							\
-		if (mz == NULL) {					\
-			virt = NULL;					\
-			phys = 0;					\
-		} else {						\
-			memset(mz->addr, 0, size);			\
-			virt = mz->addr;				\
-			phys = mz->iova;				\
-		}							\
+#define ENA_MEM_ALLOC_COHERENT(dmadev, size, virt, phys, mem_handle)	       \
+		ENA_MEM_ALLOC_COHERENT_ALIGNED(dmadev, size, virt, phys,       \
+			mem_handle, RTE_CACHE_LINE_SIZE)
+#define ENA_MEM_FREE_COHERENT(dmadev, size, virt, phys, mem_handle)	       \
+		({ ENA_TOUCH(size); ENA_TOUCH(phys); ENA_TOUCH(dmadev);	       \
+		   rte_memzone_free(mem_handle); })
+
+#define ENA_MEM_ALLOC_COHERENT_NODE_ALIGNED(				       \
+	dmadev, size, virt, phys, mem_handle, node, dev_node, alignment)       \
+	do {								       \
+		const struct rte_memzone *mz = NULL;			       \
+		ENA_TOUCH(dmadev); ENA_TOUCH(dev_node);			       \
+		if ((size) > 0) {					       \
+			char z_name[RTE_MEMZONE_NAMESIZE];		       \
+			snprintf(z_name, sizeof(z_name),		       \
+				"ena_alloc_%" PRIi64 "",		       \
+				rte_atomic64_add_return(&ena_alloc_cnt, 1));   \
+			mz = rte_memzone_reserve_aligned(z_name, (size),       \
+				node, RTE_MEMZONE_IOVA_CONTIG, alignment);     \
+			mem_handle = mz;				       \
+		}							       \
+		if (mz == NULL) {					       \
+			virt = NULL;					       \
+			phys = 0;					       \
+		} else {						       \
+			memset(mz->addr, 0, (size));			       \
+			virt = mz->addr;				       \
+			phys = mz->iova;				       \
+		}							       \
 	} while (0)
-#define ENA_MEM_ALLOC_COHERENT_NODE(					\
-	dmadev, size, virt, phys, mem_handle, node, dev_node)		\
-		ENA_MEM_ALLOC_COHERENT_NODE_ALIGNED(			\
-			dmadev,						\
-			size,						\
-			virt,						\
-			phys,						\
-			mem_handle,					\
-			node,						\
-			dev_node,					\
-			RTE_CACHE_LINE_SIZE)
-#define ENA_MEM_ALLOC_NODE(dmadev, size, virt, node, dev_node) \
-	do {								\
-		ENA_TOUCH(dmadev); ENA_TOUCH(dev_node);			\
-		virt = rte_zmalloc_socket(NULL, size, 0, node);		\
+#define ENA_MEM_ALLOC_COHERENT_NODE(					       \
+	dmadev, size, virt, phys, mem_handle, node, dev_node)		       \
+		ENA_MEM_ALLOC_COHERENT_NODE_ALIGNED(dmadev, size, virt,	phys,  \
+			mem_handle, node, dev_node, RTE_CACHE_LINE_SIZE)
+#define ENA_MEM_ALLOC_NODE(dmadev, size, virt, node, dev_node)		       \
+	do {								       \
+		ENA_TOUCH(dmadev); ENA_TOUCH(dev_node);			       \
+		virt = rte_zmalloc_socket(NULL, size, 0, node);		       \
 	} while (0)
 
 #define ENA_MEM_ALLOC(dmadev, size) rte_zmalloc(NULL, size, 1)
-#define ENA_MEM_FREE(dmadev, ptr, size)					\
+#define ENA_MEM_FREE(dmadev, ptr, size)					       \
 	({ ENA_TOUCH(dmadev); ENA_TOUCH(size); rte_free(ptr); })
 
 #define ENA_DB_SYNC(mem_handle) ((void)mem_handle)
 
-#define ENA_REG_WRITE32(bus, value, reg)				\
+#define ENA_REG_WRITE32(bus, value, reg)				       \
 	({ (void)(bus); rte_write32((value), (reg)); })
-#define ENA_REG_WRITE32_RELAXED(bus, value, reg)			\
+#define ENA_REG_WRITE32_RELAXED(bus, value, reg)			       \
 	({ (void)(bus); rte_write32_relaxed((value), (reg)); })
-#define ENA_REG_READ32(bus, reg)					\
+#define ENA_REG_READ32(bus, reg)					       \
 	({ (void)(bus); rte_read32_relaxed((reg)); })
 
 #define ATOMIC32_INC(i32_ptr) rte_atomic32_inc(i32_ptr)
@@ -297,8 +285,8 @@ extern rte_atomic32_t ena_alloc_cnt;
 #define upper_32_bits(x) ((uint32_t)(((x) >> 16) >> 16))
 
 #define ENA_TIME_EXPIRE(timeout)  (timeout < rte_get_timer_cycles())
-#define ENA_GET_SYSTEM_TIMEOUT(timeout_us)				\
-    (timeout_us * rte_get_timer_hz() / 1000000 + rte_get_timer_cycles())
+#define ENA_GET_SYSTEM_TIMEOUT(timeout_us)				       \
+	((timeout_us) * rte_get_timer_hz() / 1000000 + rte_get_timer_cycles())
 #define ENA_WAIT_EVENTS_DESTROY(admin_queue) ((void)(admin_queue))
 
 #ifndef READ_ONCE
@@ -310,14 +298,14 @@ extern rte_atomic32_t ena_alloc_cnt;
 #define READ_ONCE32(var) READ_ONCE(var)
 
 /* The size must be 8 byte align */
-#define ENA_MEMCPY_TO_DEVICE_64(dst, src, size)				\
-	do {								\
-		int count, i;						\
-		uint64_t *to = (uint64_t *)(dst);			\
-		const uint64_t *from = (const uint64_t *)(src);		\
-		count = (size) / 8;					\
-		for (i = 0; i < count; i++, from++, to++)		\
-			rte_write64_relaxed(*from, to);			\
+#define ENA_MEMCPY_TO_DEVICE_64(dst, src, size)				       \
+	do {								       \
+		int count, i;						       \
+		uint64_t *to = (uint64_t *)(dst);			       \
+		const uint64_t *from = (const uint64_t *)(src);		       \
+		count = (size) / 8;					       \
+		for (i = 0; i < count; i++, from++, to++)		       \
+			rte_write64_relaxed(*from, to);			       \
 	} while(0)
 
 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
@@ -330,7 +318,5 @@ void ena_rss_key_fill(void *key, size_t size);
 
 #define ENA_INTR_INITIAL_TX_INTERVAL_USECS_PLAT 0
 
-#define ENA_PRIu64 PRIu64
-
 #include "ena_includes.h"
 #endif /* DPDK_ENA_COM_ENA_PLAT_DPDK_H_ */
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
#99 lore raw

PATCH v4 11/19 net/ena: fix parsing of large LLQ header devarg

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")

---
v4:
* Add release notes.
* Fix commit heading style.

 doc/guides/rel_notes/release_21_05.rst | 1 +
 drivers/net/ena/ena_ethdev.c           | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_21_05.rst +1 -0
index 6e4fcde1bc..755d5fcd32 100644
@@ -209,6 +209,7 @@ New Features
 
   * 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 support of multiple data-units in cryptodev API.**
 
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
#100 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v4 11/19] net/ena: fix parsing of large LLQ header devarg

11/05/2021 08:45, Michal Krawczyk:

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

Quoted 8 lines

From: Igor Chauskin <[email protected]>

doc/guides/rel_notes/release_21_05.rst +1 -0
@@ -209,6 +209,7 @@ New Features
 
   * 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.

Until now, we don't mention fixed bugs in the "New Features" of the release notes.
I'll drop this one and the next one for consistency.

#101 lore raw

PATCH v4 12/19 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")

---
v4:
* Fix commit heading style.

 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
#102 lore raw

PATCH v4 13/19 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")

---
v4:
* Add release notes.
* Always announce DEV_RX_OFFLOAD_RSS_HASH if RSS is enabled.

 doc/guides/rel_notes/release_21_05.rst |  1 +
 drivers/net/ena/ena_ethdev.c           | 12 ++++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)
doc/guides/rel_notes/release_21_05.rst +1 -0
index 755d5fcd32..389a7a05ac 100644
@@ -210,6 +210,7 @@ New Features
   * 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.
 
 * **Added support of multiple data-units in cryptodev API.**
 
drivers/net/ena/ena_ethdev.c +10 -2
index 6092288239..9a43ab50fe 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;
 }
@@ -1960,6 +1967,9 @@ static int ena_dev_configure(struct rte_eth_dev *dev)
 
 	adapter->state = ENA_ADAPTER_STATE_CONFIG;
 
+	if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
+		dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;
+
 	adapter->tx_selected_offloads = dev->data->dev_conf.txmode.offloads;
 	adapter->rx_selected_offloads = dev->data->dev_conf.rxmode.offloads;
 	return 0;
@@ -2245,8 +2255,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
#103 lore raw

Re: [dpdk-dev] [PATCH v4 13/19] net/ena: indicate Rx RSS hash presence

Quoted 63 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")

---
v4:
* Add release notes.
* Always announce DEV_RX_OFFLOAD_RSS_HASH if RSS is enabled.

 doc/guides/rel_notes/release_21_05.rst |  1 +
 drivers/net/ena/ena_ethdev.c           | 12 ++++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)
doc/guides/rel_notes/release_21_05.rst +1 -0
index 755d5fcd32..389a7a05ac 100644
@@ -210,6 +210,7 @@ New Features
   * 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.
 
 * **Added support of multiple data-units in cryptodev API.**
 
drivers/net/ena/ena_ethdev.c +7 -0
index 6092288239..9a43ab50fe 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;
 }

drivers/net/ena/ena_ethdev.c static int ena_dev_configure(struct rte_eth_dev *dev) · line 1972

Quoted 6 lines
drivers/net/ena/ena_ethdev.c +3 -0
@@ -1960,6 +1967,9 @@ static int ena_dev_configure(struct rte_eth_dev *dev)
 
 	adapter->state = ENA_ADAPTER_STATE_CONFIG;
 
+	if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
+		dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;
+

Also need to advertise this offload in 'dev_info->rx_offload_capa'.

Quoted 13 lines
drivers/net/ena/ena_ethdev.c +0 -2
 	adapter->tx_selected_offloads = dev->data->dev_conf.txmode.offloads;
 	adapter->rx_selected_offloads = dev->data->dev_conf.rxmode.offloads;
 	return 0;
@@ -2245,8 +2255,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;
 	}
#104 lore raw

PATCH v4 14/19 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
#105 lore raw

PATCH v4 15/19 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.

---
v4:
* Replace rte_panic with the error log.

 drivers/net/ena/base/ena_plat_dpdk.h | 73 ++++++++++++++++++----------
 1 file changed, 46 insertions(+), 27 deletions(-)
drivers/net/ena/base/ena_plat_dpdk.h +46 -27
index 13264d021b..f66df95591 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())
@@ -138,40 +146,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))		       \
+			ena_trc_err(NULL,				       \
+				"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(waitqueue) ((void)(waitqueue))
+#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
@@ -289,14 +316,6 @@ extern rte_atomic64_t ena_alloc_cnt;
 	((timeout_us) * rte_get_timer_hz() / 1000000 + rte_get_timer_cycles())
 #define ENA_WAIT_EVENTS_DESTROY(admin_queue) ((void)(admin_queue))
 
-#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)
-
 /* The size must be 8 byte align */
 #define ENA_MEMCPY_TO_DEVICE_64(dst, src, size)				       \
 	do {								       \
Signature · 1 line
2.25.1
#106 lore raw

PATCH v4 16/19 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.

---
v4:
* Remove access to the "rte_eth_devices" and instead pass rte_eth_dev as an argument to all the primary process callbacks.
* Fix commit heading style.

 drivers/net/ena/ena_ethdev.c | 72 ++++++++++++++++++------------------
 drivers/net/ena/ena_ethdev.h |  5 +--
 2 files changed, 38 insertions(+), 39 deletions(-)
drivers/net/ena/ena_ethdev.c +36 -36
index 9a43ab50fe..055fa6d514 100644
@@ -164,6 +164,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);
@@ -457,11 +458,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)
@@ -469,7 +470,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;
@@ -518,7 +519,7 @@ static int ena_close(struct rte_eth_dev *dev)
 	rte_intr_disable(intr_handle);
 	rte_intr_callback_unregister(intr_handle,
 				     ena_interrupt_handler_rte,
-				     adapter);
+				     dev);
 
 	/*
 	 * MAC is not allocated dynamically. Setting NULL should prevent from
@@ -593,7 +594,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;
 }
@@ -637,7 +638,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;
 
@@ -675,8 +676,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;
 
@@ -847,10 +847,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;
 }
@@ -1070,8 +1070,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;
@@ -1084,7 +1084,7 @@ static int ena_start(struct rte_eth_dev *dev)
 
 	ticks = rte_get_timer_hz();
 	rte_timer_reset(&adapter->timer_wd, ticks, PERIODICAL, rte_lcore_id(),
-			ena_timer_wd_callback, adapter);
+			ena_timer_wd_callback, dev);
 
 	++adapter->dev_stats.dev_start;
 	adapter->state = ENA_ADAPTER_STATE_RUNNING;
@@ -1511,6 +1511,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)
 {
@@ -1528,9 +1529,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 */
@@ -1601,12 +1600,13 @@ static int ena_device_init(struct ena_com_dev *ena_dev,
 
 static void ena_interrupt_handler_rte(void *cb_arg)
 {
-	struct ena_adapter *adapter = cb_arg;
+	struct rte_eth_dev *dev = cb_arg;
+	struct ena_adapter *adapter = dev->data->dev_private;
 	struct ena_com_dev *ena_dev = &adapter->ena_dev;
 
 	ena_com_admin_q_comp_intr_handler(ena_dev);
 	if (likely(adapter->state != ENA_ADAPTER_STATE_CLOSED))
-		ena_com_aenq_intr_handler(ena_dev, adapter);
+		ena_com_aenq_intr_handler(ena_dev, dev);
 }
 
 static void check_for_missing_keep_alive(struct ena_adapter *adapter)
@@ -1639,8 +1639,8 @@ static void check_for_admin_com_state(struct ena_adapter *adapter)
 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 = arg;
+	struct ena_adapter *adapter = dev->data->dev_private;
 
 	check_for_missing_keep_alive(adapter);
 	check_for_admin_com_state(adapter);
@@ -1781,11 +1781,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,
@@ -1805,7 +1804,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;
 
@@ -1819,7 +1819,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;
@@ -1902,7 +1902,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 
 	rte_intr_callback_register(intr_handle,
 				   ena_interrupt_handler_rte,
-				   adapter);
+				   eth_dev);
 	rte_intr_enable(intr_handle);
 	ena_com_set_admin_polling_mode(ena_dev, false);
 	ena_com_admin_aenq_enable(ena_dev);
@@ -2681,7 +2681,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)
@@ -2730,7 +2730,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;
@@ -2955,14 +2955,12 @@ RTE_LOG_REGISTER(ena_logtype_com, pmd.net.ena.com, NOTICE);
 static void ena_update_on_link_change(void *adapter_data,
 				      struct ena_admin_aenq_entry *aenq_e)
 {
-	struct rte_eth_dev *eth_dev;
-	struct ena_adapter *adapter;
+	struct rte_eth_dev *eth_dev = adapter_data;
+	struct ena_adapter *adapter = eth_dev->data->dev_private;
 	struct ena_admin_aenq_link_change_desc *aenq_link_desc;
 	uint32_t status;
 
-	adapter = adapter_data;
 	aenq_link_desc = (struct ena_admin_aenq_link_change_desc *)aenq_e;
-	eth_dev = adapter->rte_dev;
 
 	status = get_ena_admin_aenq_link_change_desc_link_status(aenq_link_desc);
 	adapter->link_status = status;
@@ -2971,10 +2969,11 @@ static void ena_update_on_link_change(void *adapter_data,
 	rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 }
 
-static void ena_notification(void *data,
+static void ena_notification(void *adapter_data,
 			     struct ena_admin_aenq_entry *aenq_e)
 {
-	struct ena_adapter *adapter = data;
+	struct rte_eth_dev *eth_dev = adapter_data;
+	struct ena_adapter *adapter = eth_dev->data->dev_private;
 	struct ena_admin_ena_hw_hints *hints;
 
 	if (aenq_e->aenq_common_desc.group != ENA_ADMIN_NOTIFICATION)
@@ -2997,7 +2996,8 @@ static void ena_notification(void *data,
 static void ena_keep_alive(void *adapter_data,
 			   __rte_unused struct ena_admin_aenq_entry *aenq_e)
 {
-	struct ena_adapter *adapter = adapter_data;
+	struct rte_eth_dev *eth_dev = adapter_data;
+	struct ena_adapter *adapter = eth_dev->data->dev_private;
 	struct ena_admin_aenq_keep_alive_desc *desc;
 	uint64_t rx_drops;
 	uint64_t tx_drops;
drivers/net/ena/ena_ethdev.h +2 -3
index ae235897ee..925e71f642 100644
@@ -210,9 +210,8 @@ struct ena_offloads {
 /* 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
#107 lore raw

Re: [dpdk-dev] [PATCH v4 16/19] net/ena: make ethdev references SMP safe

Quoted 7 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.

Commit log also needs to be updated, since it still mentions "rte_eth_devices indexing".

Meanwhile adapter::port_id become kind of redundant in this version, perhaps you may want to remove it.

Quoted 10 lines

---
v4:
* Remove access to the "rte_eth_devices" and instead pass rte_eth_dev as an argument to all the primary process callbacks.
* Fix commit heading style.

<...>

#108 lore raw

PATCH v4 17/19 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.

---
v4:
* Fix commit heading style.

 drivers/net/ena/ena_ethdev.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/net/ena/ena_ethdev.c +18 -0
index 055fa6d514..21bea98007 100644
@@ -535,6 +535,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)
@@ -1058,6 +1064,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;
@@ -1104,6 +1116,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
#109 lore raw

Re: [dpdk-dev] [PATCH v4 17/19] net/ena: disable dev ops not supported in SMP

Quoted 5 lines · 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.

'SMP' can be confusing in this context, this is not exactly related to SMP. In DPDK we tend to call this multi process support, or for this patch it is more likely secondary process, like:
net/ena: disable dev ops not supported by secondary process

btw, some device operations not supported by secondary process independent from driver, it is possible to handle them in ethdev layer. Right now responsibility is mostly pushed to the application.

Quoted 55 lines

---
v4:
* Fix commit heading style.

 drivers/net/ena/ena_ethdev.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/net/ena/ena_ethdev.c +18 -0
index 055fa6d514..21bea98007 100644
@@ -535,6 +535,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)
@@ -1058,6 +1064,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;
@@ -1104,6 +1116,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);
#110 lore raw

PATCH v4 18/19 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")

---
v4:
* Add release notes.

 doc/guides/rel_notes/release_21_05.rst | 1 +
 drivers/net/ena/ena_ethdev.c           | 9 +++------
 2 files changed, 4 insertions(+), 6 deletions(-)
doc/guides/rel_notes/release_21_05.rst +1 -0
index 389a7a05ac..f6c566f05c 100644
@@ -211,6 +211,7 @@ New Features
   * 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.
 
 * **Added support of multiple data-units in cryptodev API.**
 
drivers/net/ena/ena_ethdev.c +3 -6
index 21bea98007..cb2c93052a 100644
@@ -1300,9 +1300,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;
@@ -1374,9 +1371,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",
@@ -2096,6 +2090,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
#111 lore raw

PATCH v4 19/19 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 (from 18.09.2020).
* Bug fixes for the large LLQ headers and devargs parsing.
* Mbuf RSS hash presence indication.
* Bug fix for the default ring size.
* Fix for the SMP mode (although ENA is not fully MP aware, yet).

---
v4:
* Remove release notes update from this commit.
* Squash this patch with the geration date and commit ID update of the HAL.
* Update commit log regarding the SMP fixes.

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

 drivers/net/ena/base/ena_defs/ena_gen_info.h | 4 ++--
 drivers/net/ena/ena_ethdev.c                 | 4 ++--
 2 files changed, 4 insertions(+), 4 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"
drivers/net/ena/ena_ethdev.c +2 -2
index cb2c93052a..0caa5d9ee7 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
#112 lore raw
In reply to Michal Krawczyk
Quoted 54 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.

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

Quoted 7 lines

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

Hi Michal,

I put some comments on 13,16,17/19 but merging rest, can you please send a new version for those three patches separately, on top of latest head?

Also can you please double check if anything is missed/wrong in the merged ones because of rebasing.

Except 13,16,17/19,
Series applied to dpdk-next-net/main, thanks.

#113 lore raw

wt., 11 maj 2021 o 15:07 Ferruh Yigit <[email protected]> napisał(a):

Quoted 64 lines · Michal Krawczyk
Quoted 54 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.

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

Quoted 7 lines

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

Quoted 5 lines

Hi Michal,

I put some comments on 13,16,17/19 but merging rest, can you please send a new version for those three patches separately, on top of latest head?

Hi Ferruh,

thanks a lot for a review and merge!

Sure, I'll send the new version separately, rebased on the head.

Quoted 3 lines

Also can you please double check if anything is missed/wrong in the merged ones because of rebasing.

Checked - everything is fine.

Quoted 2 lines

Except 13,16,17/19,
Series applied to dpdk-next-net/main, thanks.

Thanks,
Michal

#114 lore raw

v5 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.

Since v5, the series contains only 3, unmerged patches.

v5:
* Indicate RSS hash offload in the Rx capabilities field.
* Changes made to 'making the ethdev references multiprocess safe:
- rework commit log,
- remove adapter::port_id field.
* Change made to "disable dev ops not supported by secondary process":
- rework commit log.

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 of 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.

Michal Krawczyk (1):
net/ena: indicate Rx RSS hash presence

Stanislaw Kardach (2):
net/ena: make ethdev references multiprocess safe net/ena: disable dev ops not supported by secondary process

 doc/guides/rel_notes/release_21_05.rst |   1 +
 drivers/net/ena/ena_ethdev.c           | 101 ++++++++++++++++---------
 drivers/net/ena/ena_ethdev.h           |   4 +-
 3 files changed, 66 insertions(+), 40 deletions(-)
Signature · 1 line
2.25.1
#115 lore raw

PATCH v5 1/3 net/ena: indicate Rx RSS hash presence

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")

---
v5:
* Announce Rx RSS hash support in the dev_info->rx_offload_capa.

v4:
* Add release notes.
* Always announce DEV_RX_OFFLOAD_RSS_HASH if RSS is enabled.

 doc/guides/rel_notes/release_21_05.rst |  1 +
 drivers/net/ena/ena_ethdev.c           | 13 +++++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
doc/guides/rel_notes/release_21_05.rst +1 -0
index 4e669d3108..0466415112 100644
@@ -120,6 +120,7 @@ New Features
   * Updated ena_com (HAL) to the latest version.
   * Fixed bugs when requesting large LLQ headers using the devargs.
   * Fixed bug when the default ring size was set.
+  * Added indication of the RSS hash presence in the mbuf.
 
 * **Updated Arkville PMD driver.**
 
drivers/net/ena/ena_ethdev.c +11 -2
index 54d5e756cb..fb2b19cfdb 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;
 }
@@ -1954,6 +1961,9 @@ static int ena_dev_configure(struct rte_eth_dev *dev)
 
 	adapter->state = ENA_ADAPTER_STATE_CONFIG;
 
+	if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
+		dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;
+
 	adapter->tx_selected_offloads = dev->data->dev_conf.txmode.offloads;
 	adapter->rx_selected_offloads = dev->data->dev_conf.rxmode.offloads;
 	return 0;
@@ -2030,6 +2040,7 @@ static int ena_infos_get(struct rte_eth_dev *dev,
 
 	/* Inform framework about available features */
 	dev_info->rx_offload_capa = rx_feat;
+	dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_RSS_HASH;
 	dev_info->rx_queue_offload_capa = rx_feat;
 	dev_info->tx_offload_capa = tx_feat;
 	dev_info->tx_queue_offload_capa = tx_feat;
@@ -2242,8 +2253,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
#116 lore raw

PATCH v5 2/3 net/ena: make ethdev references multiprocess 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.

Both ena_timer_wd_callback and ena_interrupt_handler_rte needs access to the rte_eth_dev, but as they are being setup and executed in the primary process, it is safe to pass there the same pointer, which is used for the device configuration.

In all other cases, except the eth_ena_dev_init(), the rte_eth_dev_data is used instead.

---
v5:
* Remove adapter::port_id field.
* Update commit log.

v4:
* Remove access to the "rte_eth_devices" and instead pass rte_eth_dev as an argument to all the primary process callbacks.
* Fix commit heading style.

 drivers/net/ena/ena_ethdev.c | 70 ++++++++++++++++++------------------
 drivers/net/ena/ena_ethdev.h |  4 +--
 2 files changed, 36 insertions(+), 38 deletions(-)
drivers/net/ena/ena_ethdev.c +35 -35
index fb2b19cfdb..e310e7ae8c 100644
@@ -164,6 +164,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);
@@ -457,11 +458,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)
@@ -469,7 +470,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;
@@ -518,7 +519,7 @@ static int ena_close(struct rte_eth_dev *dev)
 	rte_intr_disable(intr_handle);
 	rte_intr_callback_unregister(intr_handle,
 				     ena_interrupt_handler_rte,
-				     adapter);
+				     dev);
 
 	/*
 	 * MAC is not allocated dynamically. Setting NULL should prevent from
@@ -593,7 +594,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;
 }
@@ -637,7 +638,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;
 
@@ -676,7 +677,7 @@ static int ena_rss_init_default(struct ena_adapter *adapter)
 		goto err_fill_indir;
 	}
 	PMD_DRV_LOG(DEBUG, "RSS configured for port %d\n",
-		adapter->rte_dev->data->port_id);
+		adapter->edev_data->port_id);
 
 	return 0;
 
@@ -847,10 +848,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;
 }
@@ -1070,8 +1071,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;
@@ -1084,7 +1085,7 @@ static int ena_start(struct rte_eth_dev *dev)
 
 	ticks = rte_get_timer_hz();
 	rte_timer_reset(&adapter->timer_wd, ticks, PERIODICAL, rte_lcore_id(),
-			ena_timer_wd_callback, adapter);
+			ena_timer_wd_callback, dev);
 
 	++adapter->dev_stats.dev_start;
 	adapter->state = ENA_ADAPTER_STATE_RUNNING;
@@ -1505,6 +1506,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 +1524,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 */
@@ -1595,12 +1595,13 @@ static int ena_device_init(struct ena_com_dev *ena_dev,
 
 static void ena_interrupt_handler_rte(void *cb_arg)
 {
-	struct ena_adapter *adapter = cb_arg;
+	struct rte_eth_dev *dev = cb_arg;
+	struct ena_adapter *adapter = dev->data->dev_private;
 	struct ena_com_dev *ena_dev = &adapter->ena_dev;
 
 	ena_com_admin_q_comp_intr_handler(ena_dev);
 	if (likely(adapter->state != ENA_ADAPTER_STATE_CLOSED))
-		ena_com_aenq_intr_handler(ena_dev, adapter);
+		ena_com_aenq_intr_handler(ena_dev, dev);
 }
 
 static void check_for_missing_keep_alive(struct ena_adapter *adapter)
@@ -1633,8 +1634,8 @@ static void check_for_admin_com_state(struct ena_adapter *adapter)
 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 = arg;
+	struct ena_adapter *adapter = dev->data->dev_private;
 
 	check_for_missing_keep_alive(adapter);
 	check_for_admin_com_state(adapter);
@@ -1775,11 +1776,9 @@ 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;
 
 	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,
@@ -1799,7 +1798,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;
 
@@ -1813,7 +1813,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;
@@ -1896,7 +1896,7 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 
 	rte_intr_callback_register(intr_handle,
 				   ena_interrupt_handler_rte,
-				   adapter);
+				   eth_dev);
 	rte_intr_enable(intr_handle);
 	ena_com_set_admin_polling_mode(ena_dev, false);
 	ena_com_admin_aenq_enable(ena_dev);
@@ -2679,7 +2679,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)
@@ -2728,7 +2728,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;
@@ -2953,14 +2953,12 @@ RTE_LOG_REGISTER_SUFFIX(ena_logtype_com, com, NOTICE);
 static void ena_update_on_link_change(void *adapter_data,
 				      struct ena_admin_aenq_entry *aenq_e)
 {
-	struct rte_eth_dev *eth_dev;
-	struct ena_adapter *adapter;
+	struct rte_eth_dev *eth_dev = adapter_data;
+	struct ena_adapter *adapter = eth_dev->data->dev_private;
 	struct ena_admin_aenq_link_change_desc *aenq_link_desc;
 	uint32_t status;
 
-	adapter = adapter_data;
 	aenq_link_desc = (struct ena_admin_aenq_link_change_desc *)aenq_e;
-	eth_dev = adapter->rte_dev;
 
 	status = get_ena_admin_aenq_link_change_desc_link_status(aenq_link_desc);
 	adapter->link_status = status;
@@ -2969,10 +2967,11 @@ static void ena_update_on_link_change(void *adapter_data,
 	rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL);
 }
 
-static void ena_notification(void *data,
+static void ena_notification(void *adapter_data,
 			     struct ena_admin_aenq_entry *aenq_e)
 {
-	struct ena_adapter *adapter = data;
+	struct rte_eth_dev *eth_dev = adapter_data;
+	struct ena_adapter *adapter = eth_dev->data->dev_private;
 	struct ena_admin_ena_hw_hints *hints;
 
 	if (aenq_e->aenq_common_desc.group != ENA_ADMIN_NOTIFICATION)
@@ -2995,7 +2994,8 @@ static void ena_notification(void *data,
 static void ena_keep_alive(void *adapter_data,
 			   __rte_unused struct ena_admin_aenq_entry *aenq_e)
 {
-	struct ena_adapter *adapter = adapter_data;
+	struct rte_eth_dev *eth_dev = adapter_data;
+	struct ena_adapter *adapter = eth_dev->data->dev_private;
 	struct ena_admin_aenq_keep_alive_desc *desc;
 	uint64_t rx_drops;
 	uint64_t tx_drops;
drivers/net/ena/ena_ethdev.h +1 -3
index ae235897ee..78718b759b 100644
@@ -210,9 +210,7 @@ struct ena_offloads {
 /* 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;
 
 	struct ena_com_dev ena_dev __rte_cache_aligned;
 
Signature · 1 line
2.25.1
#117 lore raw

PATCH v5 3/3 net/ena: disable dev ops not supported by secondary process

In reply to Michal Krawczyk

From: Stanislaw Kardach <[email protected]>

For dev_ops not supported by the secondary process, either return -EPERM or return without doing anything. In both cases log a warning.

It's still application's responsibility to avoid calls like that and those changes are for debugging/informational purposes.

---
v5:
* Fix commit log.

v4:
* Fix commit heading style.

 drivers/net/ena/ena_ethdev.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/net/ena/ena_ethdev.c +18 -0
index e310e7ae8c..dfe68279fa 100644
@@ -535,6 +535,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)
@@ -1059,6 +1065,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;
@@ -1105,6 +1117,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
#118 lore raw
In reply to Michal Krawczyk
Quoted 44 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.

Since v5, the series contains only 3, unmerged patches.

v5:
* Indicate RSS hash offload in the Rx capabilities field.
* Changes made to 'making the ethdev references multiprocess safe:
- rework commit log,
- remove adapter::port_id field.
* Change made to "disable dev ops not supported by secondary process":
- rework commit log.

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 of 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.

Quoted 7 lines

Michal Krawczyk (1):
net/ena: indicate Rx RSS hash presence

Stanislaw Kardach (2):
net/ena: make ethdev references multiprocess safe net/ena: disable dev ops not supported by secondary process

Series applied to dpdk-next-net/main, thanks.

#119 lore raw
In reply to Michal Krawczyk
Quoted 6 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.

Quoted 8 lines

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.

Hi Michal,

I want to confirm if this set is for this release or for v21.08.

Since it is sent late, after -rc1, getting the series for the -rc3 won't give you any time to test it properly or fix any new found issues before release.

My suggestion is to wait for next release, but can you please confirm if you want to get the risk and get the patch for this release or wait for v21.08?

Thanks,
ferruh

#120 lore raw

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

Quoted 19 lines · Michal Krawczyk
Quoted 6 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.

Quoted 8 lines

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.

Hi Michal,

Quoted 7 lines

I want to confirm if this set is for this release or for v21.08.

Since it is sent late, after -rc1, getting the series for the -rc3 won't give you any time to test it properly or fix any new found issues before release.

My suggestion is to wait for next release, but can you please confirm if you want to get the risk and get the patch for this release or wait for v21.08?

Hi Ferruh,

as this ENA release mainly introduces HAL upgrade and some bug fixes, we would like to take a risk and get the patches for this release if you're ok with that. Of course we can postpone some changes to the next release if needed, but although there are multiple patches, most of them are not the big ones (and there are no new features).

Thanks,
Michal

Quoted 3 lines

Thanks,
ferruh