[v3,05/16] examples/l2fwd-crypto: limit number of sessions

Message ID 20180628005304.26544-6-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
  Calculate the number of sessions required for the application,
knowing that there is only one session required per device.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 examples/l2fwd-crypto/main.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
  

Comments

Akhil Goyal July 4, 2018, 12:04 p.m. UTC | #1
On 6/28/2018 6:22 AM, Pablo de Lara wrote:

> Calculate the number of sessions required for the application,
> knowing that there is only one session required per device.
>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---
>   examples/l2fwd-crypto/main.c | 19 +++++++++++++++++--
>   1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
> index 4bca87b19..e8384b0c1 100644
> --- a/examples/l2fwd-crypto/main.c
> +++ b/examples/l2fwd-crypto/main.c
> @@ -42,6 +42,9 @@
>   #include <rte_prefetch.h>
>   #include <rte_random.h>
>   #include <rte_hexdump.h>
> +#ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
> +#include <rte_cryptodev_scheduler.h>
> +#endif
>   
>   enum cdev_type {
>   	CDEV_TYPE_ANY,
> @@ -59,7 +62,6 @@ enum cdev_type {
>   #define MAX_AAD_SIZE 65535
>   #define MAX_PKT_BURST 32
>   #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */
> -#define MAX_SESSIONS 32
>   #define SESSION_POOL_CACHE_SIZE 0
>   
>   #define MAXIMUM_IV_LENGTH	16
> @@ -2010,6 +2012,19 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
>   
>   		rte_cryptodev_info_get(cdev_id, &dev_info);
>   
> +		/* 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;

Should we do this in #else of

RTE_LIBRTE_PMD_CRYPTO_SCHEDULER ?

Otherwise, Acked.

> +#ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
> +		if (!strcmp(dev_info.driver_name, "crypto_scheduler")) {
> +			uint32_t nb_slaves =
> +				rte_cryptodev_scheduler_slaves_get(cdev_id,
> +								NULL);
> +
> +			sessions_needed = 2 * enabled_cdev_count * nb_slaves;
> +		}
> +#endif
>   		if (session_pool_socket[socket_id] == NULL) {
>   			char mp_name[RTE_MEMPOOL_NAMESIZE];
>   			struct rte_mempool *sess_mp;
> @@ -2022,7 +2037,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
>   			 * device private data
>   			 */
>   			sess_mp = rte_mempool_create(mp_name,
> -						MAX_SESSIONS * 2,
> +						sessions_needed,
>   						max_sess_sz,
>   						SESSION_POOL_CACHE_SIZE,
>   						0, NULL, NULL, NULL,
>
  

Patch

diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index 4bca87b19..e8384b0c1 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -42,6 +42,9 @@ 
 #include <rte_prefetch.h>
 #include <rte_random.h>
 #include <rte_hexdump.h>
+#ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
+#include <rte_cryptodev_scheduler.h>
+#endif
 
 enum cdev_type {
 	CDEV_TYPE_ANY,
@@ -59,7 +62,6 @@  enum cdev_type {
 #define MAX_AAD_SIZE 65535
 #define MAX_PKT_BURST 32
 #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */
-#define MAX_SESSIONS 32
 #define SESSION_POOL_CACHE_SIZE 0
 
 #define MAXIMUM_IV_LENGTH	16
@@ -2010,6 +2012,19 @@  initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 
 		rte_cryptodev_info_get(cdev_id, &dev_info);
 
+		/* 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;
+#ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
+		if (!strcmp(dev_info.driver_name, "crypto_scheduler")) {
+			uint32_t nb_slaves =
+				rte_cryptodev_scheduler_slaves_get(cdev_id,
+								NULL);
+
+			sessions_needed = 2 * enabled_cdev_count * nb_slaves;
+		}
+#endif
 		if (session_pool_socket[socket_id] == NULL) {
 			char mp_name[RTE_MEMPOOL_NAMESIZE];
 			struct rte_mempool *sess_mp;
@@ -2022,7 +2037,7 @@  initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 			 * device private data
 			 */
 			sess_mp = rte_mempool_create(mp_name,
-						MAX_SESSIONS * 2,
+						sessions_needed,
 						max_sess_sz,
 						SESSION_POOL_CACHE_SIZE,
 						0, NULL, NULL, NULL,