[6/6] cryptodev: replace mbuf scatter gather flag
diff mbox series

Message ID 20180608220234.10170-7-pablo.de.lara.guarch@intel.com
State Superseded, archived
Delegated to: Pablo de Lara Guarch
Headers show
Series
  • Cryptodev API changes
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Pablo de Lara June 8, 2018, 10:02 p.m. UTC
The current mbuf scatter gatter feature flag is
too ambiguous, as it is not clear if input and/or output
buffers can be scatter gather mbufs or not.

Therefore, two new flags will replace this flag:
RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_IN and
RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_OUT.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 doc/guides/rel_notes/deprecation.rst        |  2 -
 doc/guides/rel_notes/release_18_08.rst      |  4 ++
 drivers/crypto/aesni_gcm/aesni_gcm_pmd.c    |  2 +-
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |  2 +-
 drivers/crypto/dpaa_sec/dpaa_sec.c          |  3 +-
 drivers/crypto/null/null_crypto_pmd.c       |  3 +-
 drivers/crypto/openssl/rte_openssl_pmd.c    |  2 +-
 drivers/crypto/qat/rte_qat_cryptodev.c      |  3 +-
 lib/librte_cryptodev/rte_cryptodev.c        |  6 ++-
 lib/librte_cryptodev/rte_cryptodev.h        | 12 +++---
 test/test/test_cryptodev.c                  | 41 ++++++++++++++-------
 test/test/test_cryptodev_blockcipher.c      | 11 ++++--
 12 files changed, 59 insertions(+), 32 deletions(-)

Comments

Akhil Goyal June 18, 2018, 6:29 a.m. UTC | #1
Hi Pablo,
On 6/9/2018 3:32 AM, Pablo de Lara wrote:
> The current mbuf scatter gatter feature flag is
> too ambiguous, as it is not clear if input and/or output
> buffers can be scatter gather mbufs or not.
>
> Therefore, two new flags will replace this flag:
> RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_IN and
> RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_OUT.
>
There may be a case, SG supported in input buffer and we use in-place 
processing and driver may support that but may not support SG for out 
buffers in case of OOP. How can we handle this type of case?

> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---
>  doc/guides/rel_notes/deprecation.rst        |  2 -
>  doc/guides/rel_notes/release_18_08.rst      |  4 ++
>  drivers/crypto/aesni_gcm/aesni_gcm_pmd.c    |  2 +-
>  drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |  2 +-
>  drivers/crypto/dpaa_sec/dpaa_sec.c          |  3 +-
>  drivers/crypto/null/null_crypto_pmd.c       |  3 +-
>  drivers/crypto/openssl/rte_openssl_pmd.c    |  2 +-
>  drivers/crypto/qat/rte_qat_cryptodev.c      |  3 +-
>  lib/librte_cryptodev/rte_cryptodev.c        |  6 ++-
>  lib/librte_cryptodev/rte_cryptodev.h        | 12 +++---
>  test/test/test_cryptodev.c                  | 41 ++++++++++++++-------
>  test/test/test_cryptodev_blockcipher.c      | 11 ++++--
>  12 files changed, 59 insertions(+), 32 deletions(-)
>
Pablo de Lara June 25, 2018, 4:43 p.m. UTC | #2
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Akhil Goyal
> Sent: Monday, June 18, 2018 7:30 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>; Doherty, Declan
> <declan.doherty@intel.com>; akhil.goyal@nxp.com; ravi1.kumar@amd.com;
> jerin.jacob@caviumnetworks.com; Zhang, Roy Fan <roy.fan.zhang@intel.com>;
> Trahe, Fiona <fiona.trahe@intel.com>; tdu@semihalf.com;
> jianjay.zhou@huawei.com
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 6/6] cryptodev: replace mbuf scatter gather flag
> 
> Hi Pablo,
> On 6/9/2018 3:32 AM, Pablo de Lara wrote:
> > The current mbuf scatter gatter feature flag is too ambiguous, as it
> > is not clear if input and/or output buffers can be scatter gather
> > mbufs or not.
> >
> > Therefore, two new flags will replace this flag:
> > RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_IN and
> > RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_OUT.
> >
> There may be a case, SG supported in input buffer and we use in-place
> processing and driver may support that but may not support SG for out buffers in
> case of OOP. How can we handle this type of case?

Agree. I will send a new version with more flags, so we can cover all scenarios.

Thanks for the feedback!
Pablo

Patch
diff mbox series

diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 9a73b1d8e..62d635b74 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -105,5 +105,3 @@  Deprecation Notices
     ``rte_cryptodev_queue_pair_dettach_sym_session()`` will be deprecated from
     18.05 and removed in 18.08, as there are no drivers doing anything useful
     with them.
-  - Some feature flags such as ``RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER`` are ambiguous,
-    so some will be replaced by more explicit flags.
diff --git a/doc/guides/rel_notes/release_18_08.rst b/doc/guides/rel_notes/release_18_08.rst
index 0624f3701..89b84846c 100644
--- a/doc/guides/rel_notes/release_18_08.rst
+++ b/doc/guides/rel_notes/release_18_08.rst
@@ -72,6 +72,10 @@  API Changes
   - ``rte_cryptodev_get_private_session_size`` is replaced with
     ``rte_cryptodev_sym_get_private_session_size``
 
+* cryptodev: Feature flag ``RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER`` is
+  replaced with the more explicit``RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_IN``
+  and ``RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_OUT`` flags.
+
 
 ABI Changes
 -----------
diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
index cd5b1952b..aa795cbbc 100644
--- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
+++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c
@@ -492,7 +492,7 @@  aesni_gcm_create(const char *name,
 	dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
 			RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
 			RTE_CRYPTODEV_FF_CPU_AESNI |
-			RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER;
+			RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_IN;
 
 	switch (vector_mode) {
 	case RTE_AESNI_GCM_SSE:
diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 471ad1cbb..cadfeddeb 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -2762,7 +2762,7 @@  dpaa2_sec_dev_init(struct rte_cryptodev *cryptodev)
 			RTE_CRYPTODEV_FF_HW_ACCELERATED |
 			RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
 			RTE_CRYPTODEV_FF_SECURITY |
-			RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER;
+			RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_IN;
 
 	internals = cryptodev->data->dev_private;
 	internals->max_nb_sessions = RTE_DPAA2_SEC_PMD_MAX_NB_SESSIONS;
diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index e7ae33c5e..54540d7f6 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -2270,7 +2270,8 @@  dpaa_sec_dev_init(struct rte_cryptodev *cryptodev)
 			RTE_CRYPTODEV_FF_HW_ACCELERATED |
 			RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
 			RTE_CRYPTODEV_FF_SECURITY |
-			RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER;
+			RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_IN |
+			RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_OUT;
 
 	internals = cryptodev->data->dev_private;
 	internals->max_nb_queue_pairs = RTE_DPAA_MAX_NB_SEC_QPS;
diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c
index a8499cf94..d9dc22e0f 100644
--- a/drivers/crypto/null/null_crypto_pmd.c
+++ b/drivers/crypto/null/null_crypto_pmd.c
@@ -177,7 +177,8 @@  cryptodev_null_create(const char *name,
 
 	dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
 			RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
-			RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER;
+			RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_IN |
+			RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_OUT;
 
 	internals = dev->data->dev_private;
 
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index 965cab9f2..6878baa4c 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -1660,7 +1660,7 @@  cryptodev_openssl_create(const char *name,
 	dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
 			RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
 			RTE_CRYPTODEV_FF_CPU_AESNI |
-			RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER;
+			RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_IN;
 
 	/* Set vector instructions mode supported */
 	internals = dev->data->dev_private;
diff --git a/drivers/crypto/qat/rte_qat_cryptodev.c b/drivers/crypto/qat/rte_qat_cryptodev.c
index bb109f8ba..4f1ba5f30 100644
--- a/drivers/crypto/qat/rte_qat_cryptodev.c
+++ b/drivers/crypto/qat/rte_qat_cryptodev.c
@@ -89,7 +89,8 @@  crypto_qat_create(const char *name, struct rte_pci_device *pci_dev,
 	cryptodev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
 			RTE_CRYPTODEV_FF_HW_ACCELERATED |
 			RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
-			RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER;
+			RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_IN |
+			RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_OUT;
 
 	internals = cryptodev->data->dev_private;
 	switch (pci_dev->id.device_id) {
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 40e249e79..b180d4c84 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -361,8 +361,10 @@  rte_cryptodev_get_feature_name(uint64_t flag)
 		return "CPU_AESNI";
 	case RTE_CRYPTODEV_FF_HW_ACCELERATED:
 		return "HW_ACCELERATED";
-	case RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER:
-		return "MBUF_SCATTER_GATHER";
+	case RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_IN:
+		return "MBUF_INPUT_SCATTER_GATHER";
+	case RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_OUT:
+		return "MBUF_OUTPUT_SCATTER_GATHER";
 	case RTE_CRYPTODEV_FF_CPU_NEON:
 		return "CPU_NEON";
 	case RTE_CRYPTODEV_FF_CPU_ARM_CE:
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 8e8a59522..bfb52e7f2 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -345,13 +345,15 @@  rte_cryptodev_get_aead_algo_enum(enum rte_crypto_aead_algorithm *algo_enum,
 /**< Operations are off-loaded to an external hardware accelerator */
 #define	RTE_CRYPTODEV_FF_CPU_AVX512		(1ULL << 8)
 /**< Utilises CPU SIMD AVX512 instructions */
-#define	RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER	(1ULL << 9)
-/**< Scatter-gather mbufs are supported */
-#define	RTE_CRYPTODEV_FF_CPU_NEON		(1ULL << 10)
+#define	RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_IN	(1ULL << 9)
+/**< Scatter-gather input mbufs are supported */
+#define RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_OUT (1ULL << 10)
+/**< Scatter-gather output mbufs are supported */
+#define	RTE_CRYPTODEV_FF_CPU_NEON		(1ULL << 11)
 /**< Utilises CPU NEON instructions */
-#define	RTE_CRYPTODEV_FF_CPU_ARM_CE		(1ULL << 11)
+#define	RTE_CRYPTODEV_FF_CPU_ARM_CE		(1ULL << 12)
 /**< Utilises ARM CPU Cryptographic Extensions */
-#define	RTE_CRYPTODEV_FF_SECURITY		(1ULL << 12)
+#define	RTE_CRYPTODEV_FF_SECURITY		(1ULL << 13)
 /**< Support Security Protocol Processing */
 
 
diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c
index 2c687bd7c..627c3b1b3 100644
--- a/test/test/test_cryptodev.c
+++ b/test/test/test_cryptodev.c
@@ -3152,9 +3152,13 @@  test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
 	struct rte_cryptodev_info dev_info;
 
 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
-	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
-		printf("Device doesn't support scatter-gather. "
-				"Test Skipped.\n");
+
+	uint64_t feat_flags = dev_info.feature_flags;
+
+	if (!(feat_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_IN) ||
+			!(feat_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_OUT)) {
+		printf("Device doesn't support scatter-gather in both input "
+				"and output mbufs. Test Skipped.\n");
 		return 0;
 	}
 
@@ -3300,9 +3304,12 @@  test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
 	struct rte_cryptodev_info dev_info;
 
 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
-	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
-		printf("Device doesn't support scatter-gather. "
-				"Test Skipped.\n");
+
+	uint64_t feat_flags = dev_info.feature_flags;
+	if (!(feat_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_IN) ||
+			!(feat_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_OUT)) {
+		printf("Device doesn't support scatter-gather in both input "
+				"and output mbufs. Test Skipped.\n");
 		return 0;
 	}
 
@@ -3651,9 +3658,13 @@  test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
 	struct rte_cryptodev_info dev_info;
 
 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
-	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
-		printf("Device doesn't support scatter-gather. "
-				"Test Skipped.\n");
+
+	uint64_t feat_flags = dev_info.feature_flags;
+
+	if (!(feat_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_IN) ||
+			!(feat_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_OUT)) {
+		printf("Device doesn't support scatter-gather in both input "
+				"and output mbufs. Test Skipped.\n");
 		return 0;
 	}
 
@@ -4485,10 +4496,14 @@  test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
 		return -ENOTSUP;
 
 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
-	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
-		printf("Device doesn't support scatter-gather. "
-				"Test Skipped.\n");
-		return -ENOTSUP;
+
+	uint64_t feat_flags = dev_info.feature_flags;
+
+	if (!(feat_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_IN) ||
+			!(feat_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_OUT)) {
+		printf("Device doesn't support scatter-gather in both input "
+				"and output mbufs. Test Skipped.\n");
+		return 0;
 	}
 
 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
diff --git a/test/test/test_cryptodev_blockcipher.c b/test/test/test_cryptodev_blockcipher.c
index 256a7daa2..7a56171e9 100644
--- a/test/test/test_cryptodev_blockcipher.c
+++ b/test/test/test_cryptodev_blockcipher.c
@@ -77,10 +77,13 @@  test_blockcipher_one_case(const struct blockcipher_test_case *t,
 
 	if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SG) {
 		rte_cryptodev_info_get(dev_id, &dev_info);
-		if (!(dev_info.feature_flags &
-				RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
-			printf("Device doesn't support scatter-gather. "
-					"Test Skipped.\n");
+		uint64_t feat_flags = dev_info.feature_flags;
+
+		if (!(feat_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_IN) ||
+				!(feat_flags &
+					RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER_OUT)) {
+			printf("Device doesn't support scatter-gather in both input "
+				"and output mbufs. Test Skipped.\n");
 			return 0;
 		}
 		nb_segs = 3;