patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH v2 1/7] eal: fix header build with C++
       [not found] ` <20220210120257.585822-1-bruce.richardson@intel.com>
@ 2022-02-10 12:02   ` Bruce Richardson
  2022-02-10 12:57     ` David Marchand
  2022-02-10 12:02   ` [PATCH v2 2/7] eventdev: " Bruce Richardson
                     ` (4 subsequent siblings)
  5 siblings, 1 reply; 22+ messages in thread
From: Bruce Richardson @ 2022-02-10 12:02 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, joyce.kong, david.marchand, stable,
	Honnappa Nagarahalli, Ola Liljedahl, Gavin Hu,
	Konstantin Ananyev, Jerin Jacob

C++ files could not include some headers because:

* "new" is a keyword in C++, so can't be a variable name
* there is no automatic casting to/from void *

Fixes: 184104fc6121 ("ticketlock: introduce fair ticket based locking")
Fixes: ebaee6409702 ("trace: simplify trace point headers")
Cc: joyce.kong@arm.com
Cc: david.marchand@redhat.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/eal/include/generic/rte_ticketlock.h | 14 +++++++-------
 lib/eal/include/rte_trace_point.h        |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/eal/include/generic/rte_ticketlock.h b/lib/eal/include/generic/rte_ticketlock.h
index c1b8808f51..693c67b517 100644
--- a/lib/eal/include/generic/rte_ticketlock.h
+++ b/lib/eal/include/generic/rte_ticketlock.h
@@ -91,13 +91,13 @@ rte_ticketlock_unlock(rte_ticketlock_t *tl)
 static inline int
 rte_ticketlock_trylock(rte_ticketlock_t *tl)
 {
-	rte_ticketlock_t old, new;
-	old.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_RELAXED);
-	new.tickets = old.tickets;
-	new.s.next++;
-	if (old.s.next == old.s.current) {
-		if (__atomic_compare_exchange_n(&tl->tickets, &old.tickets,
-		    new.tickets, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
+	rte_ticketlock_t oldl, newl;
+	oldl.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_RELAXED);
+	newl.tickets = oldl.tickets;
+	newl.s.next++;
+	if (oldl.s.next == oldl.s.current) {
+		if (__atomic_compare_exchange_n(&tl->tickets, &oldl.tickets,
+		    newl.tickets, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
 			return 1;
 	}
 
diff --git a/lib/eal/include/rte_trace_point.h b/lib/eal/include/rte_trace_point.h
index e226f073f7..0f8700974f 100644
--- a/lib/eal/include/rte_trace_point.h
+++ b/lib/eal/include/rte_trace_point.h
@@ -370,7 +370,7 @@ do { \
 do { \
 	if (unlikely(in == NULL)) \
 		return; \
-	rte_strscpy(mem, in, __RTE_TRACE_EMIT_STRING_LEN_MAX); \
+	rte_strscpy((char *)mem, in, __RTE_TRACE_EMIT_STRING_LEN_MAX); \
 	mem = RTE_PTR_ADD(mem, __RTE_TRACE_EMIT_STRING_LEN_MAX); \
 } while (0)
 
-- 
2.32.0


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

* [PATCH v2 2/7] eventdev: fix header build with C++
       [not found] ` <20220210120257.585822-1-bruce.richardson@intel.com>
  2022-02-10 12:02   ` [PATCH v2 1/7] eal: fix header build with C++ Bruce Richardson
@ 2022-02-10 12:02   ` Bruce Richardson
  2022-02-10 12:02   ` [PATCH v2 3/7] graph: fix missing explicit cast for C++ build Bruce Richardson
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 22+ messages in thread
From: Bruce Richardson @ 2022-02-10 12:02 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, erik.g.carrillo, skori, stable, Jerin Jacob,
	Jerin Jacob, Pavan Nikhilesh, David Marchand

The eventdev headers had issues when used from C++

* Missing closing "}" for the extern "C" block
* No automatic casting to/from void *

Fixes: a6562f6d6f8e ("eventdev: introduce event timer adapter")
Fixes: 32e326869ed6 ("eventdev: add tracepoints")
Cc: erik.g.carrillo@intel.com
Cc: skori@marvell.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
---
 lib/eventdev/rte_event_timer_adapter.h | 3 +++
 lib/eventdev/rte_eventdev.h            | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/eventdev/rte_event_timer_adapter.h b/lib/eventdev/rte_event_timer_adapter.h
index 1551741820..1fe4dd8e8f 100644
--- a/lib/eventdev/rte_event_timer_adapter.h
+++ b/lib/eventdev/rte_event_timer_adapter.h
@@ -678,4 +678,7 @@ rte_event_timer_cancel_burst(const struct rte_event_timer_adapter *adapter,
 	return adapter->cancel_burst(adapter, evtims, nb_evtims);
 }
 
+#ifdef __cplusplus
+}
+#endif
 #endif /* __RTE_EVENT_TIMER_ADAPTER_H__ */
diff --git a/lib/eventdev/rte_eventdev.h b/lib/eventdev/rte_eventdev.h
index eef47d8acc..25fb7c89dd 100644
--- a/lib/eventdev/rte_eventdev.h
+++ b/lib/eventdev/rte_eventdev.h
@@ -1805,7 +1805,7 @@ __rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
 		return 0;
 	}
 #endif
-	rte_eventdev_trace_enq_burst(dev_id, port_id, ev, nb_events, fn);
+	rte_eventdev_trace_enq_burst(dev_id, port_id, ev, nb_events, (void *)fn);
 	/*
 	 * Allow zero cost non burst mode routine invocation if application
 	 * requests nb_events as const one
-- 
2.32.0


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

* [PATCH v2 3/7] graph: fix missing explicit cast for C++ build
       [not found] ` <20220210120257.585822-1-bruce.richardson@intel.com>
  2022-02-10 12:02   ` [PATCH v2 1/7] eal: fix header build with C++ Bruce Richardson
  2022-02-10 12:02   ` [PATCH v2 2/7] eventdev: " Bruce Richardson
@ 2022-02-10 12:02   ` Bruce Richardson
  2022-02-10 12:02   ` [PATCH v2 4/7] ipsec: " Bruce Richardson
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 22+ messages in thread
From: Bruce Richardson @ 2022-02-10 12:02 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, jerinj, stable, Pavan Nikhilesh, Kiran Kumar K,
	Nithin Dabilpuram

C++ does not have automatic casting to/from void pointers, so need
explicit cast if header is to be included in C++ code

Fixes: 40d4f51403ec ("graph: implement fastpath routines")
Cc: jerinj@marvell.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
---
 lib/graph/rte_graph_worker.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/graph/rte_graph_worker.h b/lib/graph/rte_graph_worker.h
index eef77f732a..0c0b9c095a 100644
--- a/lib/graph/rte_graph_worker.h
+++ b/lib/graph/rte_graph_worker.h
@@ -155,7 +155,7 @@ rte_graph_walk(struct rte_graph *graph)
 	 *	+-----+ <= cir_start + mask
 	 */
 	while (likely(head != graph->tail)) {
-		node = RTE_PTR_ADD(graph, cir_start[(int32_t)head++]);
+		node = (struct rte_node *)RTE_PTR_ADD(graph, cir_start[(int32_t)head++]);
 		RTE_ASSERT(node->fence == RTE_GRAPH_FENCE);
 		objs = node->objs;
 		rte_prefetch0(objs);
-- 
2.32.0


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

* [PATCH v2 4/7] ipsec: fix missing explicit cast for C++ build
       [not found] ` <20220210120257.585822-1-bruce.richardson@intel.com>
                     ` (2 preceding siblings ...)
  2022-02-10 12:02   ` [PATCH v2 3/7] graph: fix missing explicit cast for C++ build Bruce Richardson
@ 2022-02-10 12:02   ` Bruce Richardson
  2022-02-10 12:42     ` Ananyev, Konstantin
  2022-02-10 12:02   ` [PATCH v2 5/7] table: fix missing explicit casts " Bruce Richardson
  2022-02-10 12:02   ` [PATCH v2 6/7] vhost: fix incompatible header includes for C++ Bruce Richardson
  5 siblings, 1 reply; 22+ messages in thread
From: Bruce Richardson @ 2022-02-10 12:02 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, konstantin.ananyev, stable, Declan Doherty,
	Akhil Goyal

C++ does not have automatic casting to/from void pointers, so need
explicit cast if header is to be included in C++ code

Fixes: f901d9c82688 ("ipsec: add helpers to group completed crypto-ops")
Cc: konstantin.ananyev@intel.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/ipsec/rte_ipsec_group.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/ipsec/rte_ipsec_group.h b/lib/ipsec/rte_ipsec_group.h
index 60ab297710..62c2bd7217 100644
--- a/lib/ipsec/rte_ipsec_group.h
+++ b/lib/ipsec/rte_ipsec_group.h
@@ -49,10 +49,10 @@ rte_ipsec_ses_from_crypto(const struct rte_crypto_op *cop)
 
 	if (cop->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
 		ss = cop->sym[0].sec_session;
-		return (void *)(uintptr_t)ss->opaque_data;
+		return (struct rte_ipsec_session *)(uintptr_t)ss->opaque_data;
 	} else if (cop->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
 		cs = cop->sym[0].session;
-		return (void *)(uintptr_t)cs->opaque_data;
+		return (struct rte_ipsec_session *)(uintptr_t)cs->opaque_data;
 	}
 	return NULL;
 }
-- 
2.32.0


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

* [PATCH v2 5/7] table: fix missing explicit casts for C++ build
       [not found] ` <20220210120257.585822-1-bruce.richardson@intel.com>
                     ` (3 preceding siblings ...)
  2022-02-10 12:02   ` [PATCH v2 4/7] ipsec: " Bruce Richardson
@ 2022-02-10 12:02   ` Bruce Richardson
  2022-02-10 12:02   ` [PATCH v2 6/7] vhost: fix incompatible header includes for C++ Bruce Richardson
  5 siblings, 0 replies; 22+ messages in thread
From: Bruce Richardson @ 2022-02-10 12:02 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, kevin.laatz, cristian.dumitrescu, stable,
	Jerin Jacob, Gavin Hu

Since C++ doesn't support automatic casting from void * to other types,
we need to explicitly add the casts to any header files in DPDK.

Fixes: ea7be0a0386e ("lib/librte_table: add hash function headers")
Cc: kevin.laatz@intel.com
Cc: cristian.dumitrescu@intel.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/table/rte_table_hash_func.h | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/lib/table/rte_table_hash_func.h b/lib/table/rte_table_hash_func.h
index c4c35cc06a..a962ec2f68 100644
--- a/lib/table/rte_table_hash_func.h
+++ b/lib/table/rte_table_hash_func.h
@@ -58,8 +58,8 @@ static inline uint64_t
 rte_table_hash_crc_key8(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t crc0;
 
 	crc0 = rte_crc32_u64(seed, k[0] & m[0]);
@@ -72,8 +72,8 @@ static inline uint64_t
 rte_table_hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, crc0, crc1;
 
 	k0 = k[0] & m[0];
@@ -91,8 +91,8 @@ static inline uint64_t
 rte_table_hash_crc_key24(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, crc0, crc1;
 
 	k0 = k[0] & m[0];
@@ -113,8 +113,8 @@ static inline uint64_t
 rte_table_hash_crc_key32(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, crc0, crc1, crc2, crc3;
 
 	k0 = k[0] & m[0];
@@ -139,8 +139,8 @@ static inline uint64_t
 rte_table_hash_crc_key40(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, crc0, crc1, crc2, crc3;
 
 	k0 = k[0] & m[0];
@@ -165,8 +165,8 @@ static inline uint64_t
 rte_table_hash_crc_key48(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, k5, crc0, crc1, crc2, crc3;
 
 	k0 = k[0] & m[0];
@@ -192,8 +192,8 @@ static inline uint64_t
 rte_table_hash_crc_key56(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
 
 	k0 = k[0] & m[0];
@@ -222,8 +222,8 @@ static inline uint64_t
 rte_table_hash_crc_key64(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
 
 	k0 = k[0] & m[0];
-- 
2.32.0


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

* [PATCH v2 6/7] vhost: fix incompatible header includes for C++
       [not found] ` <20220210120257.585822-1-bruce.richardson@intel.com>
                     ` (4 preceding siblings ...)
  2022-02-10 12:02   ` [PATCH v2 5/7] table: fix missing explicit casts " Bruce Richardson
@ 2022-02-10 12:02   ` Bruce Richardson
  5 siblings, 0 replies; 22+ messages in thread
From: Bruce Richardson @ 2022-02-10 12:02 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, adrien.mazarguil, stable, Yuanhan Liu, Maxime Coquelin

The virtio kernel header includes are already noted as being
incompatible with C++. We can ensure that the header is safe for
inclusion in C++ code by not including those headers during C++ builds.
While not ideal, this does ensure that all DPDK headers can be included
in C++ code without errors.

Fixes: f8904d563691 ("vhost: fix header for strict compilation flags")
Cc: adrien.mazarguil@6wind.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/vhost/rte_vhost.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/vhost/rte_vhost.h b/lib/vhost/rte_vhost.h
index b454c05868..2acb31df2d 100644
--- a/lib/vhost/rte_vhost.h
+++ b/lib/vhost/rte_vhost.h
@@ -21,10 +21,12 @@
 extern "C" {
 #endif
 
+#ifndef __cplusplus
 /* These are not C++-aware. */
 #include <linux/vhost.h>
 #include <linux/virtio_ring.h>
 #include <linux/virtio_net.h>
+#endif
 
 #define RTE_VHOST_USER_CLIENT		(1ULL << 0)
 #define RTE_VHOST_USER_NO_RECONNECT	(1ULL << 1)
-- 
2.32.0


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

* RE: [PATCH v2 4/7] ipsec: fix missing explicit cast for C++ build
  2022-02-10 12:02   ` [PATCH v2 4/7] ipsec: " Bruce Richardson
@ 2022-02-10 12:42     ` Ananyev, Konstantin
  0 siblings, 0 replies; 22+ messages in thread
From: Ananyev, Konstantin @ 2022-02-10 12:42 UTC (permalink / raw)
  To: Richardson, Bruce, dev; +Cc: stable, Doherty, Declan, Akhil Goyal



> C++ does not have automatic casting to/from void pointers, so need
> explicit cast if header is to be included in C++ code
> 
> Fixes: f901d9c82688 ("ipsec: add helpers to group completed crypto-ops")
> Cc: konstantin.ananyev@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  lib/ipsec/rte_ipsec_group.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/ipsec/rte_ipsec_group.h b/lib/ipsec/rte_ipsec_group.h
> index 60ab297710..62c2bd7217 100644
> --- a/lib/ipsec/rte_ipsec_group.h
> +++ b/lib/ipsec/rte_ipsec_group.h
> @@ -49,10 +49,10 @@ rte_ipsec_ses_from_crypto(const struct rte_crypto_op *cop)
> 
>  	if (cop->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
>  		ss = cop->sym[0].sec_session;
> -		return (void *)(uintptr_t)ss->opaque_data;
> +		return (struct rte_ipsec_session *)(uintptr_t)ss->opaque_data;
>  	} else if (cop->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
>  		cs = cop->sym[0].session;
> -		return (void *)(uintptr_t)cs->opaque_data;
> +		return (struct rte_ipsec_session *)(uintptr_t)cs->opaque_data;
>  	}
>  	return NULL;
>  }
> --

Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

> 2.32.0


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

* Re: [PATCH v2 1/7] eal: fix header build with C++
  2022-02-10 12:02   ` [PATCH v2 1/7] eal: fix header build with C++ Bruce Richardson
@ 2022-02-10 12:57     ` David Marchand
  2022-02-10 14:07       ` Bruce Richardson
  0 siblings, 1 reply; 22+ messages in thread
From: David Marchand @ 2022-02-10 12:57 UTC (permalink / raw)
  To: Bruce Richardson
  Cc: dev, Joyce Kong, dpdk stable, Honnappa Nagarahalli,
	Ola Liljedahl, Gavin Hu, Konstantin Ananyev, Jerin Jacob

On Thu, Feb 10, 2022 at 1:03 PM Bruce Richardson
<bruce.richardson@intel.com> wrote:
>
> C++ files could not include some headers because:
>
> * "new" is a keyword in C++, so can't be a variable name
> * there is no automatic casting to/from void *
>
> Fixes: 184104fc6121 ("ticketlock: introduce fair ticket based locking")
> Fixes: ebaee6409702 ("trace: simplify trace point headers")

rte_strcpy was moved in this commit.
This is more about:
Fixes: 032a7e5499a0 ("trace: implement provider payload")

> Cc: joyce.kong@arm.com
> Cc: david.marchand@redhat.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  lib/eal/include/generic/rte_ticketlock.h | 14 +++++++-------
>  lib/eal/include/rte_trace_point.h        |  2 +-
>  2 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/lib/eal/include/generic/rte_ticketlock.h b/lib/eal/include/generic/rte_ticketlock.h
> index c1b8808f51..693c67b517 100644
> --- a/lib/eal/include/generic/rte_ticketlock.h
> +++ b/lib/eal/include/generic/rte_ticketlock.h
> @@ -91,13 +91,13 @@ rte_ticketlock_unlock(rte_ticketlock_t *tl)
>  static inline int
>  rte_ticketlock_trylock(rte_ticketlock_t *tl)
>  {
> -       rte_ticketlock_t old, new;
> -       old.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_RELAXED);
> -       new.tickets = old.tickets;
> -       new.s.next++;
> -       if (old.s.next == old.s.current) {
> -               if (__atomic_compare_exchange_n(&tl->tickets, &old.tickets,
> -                   new.tickets, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
> +       rte_ticketlock_t oldl, newl;
> +       oldl.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_RELAXED);
> +       newl.tickets = oldl.tickets;
> +       newl.s.next++;
> +       if (oldl.s.next == oldl.s.current) {
> +               if (__atomic_compare_exchange_n(&tl->tickets, &oldl.tickets,
> +                   newl.tickets, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
>                         return 1;
>         }
>
> diff --git a/lib/eal/include/rte_trace_point.h b/lib/eal/include/rte_trace_point.h
> index e226f073f7..0f8700974f 100644
> --- a/lib/eal/include/rte_trace_point.h
> +++ b/lib/eal/include/rte_trace_point.h
> @@ -370,7 +370,7 @@ do { \
>  do { \
>         if (unlikely(in == NULL)) \
>                 return; \
> -       rte_strscpy(mem, in, __RTE_TRACE_EMIT_STRING_LEN_MAX); \
> +       rte_strscpy((char *)mem, in, __RTE_TRACE_EMIT_STRING_LEN_MAX); \
>         mem = RTE_PTR_ADD(mem, __RTE_TRACE_EMIT_STRING_LEN_MAX); \
>  } while (0)
>
> --
> 2.32.0
>

lgtm, thanks.


-- 
David Marchand


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

* [PATCH v3 1/7] eal: fix header build with C++
       [not found] ` <20220210140355.586399-1-bruce.richardson@intel.com>
@ 2022-02-10 14:03   ` Bruce Richardson
  2022-02-10 14:03   ` [PATCH v3 2/7] eventdev: " Bruce Richardson
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 22+ messages in thread
From: Bruce Richardson @ 2022-02-10 14:03 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, joyce.kong, david.marchand, stable, Gavin Hu,
	Konstantin Ananyev, Honnappa Nagarahalli, Ola Liljedahl,
	Jerin Jacob

C++ files could not include some headers because:

* "new" is a keyword in C++, so can't be a variable name
* there is no automatic casting to/from void *

Fixes: 184104fc6121 ("ticketlock: introduce fair ticket based locking")
Fixes: ebaee6409702 ("trace: simplify trace point headers")
Cc: joyce.kong@arm.com
Cc: david.marchand@redhat.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/eal/include/generic/rte_ticketlock.h | 14 +++++++-------
 lib/eal/include/rte_trace_point.h        |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/eal/include/generic/rte_ticketlock.h b/lib/eal/include/generic/rte_ticketlock.h
index c1b8808f51..693c67b517 100644
--- a/lib/eal/include/generic/rte_ticketlock.h
+++ b/lib/eal/include/generic/rte_ticketlock.h
@@ -91,13 +91,13 @@ rte_ticketlock_unlock(rte_ticketlock_t *tl)
 static inline int
 rte_ticketlock_trylock(rte_ticketlock_t *tl)
 {
-	rte_ticketlock_t old, new;
-	old.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_RELAXED);
-	new.tickets = old.tickets;
-	new.s.next++;
-	if (old.s.next == old.s.current) {
-		if (__atomic_compare_exchange_n(&tl->tickets, &old.tickets,
-		    new.tickets, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
+	rte_ticketlock_t oldl, newl;
+	oldl.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_RELAXED);
+	newl.tickets = oldl.tickets;
+	newl.s.next++;
+	if (oldl.s.next == oldl.s.current) {
+		if (__atomic_compare_exchange_n(&tl->tickets, &oldl.tickets,
+		    newl.tickets, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
 			return 1;
 	}
 
diff --git a/lib/eal/include/rte_trace_point.h b/lib/eal/include/rte_trace_point.h
index e226f073f7..0f8700974f 100644
--- a/lib/eal/include/rte_trace_point.h
+++ b/lib/eal/include/rte_trace_point.h
@@ -370,7 +370,7 @@ do { \
 do { \
 	if (unlikely(in == NULL)) \
 		return; \
-	rte_strscpy(mem, in, __RTE_TRACE_EMIT_STRING_LEN_MAX); \
+	rte_strscpy((char *)mem, in, __RTE_TRACE_EMIT_STRING_LEN_MAX); \
 	mem = RTE_PTR_ADD(mem, __RTE_TRACE_EMIT_STRING_LEN_MAX); \
 } while (0)
 
-- 
2.32.0


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

* [PATCH v3 2/7] eventdev: fix header build with C++
       [not found] ` <20220210140355.586399-1-bruce.richardson@intel.com>
  2022-02-10 14:03   ` [PATCH v3 1/7] eal: fix header build with C++ Bruce Richardson
@ 2022-02-10 14:03   ` Bruce Richardson
  2022-02-10 14:03   ` [PATCH v3 3/7] graph: fix missing explicit cast for C++ build Bruce Richardson
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 22+ messages in thread
From: Bruce Richardson @ 2022-02-10 14:03 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, erik.g.carrillo, skori, stable, Jerin Jacob,
	Jerin Jacob, Pavan Nikhilesh, David Marchand

The eventdev headers had issues when used from C++

* Missing closing "}" for the extern "C" block
* No automatic casting to/from void *

Fixes: a6562f6d6f8e ("eventdev: introduce event timer adapter")
Fixes: 32e326869ed6 ("eventdev: add tracepoints")
Cc: erik.g.carrillo@intel.com
Cc: skori@marvell.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
---
 lib/eventdev/rte_event_timer_adapter.h | 3 +++
 lib/eventdev/rte_eventdev.h            | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/eventdev/rte_event_timer_adapter.h b/lib/eventdev/rte_event_timer_adapter.h
index 1551741820..1fe4dd8e8f 100644
--- a/lib/eventdev/rte_event_timer_adapter.h
+++ b/lib/eventdev/rte_event_timer_adapter.h
@@ -678,4 +678,7 @@ rte_event_timer_cancel_burst(const struct rte_event_timer_adapter *adapter,
 	return adapter->cancel_burst(adapter, evtims, nb_evtims);
 }
 
+#ifdef __cplusplus
+}
+#endif
 #endif /* __RTE_EVENT_TIMER_ADAPTER_H__ */
diff --git a/lib/eventdev/rte_eventdev.h b/lib/eventdev/rte_eventdev.h
index eef47d8acc..25fb7c89dd 100644
--- a/lib/eventdev/rte_eventdev.h
+++ b/lib/eventdev/rte_eventdev.h
@@ -1805,7 +1805,7 @@ __rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
 		return 0;
 	}
 #endif
-	rte_eventdev_trace_enq_burst(dev_id, port_id, ev, nb_events, fn);
+	rte_eventdev_trace_enq_burst(dev_id, port_id, ev, nb_events, (void *)fn);
 	/*
 	 * Allow zero cost non burst mode routine invocation if application
 	 * requests nb_events as const one
-- 
2.32.0


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

* [PATCH v3 3/7] graph: fix missing explicit cast for C++ build
       [not found] ` <20220210140355.586399-1-bruce.richardson@intel.com>
  2022-02-10 14:03   ` [PATCH v3 1/7] eal: fix header build with C++ Bruce Richardson
  2022-02-10 14:03   ` [PATCH v3 2/7] eventdev: " Bruce Richardson
@ 2022-02-10 14:03   ` Bruce Richardson
  2022-02-10 14:03   ` [PATCH v3 4/7] ipsec: " Bruce Richardson
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 22+ messages in thread
From: Bruce Richardson @ 2022-02-10 14:03 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, jerinj, stable, Kiran Kumar K,
	Nithin Dabilpuram, Pavan Nikhilesh

C++ does not have automatic casting to/from void pointers, so need
explicit cast if header is to be included in C++ code

Fixes: 40d4f51403ec ("graph: implement fastpath routines")
Cc: jerinj@marvell.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
---
 lib/graph/rte_graph_worker.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/graph/rte_graph_worker.h b/lib/graph/rte_graph_worker.h
index eef77f732a..0c0b9c095a 100644
--- a/lib/graph/rte_graph_worker.h
+++ b/lib/graph/rte_graph_worker.h
@@ -155,7 +155,7 @@ rte_graph_walk(struct rte_graph *graph)
 	 *	+-----+ <= cir_start + mask
 	 */
 	while (likely(head != graph->tail)) {
-		node = RTE_PTR_ADD(graph, cir_start[(int32_t)head++]);
+		node = (struct rte_node *)RTE_PTR_ADD(graph, cir_start[(int32_t)head++]);
 		RTE_ASSERT(node->fence == RTE_GRAPH_FENCE);
 		objs = node->objs;
 		rte_prefetch0(objs);
-- 
2.32.0


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

* [PATCH v3 4/7] ipsec: fix missing explicit cast for C++ build
       [not found] ` <20220210140355.586399-1-bruce.richardson@intel.com>
                     ` (2 preceding siblings ...)
  2022-02-10 14:03   ` [PATCH v3 3/7] graph: fix missing explicit cast for C++ build Bruce Richardson
@ 2022-02-10 14:03   ` Bruce Richardson
  2022-02-10 14:03   ` [PATCH v3 5/7] table: fix missing explicit casts " Bruce Richardson
  2022-02-10 14:03   ` [PATCH v3 6/7] vhost: fix incompatible header includes for C++ Bruce Richardson
  5 siblings, 0 replies; 22+ messages in thread
From: Bruce Richardson @ 2022-02-10 14:03 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, konstantin.ananyev, stable, Declan Doherty,
	Akhil Goyal

C++ does not have automatic casting to/from void pointers, so need
explicit cast if header is to be included in C++ code

Fixes: f901d9c82688 ("ipsec: add helpers to group completed crypto-ops")
Cc: konstantin.ananyev@intel.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/ipsec/rte_ipsec_group.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/ipsec/rte_ipsec_group.h b/lib/ipsec/rte_ipsec_group.h
index 60ab297710..62c2bd7217 100644
--- a/lib/ipsec/rte_ipsec_group.h
+++ b/lib/ipsec/rte_ipsec_group.h
@@ -49,10 +49,10 @@ rte_ipsec_ses_from_crypto(const struct rte_crypto_op *cop)
 
 	if (cop->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
 		ss = cop->sym[0].sec_session;
-		return (void *)(uintptr_t)ss->opaque_data;
+		return (struct rte_ipsec_session *)(uintptr_t)ss->opaque_data;
 	} else if (cop->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
 		cs = cop->sym[0].session;
-		return (void *)(uintptr_t)cs->opaque_data;
+		return (struct rte_ipsec_session *)(uintptr_t)cs->opaque_data;
 	}
 	return NULL;
 }
-- 
2.32.0


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

* [PATCH v3 5/7] table: fix missing explicit casts for C++ build
       [not found] ` <20220210140355.586399-1-bruce.richardson@intel.com>
                     ` (3 preceding siblings ...)
  2022-02-10 14:03   ` [PATCH v3 4/7] ipsec: " Bruce Richardson
@ 2022-02-10 14:03   ` Bruce Richardson
  2022-02-10 14:03   ` [PATCH v3 6/7] vhost: fix incompatible header includes for C++ Bruce Richardson
  5 siblings, 0 replies; 22+ messages in thread
From: Bruce Richardson @ 2022-02-10 14:03 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, kevin.laatz, cristian.dumitrescu, stable,
	Jerin Jacob, Gavin Hu

Since C++ doesn't support automatic casting from void * to other types,
we need to explicitly add the casts to any header files in DPDK.

Fixes: ea7be0a0386e ("lib/librte_table: add hash function headers")
Cc: kevin.laatz@intel.com
Cc: cristian.dumitrescu@intel.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/table/rte_table_hash_func.h | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/lib/table/rte_table_hash_func.h b/lib/table/rte_table_hash_func.h
index c4c35cc06a..a962ec2f68 100644
--- a/lib/table/rte_table_hash_func.h
+++ b/lib/table/rte_table_hash_func.h
@@ -58,8 +58,8 @@ static inline uint64_t
 rte_table_hash_crc_key8(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t crc0;
 
 	crc0 = rte_crc32_u64(seed, k[0] & m[0]);
@@ -72,8 +72,8 @@ static inline uint64_t
 rte_table_hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, crc0, crc1;
 
 	k0 = k[0] & m[0];
@@ -91,8 +91,8 @@ static inline uint64_t
 rte_table_hash_crc_key24(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, crc0, crc1;
 
 	k0 = k[0] & m[0];
@@ -113,8 +113,8 @@ static inline uint64_t
 rte_table_hash_crc_key32(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, crc0, crc1, crc2, crc3;
 
 	k0 = k[0] & m[0];
@@ -139,8 +139,8 @@ static inline uint64_t
 rte_table_hash_crc_key40(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, crc0, crc1, crc2, crc3;
 
 	k0 = k[0] & m[0];
@@ -165,8 +165,8 @@ static inline uint64_t
 rte_table_hash_crc_key48(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, k5, crc0, crc1, crc2, crc3;
 
 	k0 = k[0] & m[0];
@@ -192,8 +192,8 @@ static inline uint64_t
 rte_table_hash_crc_key56(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
 
 	k0 = k[0] & m[0];
@@ -222,8 +222,8 @@ static inline uint64_t
 rte_table_hash_crc_key64(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
 
 	k0 = k[0] & m[0];
-- 
2.32.0


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

* [PATCH v3 6/7] vhost: fix incompatible header includes for C++
       [not found] ` <20220210140355.586399-1-bruce.richardson@intel.com>
                     ` (4 preceding siblings ...)
  2022-02-10 14:03   ` [PATCH v3 5/7] table: fix missing explicit casts " Bruce Richardson
@ 2022-02-10 14:03   ` Bruce Richardson
  5 siblings, 0 replies; 22+ messages in thread
From: Bruce Richardson @ 2022-02-10 14:03 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, adrien.mazarguil, stable, Yuanhan Liu, Maxime Coquelin

The virtio kernel header includes are already noted as being
incompatible with C++. We can ensure that the header is safe for
inclusion in C++ code by not including those headers during C++ builds.
While not ideal, this does ensure that all DPDK headers can be included
in C++ code without errors.

Fixes: f8904d563691 ("vhost: fix header for strict compilation flags")
Cc: adrien.mazarguil@6wind.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/vhost/rte_vhost.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/vhost/rte_vhost.h b/lib/vhost/rte_vhost.h
index b454c05868..2acb31df2d 100644
--- a/lib/vhost/rte_vhost.h
+++ b/lib/vhost/rte_vhost.h
@@ -21,10 +21,12 @@
 extern "C" {
 #endif
 
+#ifndef __cplusplus
 /* These are not C++-aware. */
 #include <linux/vhost.h>
 #include <linux/virtio_ring.h>
 #include <linux/virtio_net.h>
+#endif
 
 #define RTE_VHOST_USER_CLIENT		(1ULL << 0)
 #define RTE_VHOST_USER_NO_RECONNECT	(1ULL << 1)
-- 
2.32.0


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

* Re: [PATCH v2 1/7] eal: fix header build with C++
  2022-02-10 12:57     ` David Marchand
@ 2022-02-10 14:07       ` Bruce Richardson
  0 siblings, 0 replies; 22+ messages in thread
From: Bruce Richardson @ 2022-02-10 14:07 UTC (permalink / raw)
  To: David Marchand
  Cc: dev, Joyce Kong, dpdk stable, Honnappa Nagarahalli,
	Ola Liljedahl, Gavin Hu, Konstantin Ananyev, Jerin Jacob

On Thu, Feb 10, 2022 at 01:57:09PM +0100, David Marchand wrote:
> On Thu, Feb 10, 2022 at 1:03 PM Bruce Richardson
> <bruce.richardson@intel.com> wrote:
> >
> > C++ files could not include some headers because:
> >
> > * "new" is a keyword in C++, so can't be a variable name
> > * there is no automatic casting to/from void *
> >
> > Fixes: 184104fc6121 ("ticketlock: introduce fair ticket based locking")
> > Fixes: ebaee6409702 ("trace: simplify trace point headers")
> 
> rte_strcpy was moved in this commit.
> This is more about:
> Fixes: 032a7e5499a0 ("trace: implement provider payload")
> 
Thank you, I missed that even though I did some searching beyond the commit
I referenced, which I suspected was only moving things!
Unfortunately, I didn't see this before I did up a v3 to fix the CI issues.
If necessary I'll do a v4 to correct, once I check there are no other CI
problems.

/Bruce

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

* [PATCH v4 1/7] eal: fix header build with C++
       [not found] ` <20220210154239.587185-1-bruce.richardson@intel.com>
@ 2022-02-10 15:42   ` Bruce Richardson
  2022-02-14  9:30     ` Joyce Kong
  2022-02-10 15:42   ` [PATCH v4 2/7] eventdev: " Bruce Richardson
                     ` (4 subsequent siblings)
  5 siblings, 1 reply; 22+ messages in thread
From: Bruce Richardson @ 2022-02-10 15:42 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, joyce.kong, jerinj, stable, Gavin Hu,
	Konstantin Ananyev, Honnappa Nagarahalli, Ola Liljedahl,
	Sunil Kumar Kori, David Marchand

C++ files could not include some headers because:

* "new" is a keyword in C++, so can't be a variable name
* there is no automatic casting to/from void *

Fixes: 184104fc6121 ("ticketlock: introduce fair ticket based locking")
Fixes: 032a7e5499a0 ("trace: implement provider payload")
Cc: joyce.kong@arm.com
Cc: jerinj@marvell.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/eal/include/generic/rte_ticketlock.h | 14 +++++++-------
 lib/eal/include/rte_trace_point.h        |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/eal/include/generic/rte_ticketlock.h b/lib/eal/include/generic/rte_ticketlock.h
index c1b8808f51..693c67b517 100644
--- a/lib/eal/include/generic/rte_ticketlock.h
+++ b/lib/eal/include/generic/rte_ticketlock.h
@@ -91,13 +91,13 @@ rte_ticketlock_unlock(rte_ticketlock_t *tl)
 static inline int
 rte_ticketlock_trylock(rte_ticketlock_t *tl)
 {
-	rte_ticketlock_t old, new;
-	old.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_RELAXED);
-	new.tickets = old.tickets;
-	new.s.next++;
-	if (old.s.next == old.s.current) {
-		if (__atomic_compare_exchange_n(&tl->tickets, &old.tickets,
-		    new.tickets, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
+	rte_ticketlock_t oldl, newl;
+	oldl.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_RELAXED);
+	newl.tickets = oldl.tickets;
+	newl.s.next++;
+	if (oldl.s.next == oldl.s.current) {
+		if (__atomic_compare_exchange_n(&tl->tickets, &oldl.tickets,
+		    newl.tickets, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
 			return 1;
 	}
 
diff --git a/lib/eal/include/rte_trace_point.h b/lib/eal/include/rte_trace_point.h
index e226f073f7..0f8700974f 100644
--- a/lib/eal/include/rte_trace_point.h
+++ b/lib/eal/include/rte_trace_point.h
@@ -370,7 +370,7 @@ do { \
 do { \
 	if (unlikely(in == NULL)) \
 		return; \
-	rte_strscpy(mem, in, __RTE_TRACE_EMIT_STRING_LEN_MAX); \
+	rte_strscpy((char *)mem, in, __RTE_TRACE_EMIT_STRING_LEN_MAX); \
 	mem = RTE_PTR_ADD(mem, __RTE_TRACE_EMIT_STRING_LEN_MAX); \
 } while (0)
 
-- 
2.32.0


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

* [PATCH v4 2/7] eventdev: fix header build with C++
       [not found] ` <20220210154239.587185-1-bruce.richardson@intel.com>
  2022-02-10 15:42   ` [PATCH v4 1/7] eal: fix header build with C++ Bruce Richardson
@ 2022-02-10 15:42   ` Bruce Richardson
  2022-02-10 15:42   ` [PATCH v4 3/7] graph: fix missing explicit cast for C++ build Bruce Richardson
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 22+ messages in thread
From: Bruce Richardson @ 2022-02-10 15:42 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, erik.g.carrillo, skori, stable, Jerin Jacob,
	Jerin Jacob, Pavan Nikhilesh, David Marchand

The eventdev headers had issues when used from C++

* Missing closing "}" for the extern "C" block
* No automatic casting to/from void *

Fixes: a6562f6d6f8e ("eventdev: introduce event timer adapter")
Fixes: 32e326869ed6 ("eventdev: add tracepoints")
Cc: erik.g.carrillo@intel.com
Cc: skori@marvell.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
---
 lib/eventdev/rte_event_timer_adapter.h | 3 +++
 lib/eventdev/rte_eventdev.h            | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/eventdev/rte_event_timer_adapter.h b/lib/eventdev/rte_event_timer_adapter.h
index 1551741820..1fe4dd8e8f 100644
--- a/lib/eventdev/rte_event_timer_adapter.h
+++ b/lib/eventdev/rte_event_timer_adapter.h
@@ -678,4 +678,7 @@ rte_event_timer_cancel_burst(const struct rte_event_timer_adapter *adapter,
 	return adapter->cancel_burst(adapter, evtims, nb_evtims);
 }
 
+#ifdef __cplusplus
+}
+#endif
 #endif /* __RTE_EVENT_TIMER_ADAPTER_H__ */
diff --git a/lib/eventdev/rte_eventdev.h b/lib/eventdev/rte_eventdev.h
index eef47d8acc..25fb7c89dd 100644
--- a/lib/eventdev/rte_eventdev.h
+++ b/lib/eventdev/rte_eventdev.h
@@ -1805,7 +1805,7 @@ __rte_event_enqueue_burst(uint8_t dev_id, uint8_t port_id,
 		return 0;
 	}
 #endif
-	rte_eventdev_trace_enq_burst(dev_id, port_id, ev, nb_events, fn);
+	rte_eventdev_trace_enq_burst(dev_id, port_id, ev, nb_events, (void *)fn);
 	/*
 	 * Allow zero cost non burst mode routine invocation if application
 	 * requests nb_events as const one
-- 
2.32.0


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

* [PATCH v4 3/7] graph: fix missing explicit cast for C++ build
       [not found] ` <20220210154239.587185-1-bruce.richardson@intel.com>
  2022-02-10 15:42   ` [PATCH v4 1/7] eal: fix header build with C++ Bruce Richardson
  2022-02-10 15:42   ` [PATCH v4 2/7] eventdev: " Bruce Richardson
@ 2022-02-10 15:42   ` Bruce Richardson
  2022-02-10 15:42   ` [PATCH v4 4/7] ipsec: " Bruce Richardson
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 22+ messages in thread
From: Bruce Richardson @ 2022-02-10 15:42 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, jerinj, stable, Nithin Dabilpuram,
	Kiran Kumar K, Pavan Nikhilesh

C++ does not have automatic casting to/from void pointers, so need
explicit cast if header is to be included in C++ code

Fixes: 40d4f51403ec ("graph: implement fastpath routines")
Cc: jerinj@marvell.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
---
 lib/graph/rte_graph_worker.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/graph/rte_graph_worker.h b/lib/graph/rte_graph_worker.h
index eef77f732a..0c0b9c095a 100644
--- a/lib/graph/rte_graph_worker.h
+++ b/lib/graph/rte_graph_worker.h
@@ -155,7 +155,7 @@ rte_graph_walk(struct rte_graph *graph)
 	 *	+-----+ <= cir_start + mask
 	 */
 	while (likely(head != graph->tail)) {
-		node = RTE_PTR_ADD(graph, cir_start[(int32_t)head++]);
+		node = (struct rte_node *)RTE_PTR_ADD(graph, cir_start[(int32_t)head++]);
 		RTE_ASSERT(node->fence == RTE_GRAPH_FENCE);
 		objs = node->objs;
 		rte_prefetch0(objs);
-- 
2.32.0


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

* [PATCH v4 4/7] ipsec: fix missing explicit cast for C++ build
       [not found] ` <20220210154239.587185-1-bruce.richardson@intel.com>
                     ` (2 preceding siblings ...)
  2022-02-10 15:42   ` [PATCH v4 3/7] graph: fix missing explicit cast for C++ build Bruce Richardson
@ 2022-02-10 15:42   ` Bruce Richardson
  2022-02-10 15:42   ` [PATCH v4 5/7] table: fix missing explicit casts " Bruce Richardson
  2022-02-10 15:42   ` [PATCH v4 6/7] vhost: fix incompatible header includes for C++ Bruce Richardson
  5 siblings, 0 replies; 22+ messages in thread
From: Bruce Richardson @ 2022-02-10 15:42 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, konstantin.ananyev, stable, Declan Doherty,
	Akhil Goyal

C++ does not have automatic casting to/from void pointers, so need
explicit cast if header is to be included in C++ code

Fixes: f901d9c82688 ("ipsec: add helpers to group completed crypto-ops")
Cc: konstantin.ananyev@intel.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
 lib/ipsec/rte_ipsec_group.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/ipsec/rte_ipsec_group.h b/lib/ipsec/rte_ipsec_group.h
index 60ab297710..62c2bd7217 100644
--- a/lib/ipsec/rte_ipsec_group.h
+++ b/lib/ipsec/rte_ipsec_group.h
@@ -49,10 +49,10 @@ rte_ipsec_ses_from_crypto(const struct rte_crypto_op *cop)
 
 	if (cop->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
 		ss = cop->sym[0].sec_session;
-		return (void *)(uintptr_t)ss->opaque_data;
+		return (struct rte_ipsec_session *)(uintptr_t)ss->opaque_data;
 	} else if (cop->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
 		cs = cop->sym[0].session;
-		return (void *)(uintptr_t)cs->opaque_data;
+		return (struct rte_ipsec_session *)(uintptr_t)cs->opaque_data;
 	}
 	return NULL;
 }
-- 
2.32.0


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

* [PATCH v4 5/7] table: fix missing explicit casts for C++ build
       [not found] ` <20220210154239.587185-1-bruce.richardson@intel.com>
                     ` (3 preceding siblings ...)
  2022-02-10 15:42   ` [PATCH v4 4/7] ipsec: " Bruce Richardson
@ 2022-02-10 15:42   ` Bruce Richardson
  2022-02-10 15:42   ` [PATCH v4 6/7] vhost: fix incompatible header includes for C++ Bruce Richardson
  5 siblings, 0 replies; 22+ messages in thread
From: Bruce Richardson @ 2022-02-10 15:42 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, kevin.laatz, cristian.dumitrescu, stable,
	Gavin Hu, Jerin Jacob

Since C++ doesn't support automatic casting from void * to other types,
we need to explicitly add the casts to any header files in DPDK.

Fixes: ea7be0a0386e ("lib/librte_table: add hash function headers")
Cc: kevin.laatz@intel.com
Cc: cristian.dumitrescu@intel.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/table/rte_table_hash_func.h | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/lib/table/rte_table_hash_func.h b/lib/table/rte_table_hash_func.h
index c4c35cc06a..a962ec2f68 100644
--- a/lib/table/rte_table_hash_func.h
+++ b/lib/table/rte_table_hash_func.h
@@ -58,8 +58,8 @@ static inline uint64_t
 rte_table_hash_crc_key8(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t crc0;
 
 	crc0 = rte_crc32_u64(seed, k[0] & m[0]);
@@ -72,8 +72,8 @@ static inline uint64_t
 rte_table_hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, crc0, crc1;
 
 	k0 = k[0] & m[0];
@@ -91,8 +91,8 @@ static inline uint64_t
 rte_table_hash_crc_key24(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, crc0, crc1;
 
 	k0 = k[0] & m[0];
@@ -113,8 +113,8 @@ static inline uint64_t
 rte_table_hash_crc_key32(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, crc0, crc1, crc2, crc3;
 
 	k0 = k[0] & m[0];
@@ -139,8 +139,8 @@ static inline uint64_t
 rte_table_hash_crc_key40(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, crc0, crc1, crc2, crc3;
 
 	k0 = k[0] & m[0];
@@ -165,8 +165,8 @@ static inline uint64_t
 rte_table_hash_crc_key48(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, k5, crc0, crc1, crc2, crc3;
 
 	k0 = k[0] & m[0];
@@ -192,8 +192,8 @@ static inline uint64_t
 rte_table_hash_crc_key56(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
 
 	k0 = k[0] & m[0];
@@ -222,8 +222,8 @@ static inline uint64_t
 rte_table_hash_crc_key64(void *key, void *mask, __rte_unused uint32_t key_size,
 	uint64_t seed)
 {
-	uint64_t *k = key;
-	uint64_t *m = mask;
+	uint64_t *k = (uint64_t *)key;
+	uint64_t *m = (uint64_t *)mask;
 	uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
 
 	k0 = k[0] & m[0];
-- 
2.32.0


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

* [PATCH v4 6/7] vhost: fix incompatible header includes for C++
       [not found] ` <20220210154239.587185-1-bruce.richardson@intel.com>
                     ` (4 preceding siblings ...)
  2022-02-10 15:42   ` [PATCH v4 5/7] table: fix missing explicit casts " Bruce Richardson
@ 2022-02-10 15:42   ` Bruce Richardson
  5 siblings, 0 replies; 22+ messages in thread
From: Bruce Richardson @ 2022-02-10 15:42 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, adrien.mazarguil, stable, Yuanhan Liu, Maxime Coquelin

The virtio kernel header includes are already noted as being
incompatible with C++. We can ensure that the header is safe for
inclusion in C++ code by not including those headers during C++ builds.
While not ideal, this does ensure that all DPDK headers can be included
in C++ code without errors.

Fixes: f8904d563691 ("vhost: fix header for strict compilation flags")
Cc: adrien.mazarguil@6wind.com
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/vhost/rte_vhost.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/vhost/rte_vhost.h b/lib/vhost/rte_vhost.h
index b454c05868..2acb31df2d 100644
--- a/lib/vhost/rte_vhost.h
+++ b/lib/vhost/rte_vhost.h
@@ -21,10 +21,12 @@
 extern "C" {
 #endif
 
+#ifndef __cplusplus
 /* These are not C++-aware. */
 #include <linux/vhost.h>
 #include <linux/virtio_ring.h>
 #include <linux/virtio_net.h>
+#endif
 
 #define RTE_VHOST_USER_CLIENT		(1ULL << 0)
 #define RTE_VHOST_USER_NO_RECONNECT	(1ULL << 1)
-- 
2.32.0


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

* RE: [PATCH v4 1/7] eal: fix header build with C++
  2022-02-10 15:42   ` [PATCH v4 1/7] eal: fix header build with C++ Bruce Richardson
@ 2022-02-14  9:30     ` Joyce Kong
  0 siblings, 0 replies; 22+ messages in thread
From: Joyce Kong @ 2022-02-14  9:30 UTC (permalink / raw)
  To: Bruce Richardson, dev
  Cc: jerinj, stable, Gavin Hu, Konstantin Ananyev,
	Honnappa Nagarahalli, Ola Liljedahl, Sunil Kumar Kori,
	David Marchand

<snip>

> Subject: [PATCH v4 1/7] eal: fix header build with C++
>
> C++ files could not include some headers because:
>
> * "new" is a keyword in C++, so can't be a variable name
> * there is no automatic casting to/from void *
>
> Fixes: 184104fc6121 ("ticketlock: introduce fair ticket based locking")
> Fixes: 032a7e5499a0 ("trace: implement provider payload")
> Cc: joyce.kong@arm.com
> Cc: jerinj@marvell.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Joyce Kong <joyce.kong@arm.com>

> ---
>  lib/eal/include/generic/rte_ticketlock.h | 14 +++++++-------
>  lib/eal/include/rte_trace_point.h        |  2 +-
>  2 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/lib/eal/include/generic/rte_ticketlock.h
> b/lib/eal/include/generic/rte_ticketlock.h
> index c1b8808f51..693c67b517 100644
> --- a/lib/eal/include/generic/rte_ticketlock.h
> +++ b/lib/eal/include/generic/rte_ticketlock.h
> @@ -91,13 +91,13 @@ rte_ticketlock_unlock(rte_ticketlock_t *tl)  static
> inline int  rte_ticketlock_trylock(rte_ticketlock_t *tl)  {
> -     rte_ticketlock_t old, new;
> -     old.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_RELAXED);
> -     new.tickets = old.tickets;
> -     new.s.next++;
> -     if (old.s.next == old.s.current) {
> -             if (__atomic_compare_exchange_n(&tl->tickets, &old.tickets,
> -                 new.tickets, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
> +     rte_ticketlock_t oldl, newl;
> +     oldl.tickets = __atomic_load_n(&tl->tickets, __ATOMIC_RELAXED);
> +     newl.tickets = oldl.tickets;
> +     newl.s.next++;
> +     if (oldl.s.next == oldl.s.current) {
> +             if (__atomic_compare_exchange_n(&tl->tickets, &oldl.tickets,
> +                 newl.tickets, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
>                       return 1;
>       }
>
> diff --git a/lib/eal/include/rte_trace_point.h
> b/lib/eal/include/rte_trace_point.h
> index e226f073f7..0f8700974f 100644
> --- a/lib/eal/include/rte_trace_point.h
> +++ b/lib/eal/include/rte_trace_point.h
> @@ -370,7 +370,7 @@ do { \
>  do { \
>       if (unlikely(in == NULL)) \
>               return; \
> -     rte_strscpy(mem, in, __RTE_TRACE_EMIT_STRING_LEN_MAX); \
> +     rte_strscpy((char *)mem, in, __RTE_TRACE_EMIT_STRING_LEN_MAX);
> \
>       mem = RTE_PTR_ADD(mem, __RTE_TRACE_EMIT_STRING_LEN_MAX);
> \  } while (0)
>
> --
> 2.32.0

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

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

end of thread, other threads:[~2022-02-14  9:31 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20220204174209.440207-1-bruce.richardson@intel.com>
     [not found] ` <20220210120257.585822-1-bruce.richardson@intel.com>
2022-02-10 12:02   ` [PATCH v2 1/7] eal: fix header build with C++ Bruce Richardson
2022-02-10 12:57     ` David Marchand
2022-02-10 14:07       ` Bruce Richardson
2022-02-10 12:02   ` [PATCH v2 2/7] eventdev: " Bruce Richardson
2022-02-10 12:02   ` [PATCH v2 3/7] graph: fix missing explicit cast for C++ build Bruce Richardson
2022-02-10 12:02   ` [PATCH v2 4/7] ipsec: " Bruce Richardson
2022-02-10 12:42     ` Ananyev, Konstantin
2022-02-10 12:02   ` [PATCH v2 5/7] table: fix missing explicit casts " Bruce Richardson
2022-02-10 12:02   ` [PATCH v2 6/7] vhost: fix incompatible header includes for C++ Bruce Richardson
     [not found] ` <20220210140355.586399-1-bruce.richardson@intel.com>
2022-02-10 14:03   ` [PATCH v3 1/7] eal: fix header build with C++ Bruce Richardson
2022-02-10 14:03   ` [PATCH v3 2/7] eventdev: " Bruce Richardson
2022-02-10 14:03   ` [PATCH v3 3/7] graph: fix missing explicit cast for C++ build Bruce Richardson
2022-02-10 14:03   ` [PATCH v3 4/7] ipsec: " Bruce Richardson
2022-02-10 14:03   ` [PATCH v3 5/7] table: fix missing explicit casts " Bruce Richardson
2022-02-10 14:03   ` [PATCH v3 6/7] vhost: fix incompatible header includes for C++ Bruce Richardson
     [not found] ` <20220210154239.587185-1-bruce.richardson@intel.com>
2022-02-10 15:42   ` [PATCH v4 1/7] eal: fix header build with C++ Bruce Richardson
2022-02-14  9:30     ` Joyce Kong
2022-02-10 15:42   ` [PATCH v4 2/7] eventdev: " Bruce Richardson
2022-02-10 15:42   ` [PATCH v4 3/7] graph: fix missing explicit cast for C++ build Bruce Richardson
2022-02-10 15:42   ` [PATCH v4 4/7] ipsec: " Bruce Richardson
2022-02-10 15:42   ` [PATCH v4 5/7] table: fix missing explicit casts " Bruce Richardson
2022-02-10 15:42   ` [PATCH v4 6/7] vhost: fix incompatible header includes for C++ Bruce Richardson

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