Skip to contentSkip to conversation

The question for the modification against (lib/cryptodev/rte_cryptodev.h) in commit 719834a6

PATCH Superseded Hu, Zhigang 5 participants 12 messages Dec 19, 2024 – Jan 8, 2025

lore
Share & tools
lore
#0 lore raw

Hi, experts,

My C++ program calls some functions defined in lib/cryptodev/rte_cryptodev.h. After upgrading dpdk from 23.11 to 24.11, my C++ program failed to be complied. It looks like that the cimmit 719834a6 caused my issue.

It seems that the commit 719834a6 intends to exclude all head files from the
#ifdef __cplusplus
extern "C" {
#endif
......
#ifdef __cplusplus
}
#endif
Unfortunately some function declarations are also excluded wrongly since these declarations are before the last head file. Below picture is an example. The function in the red circle can't be linked by C++ complier. Would you please help to check this issue?

Best regards!
Hu Zhigang

[cid:bbf5bf01-e72e-42b0-8b1a-fc627fbb1dc5]

#1 lore raw

PATCH 1/1 cryptodev: fix C++ include

Some cryptodev functions were not included in the extern "C" block, so it is moved to start before.

An include is also moved to avoid being part of this block.

Fixes 719834a6849e ("use C linkage where appropriate in headers")
---
 .mailmap                      |  1 +
 lib/cryptodev/rte_cryptodev.h | 10 +++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)
.mailmap +1 -0
index 2bf38f9e8c..1e4bb06d6e 100644
@@ -1794,6 +1794,7 @@ Zhenghua Zhou <[email protected]>
 Zhenning Xiao <[email protected]>
 Zhe Tao <[email protected]>
 Zhichao Zeng <[email protected]>
+Zhigang Hu <[email protected]>
 Zhigang Lu <[email protected]>
 Zhiguang He <[email protected]>
 Zhihong Peng <[email protected]>
lib/cryptodev/rte_cryptodev.h +5 -5
index c64d2f83a0..31a7edb189 100644
@@ -21,6 +21,11 @@
 #include <rte_rcu_qsbr.h>
 
 #include "rte_cryptodev_trace_fp.h"
+#include "rte_cryptodev_core.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /**
  * @internal Logtype used for cryptodev related messages.
@@ -1928,11 +1933,6 @@ int rte_cryptodev_remove_deq_callback(uint8_t dev_id,
 				      uint16_t qp_id,
 				      struct rte_cryptodev_cb *cb);
 
-#include <rte_cryptodev_core.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
 /**
  *
  * Dequeue a burst of processed crypto operations from a queue on the crypto
Signature · 1 line
2.47.1
#2 lore raw

RE: [EXTERNAL] [PATCH] cryptodev: fix C++ include

Quoted 32 lines

Some cryptodev functions were not included in the extern "C" block, so it is moved to start before.

An include is also moved to avoid being part of this block.

Fixes 719834a6849e ("use C linkage where appropriate in headers")
---
 .mailmap                      |  1 +
 lib/cryptodev/rte_cryptodev.h | 10 +++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)
.mailmap +1 -0
index 2bf38f9e8c..1e4bb06d6e 100644
@@ -1794,6 +1794,7 @@ Zhenghua Zhou <[email protected]>
 Zhenning Xiao <[email protected]>
 Zhe Tao <[email protected]>
 Zhichao Zeng <[email protected]>
+Zhigang Hu <[email protected]>
 Zhigang Lu <[email protected]>
 Zhiguang He <[email protected]>
 Zhihong Peng <[email protected]>
lib/cryptodev/rte_cryptodev.h +0 -0
index c64d2f83a0..31a7edb189 100644

lib/cryptodev/rte_cryptodev.h line 24

Quoted 4 lines
lib/cryptodev/rte_cryptodev.h +1 -0
@@ -21,6 +21,11 @@
 #include <rte_rcu_qsbr.h>
 
 #include "rte_cryptodev_trace_fp.h"
+#include "rte_cryptodev_core.h"

Fix is ok but rte_cryptodev_core.h should not be moved up. It is added in the middle to segregate the fast path APIs. And it is an internal header which cannot be included by app directly. I think the same schema is followed in ethdev as well.

Quoted 22 lines
lib/cryptodev/rte_cryptodev.h +4 -5
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /**
  * @internal Logtype used for cryptodev related messages.
@@ -1928,11 +1933,6 @@ int rte_cryptodev_remove_deq_callback(uint8_t
 dev_id,
 				      uint16_t qp_id,
 				      struct rte_cryptodev_cb *cb);
 
-#include <rte_cryptodev_core.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
 /**
  *

* Dequeue a burst of processed crypto operations from a queue on the crypto
--
2.47.1

#3 lore raw

Re: [EXTERNAL] [PATCH] cryptodev: fix C++ include

19/12/2024 13:24, Akhil Goyal:

Quoted 4 lines
Quoted 4 lines

Some cryptodev functions were not included in the extern "C" block, so it is moved to start before.

An include is also moved to avoid being part of this block.

[...]

Quoted 5 lines
Quoted 5 lines
lib/cryptodev/rte_cryptodev.h +0 -0
@@ -21,6 +21,11 @@
 #include <rte_rcu_qsbr.h>
 
Quoted 7 lines

lib/cryptodev/rte_cryptodev.h line 24

Quoted 2 lines
lib/cryptodev/rte_cryptodev.h +1 -0
 #include "rte_cryptodev_trace_fp.h"
+#include "rte_cryptodev_core.h"

Fix is ok but rte_cryptodev_core.h should not be moved up. It is added in the middle to segregate the fast path APIs. And it is an internal header which cannot be included by app directly. I think the same schema is followed in ethdev as well.

Indeed, this is how it's done in ethdev:

#ifdef __cplusplus
}
#endif

#include <rte_ethdev_core.h>

#ifdef __cplusplus
extern "C" {
#endif

I'll do the same in v2.

#5 lore raw

Hi Thomas,

Thank you for your quick response.

Your v1 patch works fine in my test. We are looking forward to your v2 patch.

Best Regards,
Zhigang
________________________________
From: Thomas Monjalon <[email protected]>
Sent: Thursday, December 19, 2024 7:48 PM
To: Hu, Zhigang <[email protected]>
Cc: [email protected] <[email protected]>; Dong, Yao <[email protected]>; Richardson, Bruce <[email protected]>; [email protected] <[email protected]>
Subject: Re: The question for the modification against (lib/cryptodev/rte_cryptodev.h) in commit 719834a6

19/12/2024 11:41, Hu, Zhigang:

Quoted 3 lines

Hi, experts,

My C++ program calls some functions defined in lib/cryptodev/rte_cryptodev.h. After upgrading dpdk from 23.11 to 24.11, my C++ program failed to be complied. It looks like that the cimmit 719834a6 caused my issue.

Yes, you're right.
Thanks for reporting.

Please could you try this fix?
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

#6 lore raw

Hi Thomas,

Sorry for my mistake. I see the v2 patch.

Best regards,
Hu Zhigang

________________________________
From: Hu, Zhigang <[email protected]>
Sent: Friday, December 20, 2024 10:17 AM
To: Thomas Monjalon <[email protected]>
Cc: [email protected] <[email protected]>; Dong, Yao <[email protected]>; Richardson, Bruce <[email protected]>; [email protected] <[email protected]>; Liu1, Kai <[email protected]>; Chautru, Nicolas <[email protected]>
Subject: Re: The question for the modification against (lib/cryptodev/rte_cryptodev.h) in commit 719834a6

Hi Thomas,

Thank you for your quick response.

Your v1 patch works fine in my test. We are looking forward to your v2 patch.

Best Regards,
Zhigang
________________________________
From: Thomas Monjalon <[email protected]>
Sent: Thursday, December 19, 2024 7:48 PM
To: Hu, Zhigang <[email protected]>
Cc: [email protected] <[email protected]>; Dong, Yao <[email protected]>; Richardson, Bruce <[email protected]>; [email protected] <[email protected]>
Subject: Re: The question for the modification against (lib/cryptodev/rte_cryptodev.h) in commit 719834a6

19/12/2024 11:41, Hu, Zhigang:

Quoted 3 lines

Hi, experts,

My C++ program calls some functions defined in lib/cryptodev/rte_cryptodev.h. After upgrading dpdk from 23.11 to 24.11, my C++ program failed to be complied. It looks like that the cimmit 719834a6 caused my issue.

Yes, you're right.
Thanks for reporting.

Please could you try this fix?
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

#7 lore raw

PATCH v2 1/1 cryptodev: fix C++ include

In reply to Hu, Zhigang

Some cryptodev functions were not included in an extern "C" block.

There are 2 blocks, the second one being fast path inline functions, preceded with an include of the required rte_cryptodev_core.h file.

Fixes 719834a6849e ("use C linkage where appropriate in headers")

---
v2: keep rte_cryptodev_core.h include at the same place

---
 .mailmap                      |  1 +
 lib/cryptodev/rte_cryptodev.h | 12 ++++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)
.mailmap +1 -0
index 2bf38f9e8c..1e4bb06d6e 100644
@@ -1794,6 +1794,7 @@ Zhenghua Zhou <[email protected]>
 Zhenning Xiao <[email protected]>
 Zhe Tao <[email protected]>
 Zhichao Zeng <[email protected]>
+Zhigang Hu <[email protected]>
 Zhigang Lu <[email protected]>
 Zhiguang He <[email protected]>
 Zhihong Peng <[email protected]>
lib/cryptodev/rte_cryptodev.h +10 -2
index c64d2f83a0..071ff3dbdf 100644
@@ -22,6 +22,10 @@
 
 #include "rte_cryptodev_trace_fp.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /**
  * @internal Logtype used for cryptodev related messages.
  */
@@ -1928,11 +1932,16 @@ int rte_cryptodev_remove_deq_callback(uint8_t dev_id,
 				      uint16_t qp_id,
 				      struct rte_cryptodev_cb *cb);
 
-#include <rte_cryptodev_core.h>
+#ifdef __cplusplus
+}
+#endif
+
+#include "rte_cryptodev_core.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
+
 /**
  *
  * Dequeue a burst of processed crypto operations from a queue on the crypto
@@ -2125,7 +2134,6 @@ rte_cryptodev_qp_depth_used(uint8_t dev_id, uint16_t qp_id)
 	return rc;
 }
 
-
 #ifdef __cplusplus
 }
 #endif
Signature · 1 line
2.47.1
Reviewed-by on v2 1/1
#8 lore raw

Re: [PATCH v2] cryptodev: fix C++ include

Quoted 11 lines · Thomas Monjalon

Some cryptodev functions were not included in an extern "C" block.

There are 2 blocks, the second one being fast path inline functions, preceded with an include of the required rte_cryptodev_core.h file.

Fixes 719834a6849e ("use C linkage where appropriate in headers")

I wonder if there is also an issue with lib/cryptodev/rte_crypto_asym.h, for symbols rte_crypto_asym_ke_strings and rte_crypto_asym_op_strings. But at least this patch looks fine to me.

Signature · 1 line
David Marchand
#9 lore raw

Re: [PATCH v2] cryptodev: fix C++ include

Quoted 10 lines · David Marchand
Quoted 9 lines · Thomas Monjalon

Some cryptodev functions were not included in an extern "C" block.

There are 2 blocks, the second one being fast path inline functions, preceded with an include of the required rte_cryptodev_core.h file.

Fixes 719834a6849e ("use C linkage where appropriate in headers")
Quoted 6 lines
Quoted 2 lines

I wonder if there is also an issue with lib/cryptodev/rte_crypto_asym.h, for symbols rte_crypto_asym_ke_strings and rte_crypto_asym_op_strings.

+1

Quoted 5 lines

But at least this patch looks fine to me.

Reviewed-by on v2 1/1
#10 lore raw

Re: [PATCH v2] cryptodev: fix C++ include

In reply to Thomas Monjalon
Quoted 63 lines · Thomas Monjalon

Some cryptodev functions were not included in an extern "C" block.

There are 2 blocks, the second one being fast path inline functions, preceded with an include of the required rte_cryptodev_core.h file.

Fixes 719834a6849e ("use C linkage where appropriate in headers")

---
v2: keep rte_cryptodev_core.h include at the same place

---
  .mailmap                      |  1 +
  lib/cryptodev/rte_cryptodev.h | 12 ++++++++++--
  2 files changed, 11 insertions(+), 2 deletions(-)
.mailmap +1 -0
index 2bf38f9e8c..1e4bb06d6e 100644
@@ -1794,6 +1794,7 @@ Zhenghua Zhou <[email protected]>
  Zhenning Xiao <[email protected]>
  Zhe Tao <[email protected]>
  Zhichao Zeng <[email protected]>
+Zhigang Hu <[email protected]>
  Zhigang Lu <[email protected]>
  Zhiguang He <[email protected]>
  Zhihong Peng <[email protected]>
lib/cryptodev/rte_cryptodev.h +10 -1
index c64d2f83a0..071ff3dbdf 100644
@@ -22,6 +22,10 @@
 
  #include "rte_cryptodev_trace_fp.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
  /**
   * @internal Logtype used for cryptodev related messages.
   */
@@ -1928,11 +1932,16 @@ int rte_cryptodev_remove_deq_callback(uint8_t dev_id,
  				      uint16_t qp_id,
  				      struct rte_cryptodev_cb *cb);
 
-#include <rte_cryptodev_core.h>
+#ifdef __cplusplus
+}
+#endif
+
+#include "rte_cryptodev_core.h"
 
  #ifdef __cplusplus
  extern "C" {
  #endif
+
  /**
   *
   * Dequeue a burst of processed crypto operations from a queue on the crypto

lib/cryptodev/rte_cryptodev.h rte_cryptodev_qp_depth_used(uint8_t dev_id, uint16_t qp_id) · line 2139

Quoted 7 lines
lib/cryptodev/rte_cryptodev.h +0 -1
@@ -2125,7 +2134,6 @@ rte_cryptodev_qp_depth_used(uint8_t dev_id, uint16_t qp_id)
  	return rc;
  }
 
-
  #ifdef __cplusplus
  }
  #endif
Applied
#11 lore raw

RE: [EXTERNAL] Re: [PATCH v2] cryptodev: fix C++ include

Quoted 9 lines · Thomas Monjalon
Quoted 8 lines

Some cryptodev functions were not included in an extern "C" block.

There are 2 blocks, the second one being fast path inline functions, preceded with an include of the required rte_cryptodev_core.h file.

Fixes 719834a6849e ("use C linkage where appropriate in headers")
Quoted 6 lines
Quoted 4 lines

---
v2: keep rte_cryptodev_core.h include at the same place

Applied to dpdk-next-crypto
Thanks.