DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 1/1] common/cnxk: fix static assertion failure
@ 2022-03-02 12:07 Vamsi Attunuru
  2022-03-02 12:46 ` Jerin Jacob
  2022-03-02 13:46 ` [PATCH v2 " Vamsi Attunuru
  0 siblings, 2 replies; 11+ messages in thread
From: Vamsi Attunuru @ 2022-03-02 12:07 UTC (permalink / raw)
  To: dev; +Cc: jerinj, vattunuru, ndabilpuram, Srikanth Yalavarthi

use dynamically allocated memory for storing soft expiry
ring base addresses which fixes the static assertion failure,
size of this dynamic allocation depends on RTE_MAX_ETHPORTS
which varies based on the build config.

Fixes: d26185716d3f ("net/cnxk: support outbound soft expiry
notification")

Signed-off-by: Vamsi Attunuru <vattunuru@marvell.com>
Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
---
 drivers/common/cnxk/roc_nix_inl.c      | 23 +++++++++++++----------
 drivers/common/cnxk/roc_nix_inl.h      |  2 +-
 drivers/common/cnxk/roc_nix_inl_dev.c  | 11 ++++++++++-
 drivers/common/cnxk/roc_nix_inl_priv.h |  2 +-
 drivers/common/cnxk/roc_platform.h     | 16 ++++++++++++++++
 5 files changed, 41 insertions(+), 13 deletions(-)

diff --git a/drivers/common/cnxk/roc_nix_inl.c b/drivers/common/cnxk/roc_nix_inl.c
index 11ed157703..826c6e99c1 100644
--- a/drivers/common/cnxk/roc_nix_inl.c
+++ b/drivers/common/cnxk/roc_nix_inl.c
@@ -330,12 +330,13 @@ roc_nix_inl_outb_init(struct roc_nix *roc_nix)
 	struct dev *dev = &nix->dev;
 	struct msix_offset_rsp *rsp;
 	struct nix_inl_dev *inl_dev;
+	size_t sa_sz, ring_sz;
 	uint16_t sso_pffunc;
 	uint8_t eng_grpmask;
 	uint64_t blkaddr, i;
+	uint64_t *ring_base;
 	uint16_t nb_lf;
 	void *sa_base;
-	size_t sa_sz;
 	int j, rc;
 	void *sa;
 
@@ -468,16 +469,16 @@ roc_nix_inl_outb_init(struct roc_nix *roc_nix)
 	/* Allocate memory to be used as a ring buffer to poll for
 	 * soft expiry event from ucode
 	 */
+	ring_sz = (ROC_IPSEC_ERR_RING_MAX_ENTRY + 1) * sizeof(uint64_t);
+	ring_base = inl_dev->sa_soft_exp_ring;
 	for (i = 0; i < nix->outb_se_ring_cnt; i++) {
-		inl_dev->sa_soft_exp_ring[nix->outb_se_ring_base + i] =
-			plt_zmalloc((ROC_IPSEC_ERR_RING_MAX_ENTRY + 1) *
-					    sizeof(uint64_t),
-				    0);
-		if (!inl_dev->sa_soft_exp_ring[i]) {
+		ring_base[nix->outb_se_ring_base + i] =
+			PLT_U64_CAST(plt_zmalloc(ring_sz, 0));
+		if (!ring_base[nix->outb_se_ring_base + i]) {
 			plt_err("Couldn't allocate memory for soft exp ring");
 			while (i--)
-				plt_free(inl_dev->sa_soft_exp_ring
-						 [nix->outb_se_ring_base + i]);
+				plt_free(PLT_PTR_CAST(
+					ring_base[nix->outb_se_ring_base + i]));
 			rc = -ENOMEM;
 			goto lf_fini;
 		}
@@ -504,6 +505,7 @@ roc_nix_inl_outb_fini(struct roc_nix *roc_nix)
 	struct idev_cfg *idev = idev_get_cfg();
 	struct dev *dev = &nix->dev;
 	struct nix_inl_dev *inl_dev;
+	uint64_t *ring_base;
 	int i, rc, ret = 0;
 
 	if (!nix->inl_outb_ena)
@@ -537,10 +539,11 @@ roc_nix_inl_outb_fini(struct roc_nix *roc_nix)
 
 	if (idev && idev->nix_inl_dev) {
 		inl_dev = idev->nix_inl_dev;
+		ring_base = inl_dev->sa_soft_exp_ring;
 
 		for (i = 0; i < ROC_NIX_INL_MAX_SOFT_EXP_RNGS; i++) {
-			if (inl_dev->sa_soft_exp_ring[i])
-				plt_free(inl_dev->sa_soft_exp_ring[i]);
+			if (ring_base[i])
+				plt_free(PLT_PTR_CAST(ring_base[i]));
 		}
 	}
 
diff --git a/drivers/common/cnxk/roc_nix_inl.h b/drivers/common/cnxk/roc_nix_inl.h
index 1dc58f2da2..2c2a4d76f2 100644
--- a/drivers/common/cnxk/roc_nix_inl.h
+++ b/drivers/common/cnxk/roc_nix_inl.h
@@ -137,7 +137,7 @@ struct roc_nix_inl_dev {
 	bool set_soft_exp_poll;
 	/* End of input parameters */
 
-#define ROC_NIX_INL_MEM_SZ (2304)
+#define ROC_NIX_INL_MEM_SZ (1280)
 	uint8_t reserved[ROC_NIX_INL_MEM_SZ] __plt_cache_aligned;
 } __plt_cache_aligned;
 
diff --git a/drivers/common/cnxk/roc_nix_inl_dev.c b/drivers/common/cnxk/roc_nix_inl_dev.c
index 1cfcdba3f2..5a032aab52 100644
--- a/drivers/common/cnxk/roc_nix_inl_dev.c
+++ b/drivers/common/cnxk/roc_nix_inl_dev.c
@@ -653,7 +653,7 @@ inl_outb_soft_exp_poll(struct nix_inl_dev *inl_dev, uint32_t ring_idx)
 	uint32_t port_id;
 
 	port_id = ring_idx / ROC_NIX_SOFT_EXP_PER_PORT_MAX_RINGS;
-	ring_base = inl_dev->sa_soft_exp_ring[ring_idx];
+	ring_base = PLT_PTR_CAST(inl_dev->sa_soft_exp_ring[ring_idx]);
 	if (!ring_base) {
 		plt_err("Invalid soft exp ring base");
 		return;
@@ -751,6 +751,14 @@ nix_inl_outb_poll_thread_setup(struct nix_inl_dev *inl_dev)
 
 	inl_dev->soft_exp_ring_bmap_mem = mem;
 	inl_dev->soft_exp_ring_bmap = bmap;
+	inl_dev->sa_soft_exp_ring = plt_zmalloc(
+		ROC_NIX_INL_MAX_SOFT_EXP_RNGS * sizeof(uint64_t), 0);
+	if (!inl_dev->sa_soft_exp_ring) {
+		plt_err("soft expiry ring pointer array alloc failed");
+		plt_free(mem);
+		rc = -ENOMEM;
+		goto exit;
+	}
 
 	for (i = 0; i < ROC_NIX_INL_MAX_SOFT_EXP_RNGS; i++)
 		plt_bitmap_clear(inl_dev->soft_exp_ring_bmap, i);
@@ -896,6 +904,7 @@ roc_nix_inl_dev_fini(struct roc_nix_inl_dev *roc_inl_dev)
 		pthread_join(inl_dev->soft_exp_poll_thread, NULL);
 		plt_bitmap_free(inl_dev->soft_exp_ring_bmap);
 		plt_free(inl_dev->soft_exp_ring_bmap_mem);
+		plt_free(inl_dev->sa_soft_exp_ring);
 	}
 
 	/* Flush Inbound CTX cache entries */
diff --git a/drivers/common/cnxk/roc_nix_inl_priv.h b/drivers/common/cnxk/roc_nix_inl_priv.h
index da6d6e9b03..0fa5e090d4 100644
--- a/drivers/common/cnxk/roc_nix_inl_priv.h
+++ b/drivers/common/cnxk/roc_nix_inl_priv.h
@@ -58,7 +58,7 @@ struct nix_inl_dev {
 	/* OUTB soft expiry poll thread */
 	pthread_t soft_exp_poll_thread;
 	uint32_t soft_exp_poll_freq;
-	void *sa_soft_exp_ring[ROC_NIX_INL_MAX_SOFT_EXP_RNGS];
+	uint64_t *sa_soft_exp_ring;
 
 	/* Soft expiry ring bitmap */
 	struct plt_bitmap *soft_exp_ring_bmap;
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index fa285446bd..267cf6f8fc 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -41,6 +41,7 @@
 #define PLT_MEMZONE_NAMESIZE	 RTE_MEMZONE_NAMESIZE
 #define PLT_STD_C11		 RTE_STD_C11
 #define PLT_PTR_ADD		 RTE_PTR_ADD
+#define PLT_PTR_SUB		 RTE_PTR_SUB
 #define PLT_PTR_DIFF		 RTE_PTR_DIFF
 #define PLT_MAX_RXTX_INTR_VEC_ID RTE_MAX_RXTX_INTR_VEC_ID
 #define PLT_INTR_VEC_RXTX_OFFSET RTE_INTR_VEC_RXTX_OFFSET
@@ -63,6 +64,17 @@
 #ifndef PLT_ETHER_ADDR_LEN
 #define PLT_ETHER_ADDR_LEN RTE_ETHER_ADDR_LEN
 #endif
+
+/* Cast to specific datatypes */
+#define PLT_PTR_CAST(val) ((void *)(val))
+#define PLT_U64_CAST(val) ((uint64_t)(val))
+#define PLT_U32_CAST(val) ((uint32_t)(val))
+#define PLT_U16_CAST(val) ((uint16_t)(val))
+
+/* Add / Sub pointer with scalar and cast to uint64_t */
+#define PLT_PTR_ADD_U64_CAST(__ptr, __x) PLT_U64_CAST(PLT_PTR_ADD(__ptr, __x))
+#define PLT_PTR_SUB_U64_CAST(__ptr, __x) PLT_U64_CAST(PLT_PTR_SUB(__ptr, __x))
+
 /** Divide ceil */
 #define PLT_DIV_CEIL(x, y)			\
 	({					\
@@ -158,6 +170,10 @@
 #define plt_write64(val, addr)                                                 \
 	rte_write64_relaxed((val), (volatile void *)(addr))
 
+#define plt_read32(addr) rte_read32_relaxed((volatile void *)(addr))
+#define plt_write32(val, addr)                                                 \
+	rte_write32_relaxed((val), (volatile void *)(addr))
+
 #define plt_wmb()		rte_wmb()
 #define plt_rmb()		rte_rmb()
 #define plt_io_wmb()		rte_io_wmb()
-- 
2.25.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/1] common/cnxk: fix static assertion failure
  2022-03-02 12:07 [PATCH 1/1] common/cnxk: fix static assertion failure Vamsi Attunuru
@ 2022-03-02 12:46 ` Jerin Jacob
  2022-03-02 13:46 ` [PATCH v2 " Vamsi Attunuru
  1 sibling, 0 replies; 11+ messages in thread
From: Jerin Jacob @ 2022-03-02 12:46 UTC (permalink / raw)
  To: Vamsi Attunuru, YuX
  Cc: dpdk-dev, Jerin Jacob, Nithin Dabilpuram, Srikanth Yalavarthi

On Wed, Mar 2, 2022 at 5:37 PM Vamsi Attunuru <vattunuru@marvell.com> wrote:
>
> use dynamically allocated memory for storing soft expiry

Use

> ring base addresses which fixes the static assertion failure,
> size of this dynamic allocation depends on RTE_MAX_ETHPORTS

as the size of

> which varies based on the build config.
>

Fill Bugzilla ID:

> Fixes: d26185716d3f ("net/cnxk: support outbound soft expiry
> notification")

Please move word "notification" to same line.

Add Cc: stable@dpdk.org

+ @yux.jiang@intel.com

Add Reported-by:


>
> Signed-off-by: Vamsi Attunuru <vattunuru@marvell.com>
> Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
> ---
> +
> +/* Add / Sub pointer with scalar and cast to uint64_t */
> +#define PLT_PTR_ADD_U64_CAST(__ptr, __x) PLT_U64_CAST(PLT_PTR_ADD(__ptr, __x))
> +#define PLT_PTR_SUB_U64_CAST(__ptr, __x) PLT_U64_CAST(PLT_PTR_SUB(__ptr, __x))

Since it is not used in this patch, This line can be removed

> +
>  /** Divide ceil */
>  #define PLT_DIV_CEIL(x, y)                     \
>         ({                                      \
> @@ -158,6 +170,10 @@
>  #define plt_write64(val, addr)                                                 \
>         rte_write64_relaxed((val), (volatile void *)(addr))
>
> +#define plt_read32(addr) rte_read32_relaxed((volatile void *)(addr))
> +#define plt_write32(val, addr)                                                 \
> +       rte_write32_relaxed((val), (volatile void *)(addr))

Since it is not used in this patch, This line can be removed

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 1/1] common/cnxk: fix static assertion failure
  2022-03-02 12:07 [PATCH 1/1] common/cnxk: fix static assertion failure Vamsi Attunuru
  2022-03-02 12:46 ` Jerin Jacob
@ 2022-03-02 13:46 ` Vamsi Attunuru
  2022-03-03  5:59   ` Jerin Jacob
                     ` (2 more replies)
  1 sibling, 3 replies; 11+ messages in thread
From: Vamsi Attunuru @ 2022-03-02 13:46 UTC (permalink / raw)
  To: dev
  Cc: jerinj, vattunuru, ndabilpuram, yux.jiang, stable, Wei Ling,
	Srikanth Yalavarthi

Use dynamically allocated memory for storing soft expiry
ring base addresses which fixes the static assertion failure,
as the size of dynamic allocation depends on RTE_MAX_ETHPORTS
which varies based on the build config.

Bugzilla ID: 940
Fixes: d26185716d3f ("net/cnxk: support outbound soft expiry notification")
Cc: stable@dpdk.org

Reported-by: Wei Ling <weix.ling@intel.com>
Reported-by: Yu Jiang <yux.jiang@intel.com>
Signed-off-by: Vamsi Attunuru <vattunuru@marvell.com>
Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
---
V2: Add bugzilla & reportee details, remove unused changes.
---
 drivers/common/cnxk/roc_nix_inl.c      | 23 +++++++++++++----------
 drivers/common/cnxk/roc_nix_inl.h      |  2 +-
 drivers/common/cnxk/roc_nix_inl_dev.c  | 11 ++++++++++-
 drivers/common/cnxk/roc_nix_inl_priv.h |  2 +-
 drivers/common/cnxk/roc_platform.h     |  7 +++++++
 5 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/drivers/common/cnxk/roc_nix_inl.c b/drivers/common/cnxk/roc_nix_inl.c
index 11ed157703..826c6e99c1 100644
--- a/drivers/common/cnxk/roc_nix_inl.c
+++ b/drivers/common/cnxk/roc_nix_inl.c
@@ -330,12 +330,13 @@ roc_nix_inl_outb_init(struct roc_nix *roc_nix)
 	struct dev *dev = &nix->dev;
 	struct msix_offset_rsp *rsp;
 	struct nix_inl_dev *inl_dev;
+	size_t sa_sz, ring_sz;
 	uint16_t sso_pffunc;
 	uint8_t eng_grpmask;
 	uint64_t blkaddr, i;
+	uint64_t *ring_base;
 	uint16_t nb_lf;
 	void *sa_base;
-	size_t sa_sz;
 	int j, rc;
 	void *sa;
 
@@ -468,16 +469,16 @@ roc_nix_inl_outb_init(struct roc_nix *roc_nix)
 	/* Allocate memory to be used as a ring buffer to poll for
 	 * soft expiry event from ucode
 	 */
+	ring_sz = (ROC_IPSEC_ERR_RING_MAX_ENTRY + 1) * sizeof(uint64_t);
+	ring_base = inl_dev->sa_soft_exp_ring;
 	for (i = 0; i < nix->outb_se_ring_cnt; i++) {
-		inl_dev->sa_soft_exp_ring[nix->outb_se_ring_base + i] =
-			plt_zmalloc((ROC_IPSEC_ERR_RING_MAX_ENTRY + 1) *
-					    sizeof(uint64_t),
-				    0);
-		if (!inl_dev->sa_soft_exp_ring[i]) {
+		ring_base[nix->outb_se_ring_base + i] =
+			PLT_U64_CAST(plt_zmalloc(ring_sz, 0));
+		if (!ring_base[nix->outb_se_ring_base + i]) {
 			plt_err("Couldn't allocate memory for soft exp ring");
 			while (i--)
-				plt_free(inl_dev->sa_soft_exp_ring
-						 [nix->outb_se_ring_base + i]);
+				plt_free(PLT_PTR_CAST(
+					ring_base[nix->outb_se_ring_base + i]));
 			rc = -ENOMEM;
 			goto lf_fini;
 		}
@@ -504,6 +505,7 @@ roc_nix_inl_outb_fini(struct roc_nix *roc_nix)
 	struct idev_cfg *idev = idev_get_cfg();
 	struct dev *dev = &nix->dev;
 	struct nix_inl_dev *inl_dev;
+	uint64_t *ring_base;
 	int i, rc, ret = 0;
 
 	if (!nix->inl_outb_ena)
@@ -537,10 +539,11 @@ roc_nix_inl_outb_fini(struct roc_nix *roc_nix)
 
 	if (idev && idev->nix_inl_dev) {
 		inl_dev = idev->nix_inl_dev;
+		ring_base = inl_dev->sa_soft_exp_ring;
 
 		for (i = 0; i < ROC_NIX_INL_MAX_SOFT_EXP_RNGS; i++) {
-			if (inl_dev->sa_soft_exp_ring[i])
-				plt_free(inl_dev->sa_soft_exp_ring[i]);
+			if (ring_base[i])
+				plt_free(PLT_PTR_CAST(ring_base[i]));
 		}
 	}
 
diff --git a/drivers/common/cnxk/roc_nix_inl.h b/drivers/common/cnxk/roc_nix_inl.h
index 1dc58f2da2..2c2a4d76f2 100644
--- a/drivers/common/cnxk/roc_nix_inl.h
+++ b/drivers/common/cnxk/roc_nix_inl.h
@@ -137,7 +137,7 @@ struct roc_nix_inl_dev {
 	bool set_soft_exp_poll;
 	/* End of input parameters */
 
-#define ROC_NIX_INL_MEM_SZ (2304)
+#define ROC_NIX_INL_MEM_SZ (1280)
 	uint8_t reserved[ROC_NIX_INL_MEM_SZ] __plt_cache_aligned;
 } __plt_cache_aligned;
 
diff --git a/drivers/common/cnxk/roc_nix_inl_dev.c b/drivers/common/cnxk/roc_nix_inl_dev.c
index 1cfcdba3f2..5a032aab52 100644
--- a/drivers/common/cnxk/roc_nix_inl_dev.c
+++ b/drivers/common/cnxk/roc_nix_inl_dev.c
@@ -653,7 +653,7 @@ inl_outb_soft_exp_poll(struct nix_inl_dev *inl_dev, uint32_t ring_idx)
 	uint32_t port_id;
 
 	port_id = ring_idx / ROC_NIX_SOFT_EXP_PER_PORT_MAX_RINGS;
-	ring_base = inl_dev->sa_soft_exp_ring[ring_idx];
+	ring_base = PLT_PTR_CAST(inl_dev->sa_soft_exp_ring[ring_idx]);
 	if (!ring_base) {
 		plt_err("Invalid soft exp ring base");
 		return;
@@ -751,6 +751,14 @@ nix_inl_outb_poll_thread_setup(struct nix_inl_dev *inl_dev)
 
 	inl_dev->soft_exp_ring_bmap_mem = mem;
 	inl_dev->soft_exp_ring_bmap = bmap;
+	inl_dev->sa_soft_exp_ring = plt_zmalloc(
+		ROC_NIX_INL_MAX_SOFT_EXP_RNGS * sizeof(uint64_t), 0);
+	if (!inl_dev->sa_soft_exp_ring) {
+		plt_err("soft expiry ring pointer array alloc failed");
+		plt_free(mem);
+		rc = -ENOMEM;
+		goto exit;
+	}
 
 	for (i = 0; i < ROC_NIX_INL_MAX_SOFT_EXP_RNGS; i++)
 		plt_bitmap_clear(inl_dev->soft_exp_ring_bmap, i);
@@ -896,6 +904,7 @@ roc_nix_inl_dev_fini(struct roc_nix_inl_dev *roc_inl_dev)
 		pthread_join(inl_dev->soft_exp_poll_thread, NULL);
 		plt_bitmap_free(inl_dev->soft_exp_ring_bmap);
 		plt_free(inl_dev->soft_exp_ring_bmap_mem);
+		plt_free(inl_dev->sa_soft_exp_ring);
 	}
 
 	/* Flush Inbound CTX cache entries */
diff --git a/drivers/common/cnxk/roc_nix_inl_priv.h b/drivers/common/cnxk/roc_nix_inl_priv.h
index da6d6e9b03..0fa5e090d4 100644
--- a/drivers/common/cnxk/roc_nix_inl_priv.h
+++ b/drivers/common/cnxk/roc_nix_inl_priv.h
@@ -58,7 +58,7 @@ struct nix_inl_dev {
 	/* OUTB soft expiry poll thread */
 	pthread_t soft_exp_poll_thread;
 	uint32_t soft_exp_poll_freq;
-	void *sa_soft_exp_ring[ROC_NIX_INL_MAX_SOFT_EXP_RNGS];
+	uint64_t *sa_soft_exp_ring;
 
 	/* Soft expiry ring bitmap */
 	struct plt_bitmap *soft_exp_ring_bmap;
diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
index fa285446bd..28004b1743 100644
--- a/drivers/common/cnxk/roc_platform.h
+++ b/drivers/common/cnxk/roc_platform.h
@@ -63,6 +63,13 @@
 #ifndef PLT_ETHER_ADDR_LEN
 #define PLT_ETHER_ADDR_LEN RTE_ETHER_ADDR_LEN
 #endif
+
+/* Cast to specific datatypes */
+#define PLT_PTR_CAST(val) ((void *)(val))
+#define PLT_U64_CAST(val) ((uint64_t)(val))
+#define PLT_U32_CAST(val) ((uint32_t)(val))
+#define PLT_U16_CAST(val) ((uint16_t)(val))
+
 /** Divide ceil */
 #define PLT_DIV_CEIL(x, y)			\
 	({					\
-- 
2.25.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/1] common/cnxk: fix static assertion failure
  2022-03-02 13:46 ` [PATCH v2 " Vamsi Attunuru
@ 2022-03-03  5:59   ` Jerin Jacob
  2022-03-03 11:54   ` Ling, WeiX
  2022-03-03 17:21   ` Ferruh Yigit
  2 siblings, 0 replies; 11+ messages in thread
From: Jerin Jacob @ 2022-03-03  5:59 UTC (permalink / raw)
  To: Vamsi Attunuru, Ferruh Yigit
  Cc: dpdk-dev, Jerin Jacob, Nithin Dabilpuram, YuX, dpdk stable,
	Wei Ling, Srikanth Yalavarthi

On Wed, Mar 2, 2022 at 7:18 PM Vamsi Attunuru <vattunuru@marvell.com> wrote:
>
> Use dynamically allocated memory for storing soft expiry
> ring base addresses which fixes the static assertion failure,
> as the size of dynamic allocation depends on RTE_MAX_ETHPORTS
> which varies based on the build config.
>
> Bugzilla ID: 940
> Fixes: d26185716d3f ("net/cnxk: support outbound soft expiry notification")
> Cc: stable@dpdk.org
>
> Reported-by: Wei Ling <weix.ling@intel.com>
> Reported-by: Yu Jiang <yux.jiang@intel.com>
> Signed-off-by: Vamsi Attunuru <vattunuru@marvell.com>
> Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>

Acked-by: Jerin Jacob <jerinj@marvell.com>
Applied to dpdk-next-net-mrvl/for-next-net. Thanks


> ---
> V2: Add bugzilla & reportee details, remove unused changes.
> ---
>  drivers/common/cnxk/roc_nix_inl.c      | 23 +++++++++++++----------
>  drivers/common/cnxk/roc_nix_inl.h      |  2 +-
>  drivers/common/cnxk/roc_nix_inl_dev.c  | 11 ++++++++++-
>  drivers/common/cnxk/roc_nix_inl_priv.h |  2 +-
>  drivers/common/cnxk/roc_platform.h     |  7 +++++++
>  5 files changed, 32 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/common/cnxk/roc_nix_inl.c b/drivers/common/cnxk/roc_nix_inl.c
> index 11ed157703..826c6e99c1 100644
> --- a/drivers/common/cnxk/roc_nix_inl.c
> +++ b/drivers/common/cnxk/roc_nix_inl.c
> @@ -330,12 +330,13 @@ roc_nix_inl_outb_init(struct roc_nix *roc_nix)
>         struct dev *dev = &nix->dev;
>         struct msix_offset_rsp *rsp;
>         struct nix_inl_dev *inl_dev;
> +       size_t sa_sz, ring_sz;
>         uint16_t sso_pffunc;
>         uint8_t eng_grpmask;
>         uint64_t blkaddr, i;
> +       uint64_t *ring_base;
>         uint16_t nb_lf;
>         void *sa_base;
> -       size_t sa_sz;
>         int j, rc;
>         void *sa;
>
> @@ -468,16 +469,16 @@ roc_nix_inl_outb_init(struct roc_nix *roc_nix)
>         /* Allocate memory to be used as a ring buffer to poll for
>          * soft expiry event from ucode
>          */
> +       ring_sz = (ROC_IPSEC_ERR_RING_MAX_ENTRY + 1) * sizeof(uint64_t);
> +       ring_base = inl_dev->sa_soft_exp_ring;
>         for (i = 0; i < nix->outb_se_ring_cnt; i++) {
> -               inl_dev->sa_soft_exp_ring[nix->outb_se_ring_base + i] =
> -                       plt_zmalloc((ROC_IPSEC_ERR_RING_MAX_ENTRY + 1) *
> -                                           sizeof(uint64_t),
> -                                   0);
> -               if (!inl_dev->sa_soft_exp_ring[i]) {
> +               ring_base[nix->outb_se_ring_base + i] =
> +                       PLT_U64_CAST(plt_zmalloc(ring_sz, 0));
> +               if (!ring_base[nix->outb_se_ring_base + i]) {
>                         plt_err("Couldn't allocate memory for soft exp ring");
>                         while (i--)
> -                               plt_free(inl_dev->sa_soft_exp_ring
> -                                                [nix->outb_se_ring_base + i]);
> +                               plt_free(PLT_PTR_CAST(
> +                                       ring_base[nix->outb_se_ring_base + i]));
>                         rc = -ENOMEM;
>                         goto lf_fini;
>                 }
> @@ -504,6 +505,7 @@ roc_nix_inl_outb_fini(struct roc_nix *roc_nix)
>         struct idev_cfg *idev = idev_get_cfg();
>         struct dev *dev = &nix->dev;
>         struct nix_inl_dev *inl_dev;
> +       uint64_t *ring_base;
>         int i, rc, ret = 0;
>
>         if (!nix->inl_outb_ena)
> @@ -537,10 +539,11 @@ roc_nix_inl_outb_fini(struct roc_nix *roc_nix)
>
>         if (idev && idev->nix_inl_dev) {
>                 inl_dev = idev->nix_inl_dev;
> +               ring_base = inl_dev->sa_soft_exp_ring;
>
>                 for (i = 0; i < ROC_NIX_INL_MAX_SOFT_EXP_RNGS; i++) {
> -                       if (inl_dev->sa_soft_exp_ring[i])
> -                               plt_free(inl_dev->sa_soft_exp_ring[i]);
> +                       if (ring_base[i])
> +                               plt_free(PLT_PTR_CAST(ring_base[i]));
>                 }
>         }
>
> diff --git a/drivers/common/cnxk/roc_nix_inl.h b/drivers/common/cnxk/roc_nix_inl.h
> index 1dc58f2da2..2c2a4d76f2 100644
> --- a/drivers/common/cnxk/roc_nix_inl.h
> +++ b/drivers/common/cnxk/roc_nix_inl.h
> @@ -137,7 +137,7 @@ struct roc_nix_inl_dev {
>         bool set_soft_exp_poll;
>         /* End of input parameters */
>
> -#define ROC_NIX_INL_MEM_SZ (2304)
> +#define ROC_NIX_INL_MEM_SZ (1280)
>         uint8_t reserved[ROC_NIX_INL_MEM_SZ] __plt_cache_aligned;
>  } __plt_cache_aligned;
>
> diff --git a/drivers/common/cnxk/roc_nix_inl_dev.c b/drivers/common/cnxk/roc_nix_inl_dev.c
> index 1cfcdba3f2..5a032aab52 100644
> --- a/drivers/common/cnxk/roc_nix_inl_dev.c
> +++ b/drivers/common/cnxk/roc_nix_inl_dev.c
> @@ -653,7 +653,7 @@ inl_outb_soft_exp_poll(struct nix_inl_dev *inl_dev, uint32_t ring_idx)
>         uint32_t port_id;
>
>         port_id = ring_idx / ROC_NIX_SOFT_EXP_PER_PORT_MAX_RINGS;
> -       ring_base = inl_dev->sa_soft_exp_ring[ring_idx];
> +       ring_base = PLT_PTR_CAST(inl_dev->sa_soft_exp_ring[ring_idx]);
>         if (!ring_base) {
>                 plt_err("Invalid soft exp ring base");
>                 return;
> @@ -751,6 +751,14 @@ nix_inl_outb_poll_thread_setup(struct nix_inl_dev *inl_dev)
>
>         inl_dev->soft_exp_ring_bmap_mem = mem;
>         inl_dev->soft_exp_ring_bmap = bmap;
> +       inl_dev->sa_soft_exp_ring = plt_zmalloc(
> +               ROC_NIX_INL_MAX_SOFT_EXP_RNGS * sizeof(uint64_t), 0);
> +       if (!inl_dev->sa_soft_exp_ring) {
> +               plt_err("soft expiry ring pointer array alloc failed");
> +               plt_free(mem);
> +               rc = -ENOMEM;
> +               goto exit;
> +       }
>
>         for (i = 0; i < ROC_NIX_INL_MAX_SOFT_EXP_RNGS; i++)
>                 plt_bitmap_clear(inl_dev->soft_exp_ring_bmap, i);
> @@ -896,6 +904,7 @@ roc_nix_inl_dev_fini(struct roc_nix_inl_dev *roc_inl_dev)
>                 pthread_join(inl_dev->soft_exp_poll_thread, NULL);
>                 plt_bitmap_free(inl_dev->soft_exp_ring_bmap);
>                 plt_free(inl_dev->soft_exp_ring_bmap_mem);
> +               plt_free(inl_dev->sa_soft_exp_ring);
>         }
>
>         /* Flush Inbound CTX cache entries */
> diff --git a/drivers/common/cnxk/roc_nix_inl_priv.h b/drivers/common/cnxk/roc_nix_inl_priv.h
> index da6d6e9b03..0fa5e090d4 100644
> --- a/drivers/common/cnxk/roc_nix_inl_priv.h
> +++ b/drivers/common/cnxk/roc_nix_inl_priv.h
> @@ -58,7 +58,7 @@ struct nix_inl_dev {
>         /* OUTB soft expiry poll thread */
>         pthread_t soft_exp_poll_thread;
>         uint32_t soft_exp_poll_freq;
> -       void *sa_soft_exp_ring[ROC_NIX_INL_MAX_SOFT_EXP_RNGS];
> +       uint64_t *sa_soft_exp_ring;
>
>         /* Soft expiry ring bitmap */
>         struct plt_bitmap *soft_exp_ring_bmap;
> diff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h
> index fa285446bd..28004b1743 100644
> --- a/drivers/common/cnxk/roc_platform.h
> +++ b/drivers/common/cnxk/roc_platform.h
> @@ -63,6 +63,13 @@
>  #ifndef PLT_ETHER_ADDR_LEN
>  #define PLT_ETHER_ADDR_LEN RTE_ETHER_ADDR_LEN
>  #endif
> +
> +/* Cast to specific datatypes */
> +#define PLT_PTR_CAST(val) ((void *)(val))
> +#define PLT_U64_CAST(val) ((uint64_t)(val))
> +#define PLT_U32_CAST(val) ((uint32_t)(val))
> +#define PLT_U16_CAST(val) ((uint16_t)(val))
> +
>  /** Divide ceil */
>  #define PLT_DIV_CEIL(x, y)                     \
>         ({                                      \
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH v2 1/1] common/cnxk: fix static assertion failure
  2022-03-02 13:46 ` [PATCH v2 " Vamsi Attunuru
  2022-03-03  5:59   ` Jerin Jacob
@ 2022-03-03 11:54   ` Ling, WeiX
  2022-03-03 17:21   ` Ferruh Yigit
  2 siblings, 0 replies; 11+ messages in thread
From: Ling, WeiX @ 2022-03-03 11:54 UTC (permalink / raw)
  To: Vamsi Attunuru, dev
  Cc: jerinj, ndabilpuram, Jiang, YuX, stable, Srikanth Yalavarthi

> -----Original Message-----
> From: Vamsi Attunuru <vattunuru@marvell.com>
> Sent: Wednesday, March 2, 2022 9:47 PM
> To: dev@dpdk.org
> Cc: jerinj@marvell.com; vattunuru@marvell.com; ndabilpuram@marvell.com;
> Jiang, YuX <yux.jiang@intel.com>; stable@dpdk.org; Ling, WeiX
> <weix.ling@intel.com>; Srikanth Yalavarthi <syalavarthi@marvell.com>
> Subject: [PATCH v2 1/1] common/cnxk: fix static assertion failure
> 
> Use dynamically allocated memory for storing soft expiry ring base addresses
> which fixes the static assertion failure, as the size of dynamic allocation
> depends on RTE_MAX_ETHPORTS which varies based on the build config.
> 
> Bugzilla ID: 940
> Fixes: d26185716d3f ("net/cnxk: support outbound soft expiry notification")
> Cc: stable@dpdk.org
> 
> Reported-by: Wei Ling <weix.ling@intel.com>
> Reported-by: Yu Jiang <yux.jiang@intel.com>
> Signed-off-by: Vamsi Attunuru <vattunuru@marvell.com>
> Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
> ---

Tested-by: Wei Ling <weix.ling@intel.com>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/1] common/cnxk: fix static assertion failure
  2022-03-02 13:46 ` [PATCH v2 " Vamsi Attunuru
  2022-03-03  5:59   ` Jerin Jacob
  2022-03-03 11:54   ` Ling, WeiX
@ 2022-03-03 17:21   ` Ferruh Yigit
  2022-03-04 10:20     ` [EXT] " Vamsi Krishna Attunuru
  2 siblings, 1 reply; 11+ messages in thread
From: Ferruh Yigit @ 2022-03-03 17:21 UTC (permalink / raw)
  To: Vamsi Attunuru, dev
  Cc: jerinj, ndabilpuram, yux.jiang, stable, Wei Ling, Srikanth Yalavarthi

On 3/2/2022 1:46 PM, Vamsi Attunuru wrote:
> Use dynamically allocated memory for storing soft expiry
> ring base addresses which fixes the static assertion failure,
> as the size of dynamic allocation depends on RTE_MAX_ETHPORTS
> which varies based on the build config.
> 

Hi Vamsi,

"fix static assertion failure" is not enough descriptive.
assertions already added to verify assumptions, and in this case
it seems it failed, but what was actually wrong?

Is it that allocated memory size for ring wrong? (this is what I got
from commit log but I am not sure)

Can you please describe what actually was wrong and fixed now?

> Bugzilla ID: 940
> Fixes: d26185716d3f ("net/cnxk: support outbound soft expiry notification")
> Cc:stable@dpdk.org
> 
> Reported-by: Wei Ling<weix.ling@intel.com>
> Reported-by: Yu Jiang<yux.jiang@intel.com>
> Signed-off-by: Vamsi Attunuru<vattunuru@marvell.com>
> Signed-off-by: Srikanth Yalavarthi<syalavarthi@marvell.com>
> ---
> V2: Add bugzilla & reportee details, remove unused changes.
> ---


^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [EXT] Re: [PATCH v2 1/1] common/cnxk: fix static assertion failure
  2022-03-03 17:21   ` Ferruh Yigit
@ 2022-03-04 10:20     ` Vamsi Krishna Attunuru
  2022-03-04 11:15       ` Ferruh Yigit
  2022-03-04 13:14       ` Ferruh Yigit
  0 siblings, 2 replies; 11+ messages in thread
From: Vamsi Krishna Attunuru @ 2022-03-04 10:20 UTC (permalink / raw)
  To: Ferruh Yigit, dev
  Cc: Jerin Jacob Kollanukkaran, Nithin Kumar Dabilpuram, yux.jiang,
	stable, Wei Ling, Srikanth Yalavarthi



> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Thursday, March 3, 2022 10:52 PM
> To: Vamsi Krishna Attunuru <vattunuru@marvell.com>; dev@dpdk.org
> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Nithin Kumar
> Dabilpuram <ndabilpuram@marvell.com>; yux.jiang@intel.com;
> stable@dpdk.org; Wei Ling <weix.ling@intel.com>; Srikanth Yalavarthi
> <syalavarthi@marvell.com>
> Subject: [EXT] Re: [PATCH v2 1/1] common/cnxk: fix static assertion failure
> 
> External Email
> 
> ----------------------------------------------------------------------
> On 3/2/2022 1:46 PM, Vamsi Attunuru wrote:
> > Use dynamically allocated memory for storing soft expiry ring base
> > addresses which fixes the static assertion failure, as the size of
> > dynamic allocation depends on RTE_MAX_ETHPORTS which varies based on
> > the build config.
> >
> 
> Hi Vamsi,
> 
> "fix static assertion failure" is not enough descriptive.
> assertions already added to verify assumptions, and in this case it seems it
> failed, but what was actually wrong?
> 
> Is it that allocated memory size for ring wrong? (this is what I got from
> commit log but I am not sure)
> 
> Can you please describe what actually was wrong and fixed now?
> 
Hi Ferruh,

Earlier sa_soft_exp_ring struct member was an array of pointers and it's size is linked to num RTE_MAX_ETHPORTS, 
and the whole struct size is confined and protected by size assertion.  It resulted in build failure with -Dmax_ethports=1024
option and assertion caught that failure. V2 fixes the issues by allocating the required memory dynamically instead
 of using array of pointers.

> > Bugzilla ID: 940
> > Fixes: d26185716d3f ("net/cnxk: support outbound soft expiry
> > notification") Cc:stable@dpdk.org
> >
> > Reported-by: Wei Ling<weix.ling@intel.com>
> > Reported-by: Yu Jiang<yux.jiang@intel.com>
> > Signed-off-by: Vamsi Attunuru<vattunuru@marvell.com>
> > Signed-off-by: Srikanth Yalavarthi<syalavarthi@marvell.com>
> > ---
> > V2: Add bugzilla & reportee details, remove unused changes.
> > ---


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [EXT] Re: [PATCH v2 1/1] common/cnxk: fix static assertion failure
  2022-03-04 10:20     ` [EXT] " Vamsi Krishna Attunuru
@ 2022-03-04 11:15       ` Ferruh Yigit
  2022-03-04 11:45         ` Vamsi Krishna Attunuru
  2022-03-04 13:14       ` Ferruh Yigit
  1 sibling, 1 reply; 11+ messages in thread
From: Ferruh Yigit @ 2022-03-04 11:15 UTC (permalink / raw)
  To: Vamsi Krishna Attunuru, dev
  Cc: Jerin Jacob Kollanukkaran, Nithin Kumar Dabilpuram, yux.jiang,
	stable, Wei Ling, Srikanth Yalavarthi

On 3/4/2022 10:20 AM, Vamsi Krishna Attunuru wrote:
> 
> 
>> -----Original Message-----
>> From: Ferruh Yigit <ferruh.yigit@intel.com>
>> Sent: Thursday, March 3, 2022 10:52 PM
>> To: Vamsi Krishna Attunuru <vattunuru@marvell.com>; dev@dpdk.org
>> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Nithin Kumar
>> Dabilpuram <ndabilpuram@marvell.com>; yux.jiang@intel.com;
>> stable@dpdk.org; Wei Ling <weix.ling@intel.com>; Srikanth Yalavarthi
>> <syalavarthi@marvell.com>
>> Subject: [EXT] Re: [PATCH v2 1/1] common/cnxk: fix static assertion failure
>>
>> External Email
>>
>> ----------------------------------------------------------------------
>> On 3/2/2022 1:46 PM, Vamsi Attunuru wrote:
>>> Use dynamically allocated memory for storing soft expiry ring base
>>> addresses which fixes the static assertion failure, as the size of
>>> dynamic allocation depends on RTE_MAX_ETHPORTS which varies based on
>>> the build config.
>>>
>>
>> Hi Vamsi,
>>
>> "fix static assertion failure" is not enough descriptive.
>> assertions already added to verify assumptions, and in this case it seems it
>> failed, but what was actually wrong?
>>
>> Is it that allocated memory size for ring wrong? (this is what I got from
>> commit log but I am not sure)
>>
>> Can you please describe what actually was wrong and fixed now?
>>
> Hi Ferruh,
> 
> Earlier sa_soft_exp_ring struct member was an array of pointers and it's size is linked to num RTE_MAX_ETHPORTS,
> and the whole struct size is confined and protected by size assertion.  It resulted in build failure with -Dmax_ethports=1024
> option and assertion caught that failure. V2 fixes the issues by allocating the required memory dynamically instead
>   of using array of pointers.
> 

Thanks Vamsi for details,

I was expecting a new version of patch with updated commit log,
but to make patch for -rc3 I will update it in next-net according
above information

>>> Bugzilla ID: 940
>>> Fixes: d26185716d3f ("net/cnxk: support outbound soft expiry
>>> notification") Cc:stable@dpdk.org
>>>
>>> Reported-by: Wei Ling<weix.ling@intel.com>
>>> Reported-by: Yu Jiang<yux.jiang@intel.com>
>>> Signed-off-by: Vamsi Attunuru<vattunuru@marvell.com>
>>> Signed-off-by: Srikanth Yalavarthi<syalavarthi@marvell.com>
>>> ---
>>> V2: Add bugzilla & reportee details, remove unused changes.
>>> ---
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [EXT] Re: [PATCH v2 1/1] common/cnxk: fix static assertion failure
  2022-03-04 11:15       ` Ferruh Yigit
@ 2022-03-04 11:45         ` Vamsi Krishna Attunuru
  0 siblings, 0 replies; 11+ messages in thread
From: Vamsi Krishna Attunuru @ 2022-03-04 11:45 UTC (permalink / raw)
  To: Ferruh Yigit, dev
  Cc: Jerin Jacob Kollanukkaran, Nithin Kumar Dabilpuram, yux.jiang,
	stable, Wei Ling, Srikanth Yalavarthi



> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Friday, March 4, 2022 4:46 PM
> To: Vamsi Krishna Attunuru <vattunuru@marvell.com>; dev@dpdk.org
> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Nithin Kumar
> Dabilpuram <ndabilpuram@marvell.com>; yux.jiang@intel.com;
> stable@dpdk.org; Wei Ling <weix.ling@intel.com>; Srikanth Yalavarthi
> <syalavarthi@marvell.com>
> Subject: Re: [EXT] Re: [PATCH v2 1/1] common/cnxk: fix static assertion
> failure
> 
> On 3/4/2022 10:20 AM, Vamsi Krishna Attunuru wrote:
> >
> >
> >> -----Original Message-----
> >> From: Ferruh Yigit <ferruh.yigit@intel.com>
> >> Sent: Thursday, March 3, 2022 10:52 PM
> >> To: Vamsi Krishna Attunuru <vattunuru@marvell.com>; dev@dpdk.org
> >> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Nithin Kumar
> >> Dabilpuram <ndabilpuram@marvell.com>; yux.jiang@intel.com;
> >> stable@dpdk.org; Wei Ling <weix.ling@intel.com>; Srikanth Yalavarthi
> >> <syalavarthi@marvell.com>
> >> Subject: [EXT] Re: [PATCH v2 1/1] common/cnxk: fix static assertion
> >> failure
> >>
> >> External Email
> >>
> >> ---------------------------------------------------------------------
> >> - On 3/2/2022 1:46 PM, Vamsi Attunuru wrote:
> >>> Use dynamically allocated memory for storing soft expiry ring base
> >>> addresses which fixes the static assertion failure, as the size of
> >>> dynamic allocation depends on RTE_MAX_ETHPORTS which varies based
> on
> >>> the build config.
> >>>
> >>
> >> Hi Vamsi,
> >>
> >> "fix static assertion failure" is not enough descriptive.
> >> assertions already added to verify assumptions, and in this case it
> >> seems it failed, but what was actually wrong?
> >>
> >> Is it that allocated memory size for ring wrong? (this is what I got
> >> from commit log but I am not sure)
> >>
> >> Can you please describe what actually was wrong and fixed now?
> >>
> > Hi Ferruh,
> >
> > Earlier sa_soft_exp_ring struct member was an array of pointers and
> > it's size is linked to num RTE_MAX_ETHPORTS, and the whole struct size
> > is confined and protected by size assertion.  It resulted in build failure with -
> Dmax_ethports=1024 option and assertion caught that failure. V2 fixes the
> issues by allocating the required memory dynamically instead
> >   of using array of pointers.
> >
> 
> Thanks Vamsi for details,
> 
> I was expecting a new version of patch with updated commit log, but to
> make patch for -rc3 I will update it in next-net according above information

Sure, thanks Ferruh.

> 
> >>> Bugzilla ID: 940
> >>> Fixes: d26185716d3f ("net/cnxk: support outbound soft expiry
> >>> notification") Cc:stable@dpdk.org
> >>>
> >>> Reported-by: Wei Ling<weix.ling@intel.com>
> >>> Reported-by: Yu Jiang<yux.jiang@intel.com>
> >>> Signed-off-by: Vamsi Attunuru<vattunuru@marvell.com>
> >>> Signed-off-by: Srikanth Yalavarthi<syalavarthi@marvell.com>
> >>> ---
> >>> V2: Add bugzilla & reportee details, remove unused changes.
> >>> ---
> >


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [EXT] Re: [PATCH v2 1/1] common/cnxk: fix static assertion failure
  2022-03-04 10:20     ` [EXT] " Vamsi Krishna Attunuru
  2022-03-04 11:15       ` Ferruh Yigit
@ 2022-03-04 13:14       ` Ferruh Yigit
  2022-03-04 13:59         ` Vamsi Krishna Attunuru
  1 sibling, 1 reply; 11+ messages in thread
From: Ferruh Yigit @ 2022-03-04 13:14 UTC (permalink / raw)
  To: Vamsi Krishna Attunuru, dev
  Cc: Jerin Jacob Kollanukkaran, Nithin Kumar Dabilpuram, yux.jiang,
	stable, Wei Ling, Srikanth Yalavarthi

On 3/4/2022 10:20 AM, Vamsi Krishna Attunuru wrote:
> 
> 
>> -----Original Message-----
>> From: Ferruh Yigit <ferruh.yigit@intel.com>
>> Sent: Thursday, March 3, 2022 10:52 PM
>> To: Vamsi Krishna Attunuru <vattunuru@marvell.com>; dev@dpdk.org
>> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Nithin Kumar
>> Dabilpuram <ndabilpuram@marvell.com>; yux.jiang@intel.com;
>> stable@dpdk.org; Wei Ling <weix.ling@intel.com>; Srikanth Yalavarthi
>> <syalavarthi@marvell.com>
>> Subject: [EXT] Re: [PATCH v2 1/1] common/cnxk: fix static assertion failure
>>
>> External Email
>>
>> ----------------------------------------------------------------------
>> On 3/2/2022 1:46 PM, Vamsi Attunuru wrote:
>>> Use dynamically allocated memory for storing soft expiry ring base
>>> addresses which fixes the static assertion failure, as the size of
>>> dynamic allocation depends on RTE_MAX_ETHPORTS which varies based on
>>> the build config.
>>>
>>
>> Hi Vamsi,
>>
>> "fix static assertion failure" is not enough descriptive.
>> assertions already added to verify assumptions, and in this case it seems it
>> failed, but what was actually wrong?
>>
>> Is it that allocated memory size for ring wrong? (this is what I got from
>> commit log but I am not sure)
>>
>> Can you please describe what actually was wrong and fixed now?
>>
> Hi Ferruh,
> 
> Earlier sa_soft_exp_ring struct member was an array of pointers and it's size is linked to num RTE_MAX_ETHPORTS,
> and the whole struct size is confined and protected by size assertion.  It resulted in build failure with -Dmax_ethports=1024
> option and assertion caught that failure. V2 fixes the issues by allocating the required memory dynamically instead
>   of using array of pointers.
> 

just to double check if I got it right,

The failing assertion is:
PLT_STATIC_ASSERT(sizeof(struct nix_inl_dev) <= ROC_NIX_INL_MEM_SZ);

Technically you can calculate the 'ROC_NIX_INL_MEM_SZ' as a function
of 'RTE_MAX_ETHPORTS' and that would work (although need to calculate
size for proper cache alignment).

But instead you prefer to convert array to function pointer to fix
the struct size and make it independent from the configured
'RTE_MAX_ETHPORTS' config.


And I assume current magic number for the 'ROC_NIX_INL_MEM_SZ' is
calculated based on max memory requirement of the cn9k & cn10k:
#define ROC_NIX_INL_MEM_SZ (1280)

If so it can be better to describe 'ROC_NIX_INL_MEM_SZ' as what
it is calculated from, like following but it is up to you:
max(sizeof(x), sizeof(y)) ...

>>> Bugzilla ID: 940
>>> Fixes: d26185716d3f ("net/cnxk: support outbound soft expiry
>>> notification") Cc:stable@dpdk.org
>>>
>>> Reported-by: Wei Ling<weix.ling@intel.com>
>>> Reported-by: Yu Jiang<yux.jiang@intel.com>
>>> Signed-off-by: Vamsi Attunuru<vattunuru@marvell.com>
>>> Signed-off-by: Srikanth Yalavarthi<syalavarthi@marvell.com>
>>> ---
>>> V2: Add bugzilla & reportee details, remove unused changes.
>>> ---
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [EXT] Re: [PATCH v2 1/1] common/cnxk: fix static assertion failure
  2022-03-04 13:14       ` Ferruh Yigit
@ 2022-03-04 13:59         ` Vamsi Krishna Attunuru
  0 siblings, 0 replies; 11+ messages in thread
From: Vamsi Krishna Attunuru @ 2022-03-04 13:59 UTC (permalink / raw)
  To: Ferruh Yigit, dev
  Cc: Jerin Jacob Kollanukkaran, Nithin Kumar Dabilpuram, yux.jiang,
	stable, Wei Ling, Srikanth Yalavarthi



> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Friday, March 4, 2022 6:44 PM
> To: Vamsi Krishna Attunuru <vattunuru@marvell.com>; dev@dpdk.org
> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Nithin Kumar
> Dabilpuram <ndabilpuram@marvell.com>; yux.jiang@intel.com;
> stable@dpdk.org; Wei Ling <weix.ling@intel.com>; Srikanth Yalavarthi
> <syalavarthi@marvell.com>
> Subject: Re: [EXT] Re: [PATCH v2 1/1] common/cnxk: fix static assertion
> failure
> 
> On 3/4/2022 10:20 AM, Vamsi Krishna Attunuru wrote:
> >
> >
> >> -----Original Message-----
> >> From: Ferruh Yigit <ferruh.yigit@intel.com>
> >> Sent: Thursday, March 3, 2022 10:52 PM
> >> To: Vamsi Krishna Attunuru <vattunuru@marvell.com>; dev@dpdk.org
> >> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Nithin Kumar
> >> Dabilpuram <ndabilpuram@marvell.com>; yux.jiang@intel.com;
> >> stable@dpdk.org; Wei Ling <weix.ling@intel.com>; Srikanth Yalavarthi
> >> <syalavarthi@marvell.com>
> >> Subject: [EXT] Re: [PATCH v2 1/1] common/cnxk: fix static assertion
> >> failure
> >>
> >> External Email
> >>
> >> ---------------------------------------------------------------------
> >> - On 3/2/2022 1:46 PM, Vamsi Attunuru wrote:
> >>> Use dynamically allocated memory for storing soft expiry ring base
> >>> addresses which fixes the static assertion failure, as the size of
> >>> dynamic allocation depends on RTE_MAX_ETHPORTS which varies based
> on
> >>> the build config.
> >>>
> >>
> >> Hi Vamsi,
> >>
> >> "fix static assertion failure" is not enough descriptive.
> >> assertions already added to verify assumptions, and in this case it
> >> seems it failed, but what was actually wrong?
> >>
> >> Is it that allocated memory size for ring wrong? (this is what I got
> >> from commit log but I am not sure)
> >>
> >> Can you please describe what actually was wrong and fixed now?
> >>
> > Hi Ferruh,
> >
> > Earlier sa_soft_exp_ring struct member was an array of pointers and
> > it's size is linked to num RTE_MAX_ETHPORTS, and the whole struct size
> > is confined and protected by size assertion.  It resulted in build failure with -
> Dmax_ethports=1024 option and assertion caught that failure. V2 fixes the
> issues by allocating the required memory dynamically instead
> >   of using array of pointers.
> >
> 
> just to double check if I got it right,
> 
> The failing assertion is:
> PLT_STATIC_ASSERT(sizeof(struct nix_inl_dev) <= ROC_NIX_INL_MEM_SZ);
> 
Yes.
> Technically you can calculate the 'ROC_NIX_INL_MEM_SZ' as a function of
> 'RTE_MAX_ETHPORTS' and that would work (although need to calculate size
> for proper cache alignment).
> 
> But instead you prefer to convert array to function pointer to fix the struct
> size and make it independent from the configured 'RTE_MAX_ETHPORTS'
> config.
> 
Correct.
> 
> And I assume current magic number for the 'ROC_NIX_INL_MEM_SZ' is
> calculated based on max memory requirement of the cn9k & cn10k:
> #define ROC_NIX_INL_MEM_SZ (1280)
>
> If so it can be better to describe 'ROC_NIX_INL_MEM_SZ' as what it is
> calculated from, like following but it is up to you:
> max(sizeof(x), sizeof(y)) ...
> 
correct, I will check the better approach upon the usage.

> >>> Bugzilla ID: 940
> >>> Fixes: d26185716d3f ("net/cnxk: support outbound soft expiry
> >>> notification") Cc:stable@dpdk.org
> >>>
> >>> Reported-by: Wei Ling<weix.ling@intel.com>
> >>> Reported-by: Yu Jiang<yux.jiang@intel.com>
> >>> Signed-off-by: Vamsi Attunuru<vattunuru@marvell.com>
> >>> Signed-off-by: Srikanth Yalavarthi<syalavarthi@marvell.com>
> >>> ---
> >>> V2: Add bugzilla & reportee details, remove unused changes.
> >>> ---
> >


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-03-04 13:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-02 12:07 [PATCH 1/1] common/cnxk: fix static assertion failure Vamsi Attunuru
2022-03-02 12:46 ` Jerin Jacob
2022-03-02 13:46 ` [PATCH v2 " Vamsi Attunuru
2022-03-03  5:59   ` Jerin Jacob
2022-03-03 11:54   ` Ling, WeiX
2022-03-03 17:21   ` Ferruh Yigit
2022-03-04 10:20     ` [EXT] " Vamsi Krishna Attunuru
2022-03-04 11:15       ` Ferruh Yigit
2022-03-04 11:45         ` Vamsi Krishna Attunuru
2022-03-04 13:14       ` Ferruh Yigit
2022-03-04 13:59         ` Vamsi Krishna Attunuru

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).