From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 1B4691BF27 for ; Wed, 4 Jul 2018 18:57:48 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jul 2018 09:57:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,306,1526367600"; d="scan'208";a="52630768" Received: from silpixa00399466.ir.intel.com (HELO silpixa00399466.ger.corp.intel.com) ([10.237.223.220]) by fmsmga008.fm.intel.com with ESMTP; 04 Jul 2018 09:57:46 -0700 From: Pablo de Lara To: declan.doherty@intel.com, akhil.goyal@nxp.com, shally.verma@caviumnetworks.com, ravi1.kumar@amd.com, jerin.jacob@caviumnetworks.com, roy.fan.zhang@intel.com, fiona.trahe@intel.com, tdu@semihalf.com, jianjay.zhou@huawei.com Cc: dev@dpdk.org, Pablo de Lara Date: Wed, 4 Jul 2018 09:51:43 +0100 Message-Id: <20180704085154.37828-6-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180704085154.37828-1-pablo.de.lara.guarch@intel.com> References: <20180608220234.10170-1-pablo.de.lara.guarch@intel.com> <20180704085154.37828-1-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v4 05/16] examples/l2fwd-crypto: limit number of sessions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jul 2018 16:57:49 -0000 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 Acked-by: Akhil Goyal --- examples/l2fwd-crypto/main.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index 4bca87b19..db364cf5d 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -42,6 +42,9 @@ #include #include #include +#ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER +#include +#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 @@ -1973,6 +1975,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(); @@ -2010,6 +2013,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; @@ -2022,7 +2040,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, -- 2.14.4