summaryrefslogtreecommitdiff
path: root/examples/l2fwd-crypto
diff options
context:
space:
mode:
authorPablo de Lara <pablo.de.lara.guarch@intel.com>2018-07-05 03:07:54 +0100
committerPablo de Lara <pablo.de.lara.guarch@intel.com>2018-07-11 03:57:20 +0200
commite3bcb99a5e1383076f29568bf8a99ba7732d9bb9 (patch)
treebdaaf671366085b3201bf0337ad8308dcfbfa3a4 /examples/l2fwd-crypto
parent7ac34bce58695f385cdd7d6879f46f8156287ddc (diff)
downloaddpdk-e3bcb99a5e1383076f29568bf8a99ba7732d9bb9.zip
dpdk-e3bcb99a5e1383076f29568bf8a99ba7732d9bb9.tar.gz
dpdk-e3bcb99a5e1383076f29568bf8a99ba7732d9bb9.tar.xz
examples/l2fwd-crypto: limit number of sessions
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> Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
Diffstat (limited to 'examples/l2fwd-crypto')
-rw-r--r--examples/l2fwd-crypto/Makefile6
-rw-r--r--examples/l2fwd-crypto/main.c22
2 files changed, 26 insertions, 2 deletions
diff --git a/examples/l2fwd-crypto/Makefile b/examples/l2fwd-crypto/Makefile
index a67f087..6658fd0 100644
--- a/examples/l2fwd-crypto/Makefile
+++ b/examples/l2fwd-crypto/Makefile
@@ -51,5 +51,11 @@ include $(RTE_SDK)/mk/rte.vars.mk
CFLAGS += -O3
CFLAGS += $(WERROR_FLAGS)
+ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
+ifeq ($(CONFIG_RTE_LIBRTE_PMD_CRYPTO_SCHEDULER),y)
+LDLIBS += -lrte_pmd_crypto_scheduler
+endif
+endif
+
include $(RTE_SDK)/mk/rte.extapp.mk
endif
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index 1b55879..9d6bb78 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
@@ -1972,6 +1974,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
unsigned int cdev_id, cdev_count, enabled_cdev_count = 0;
const struct rte_cryptodev_capabilities *cap;
unsigned int sess_sz, max_sess_sz = 0;
+ uint32_t sessions_needed = 0;
int retval;
cdev_count = rte_cryptodev_count();
@@ -2009,6 +2012,21 @@ 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)
+ */
+ if (!strcmp(dev_info.driver_name, "crypto_scheduler")) {
+#ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
+ uint32_t nb_slaves =
+ rte_cryptodev_scheduler_slaves_get(cdev_id,
+ NULL);
+
+ sessions_needed = 2 * enabled_cdev_count * nb_slaves;
+#endif
+ } else
+ sessions_needed = 2 * enabled_cdev_count;
+
if (session_pool_socket[socket_id] == NULL) {
char mp_name[RTE_MEMPOOL_NAMESIZE];
struct rte_mempool *sess_mp;
@@ -2021,7 +2039,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,