[v3,03/16] app/crypto-perf: limit number of sessions

Message ID 20180628005304.26544-4-pablo.de.lara.guarch@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Pablo de Lara Guarch
Headers
Series Cryptodev API changes for 18.08 |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

De Lara Guarch, Pablo June 28, 2018, 12:52 a.m. UTC
  Instead of creating a fixed number of sessions,
calculate the necessary number based on number of devices
and queue pairs used.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 app/test-crypto-perf/main.c | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)
  

Comments

Akhil Goyal July 4, 2018, 12:13 p.m. UTC | #1
On 6/28/2018 6:22 AM, Pablo de Lara wrote:
> Instead of creating a fixed number of sessions,
> calculate the necessary number based on number of devices
> and queue pairs used.
>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---

Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
  
Akhil Goyal July 4, 2018, 12:15 p.m. UTC | #2
On 6/28/2018 6:22 AM, Pablo de Lara wrote:
> Instead of creating a fixed number of sessions,
> calculate the necessary number based on number of devices
> and queue pairs used.
>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---
>   app/test-crypto-perf/main.c | 31 ++++++++++++++++++++++++++++---
>   1 file changed, 28 insertions(+), 3 deletions(-)
>
> diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
> index 4ae14390b..b02d3f597 100644
> --- a/app/test-crypto-perf/main.c
> +++ b/app/test-crypto-perf/main.c
> @@ -21,7 +21,6 @@
>   #include "cperf_test_verify.h"
>   #include "cperf_test_pmd_cyclecount.h"
>   
> -#define NUM_SESSIONS 2048
>   #define SESS_MEMPOOL_CACHE_SIZE 64
>   
>   const char *cperf_test_type_strs[] = {
> @@ -149,15 +148,41 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs,
>   			.nb_descriptors = opts->nb_descriptors
>   		};
>   
> +		uint32_t dev_max_nb_sess = cdev_info.sym.max_nb_sessions;
> +		/* Two sessions objects are required for each session
> +		 * (one for the header, one for the private data)
> +		 */
> +		uint32_t sessions_needed = 2 * enabled_cdev_count *
> +						opts->nb_qps;
> +#ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
> +		if (!strcmp((const char *)opts->device_type,
> +					"crypto_scheduler")) {
> +			uint32_t nb_slaves =
> +				rte_cryptodev_scheduler_slaves_get(cdev_id,
> +								NULL);
> +
> +			sessions_needed = 2 * enabled_cdev_count *
> +				opts->nb_qps * nb_slaves;
> +		}
> +#endif

One minor. Can we have #else?

> +		/*
> +		 * A single session is required per queue pair
> +		 * in each device
> +		 */
> +		if (dev_max_nb_sess < opts->nb_qps) {
> +			RTE_LOG(ERR, USER1,
> +				"Device does not support at least "
> +				"%u sessions\n", opts->nb_qps);
> +			return -ENOTSUP;
> +		}
>   		if (session_pool_socket[socket_id] == NULL) {
>   			char mp_name[RTE_MEMPOOL_NAMESIZE];
>   			struct rte_mempool *sess_mp;
>   
>   			snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
>   				"sess_mp_%u", socket_id);
> -
>   			sess_mp = rte_mempool_create(mp_name,
> -						NUM_SESSIONS,
> +						sessions_needed,
>   						max_sess_size,
>   						SESS_MEMPOOL_CACHE_SIZE,
>   						0, NULL, NULL, NULL,
  

Patch

diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c
index 4ae14390b..b02d3f597 100644
--- a/app/test-crypto-perf/main.c
+++ b/app/test-crypto-perf/main.c
@@ -21,7 +21,6 @@ 
 #include "cperf_test_verify.h"
 #include "cperf_test_pmd_cyclecount.h"
 
-#define NUM_SESSIONS 2048
 #define SESS_MEMPOOL_CACHE_SIZE 64
 
 const char *cperf_test_type_strs[] = {
@@ -149,15 +148,41 @@  cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs,
 			.nb_descriptors = opts->nb_descriptors
 		};
 
+		uint32_t dev_max_nb_sess = cdev_info.sym.max_nb_sessions;
+		/* Two sessions objects are required for each session
+		 * (one for the header, one for the private data)
+		 */
+		uint32_t sessions_needed = 2 * enabled_cdev_count *
+						opts->nb_qps;
+#ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
+		if (!strcmp((const char *)opts->device_type,
+					"crypto_scheduler")) {
+			uint32_t nb_slaves =
+				rte_cryptodev_scheduler_slaves_get(cdev_id,
+								NULL);
+
+			sessions_needed = 2 * enabled_cdev_count *
+				opts->nb_qps * nb_slaves;
+		}
+#endif
+		/*
+		 * A single session is required per queue pair
+		 * in each device
+		 */
+		if (dev_max_nb_sess < opts->nb_qps) {
+			RTE_LOG(ERR, USER1,
+				"Device does not support at least "
+				"%u sessions\n", opts->nb_qps);
+			return -ENOTSUP;
+		}
 		if (session_pool_socket[socket_id] == NULL) {
 			char mp_name[RTE_MEMPOOL_NAMESIZE];
 			struct rte_mempool *sess_mp;
 
 			snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
 				"sess_mp_%u", socket_id);
-
 			sess_mp = rte_mempool_create(mp_name,
-						NUM_SESSIONS,
+						sessions_needed,
 						max_sess_size,
 						SESS_MEMPOOL_CACHE_SIZE,
 						0, NULL, NULL, NULL,