From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 66F9B1B891 for ; Thu, 10 Jan 2019 15:50:33 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jan 2019 06:50:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,461,1539673200"; d="scan'208";a="126595051" Received: from silpixa00398673.ir.intel.com (HELO silpixa00398673.ger.corp.intel.com) ([10.237.223.54]) by orsmga001.jf.intel.com with ESMTP; 10 Jan 2019 06:50:31 -0800 From: Fan Zhang To: dev@dpdk.org Cc: akhil.goyal@nxp.com, pablo.de.lara.guarch@intel.com, fiona.trahe@intel.com Date: Thu, 10 Jan 2019 14:50:14 +0000 Message-Id: <20190110145022.42883-5-roy.fan.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190110145022.42883-1-roy.fan.zhang@intel.com> References: <20190109225609.20590-1-roy.fan.zhang@intel.com> <20190110145022.42883-1-roy.fan.zhang@intel.com> Subject: [dpdk-dev] [PATCH v5 04/12] net/softnic: use separate session mempools 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: Thu, 10 Jan 2019 14:50:34 -0000 This patch uses the two session mempool approach to softnic PMD. One mempool is for session header objects, and the other is for session private data. Signed-off-by: Fan Zhang Acked-by: Fiona Trahe --- drivers/net/softnic/rte_eth_softnic_cli.c | 52 ++++++++++++++++++++++++- drivers/net/softnic/rte_eth_softnic_cryptodev.c | 50 +++++++++++++++++++++++- drivers/net/softnic/rte_eth_softnic_internals.h | 3 ++ 3 files changed, 102 insertions(+), 3 deletions(-) diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c index 57b623377..76136c2e2 100644 --- a/drivers/net/softnic/rte_eth_softnic_cli.c +++ b/drivers/net/softnic/rte_eth_softnic_cli.c @@ -1092,7 +1092,7 @@ cmd_tap(struct pmd_internals *softnic, /** * cryptodev dev | dev_id - * queue + * queue max_sessions **/ static void @@ -1106,7 +1106,7 @@ cmd_cryptodev(struct pmd_internals *softnic, char *name; memset(¶ms, 0, sizeof(params)); - if (n_tokens != 7) { + if (n_tokens != 9) { snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); return; } @@ -1145,6 +1145,19 @@ cmd_cryptodev(struct pmd_internals *softnic, return; } + if (strcmp(tokens[7], "max_sessions")) { + snprintf(out, out_size, MSG_ARG_NOT_FOUND, + "4"); + return; + } + + if (softnic_parser_read_uint32(¶ms.session_pool_size, tokens[8]) + < 0) { + snprintf(out, out_size, MSG_ARG_INVALID, + "q"); + return; + } + if (softnic_cryptodev_create(softnic, name, ¶ms) == NULL) { snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]); return; @@ -1739,6 +1752,41 @@ cmd_table_action_profile(struct pmd_internals *softnic, t0 += 1; } /* decap */ + if (t0 < n_tokens && (strcmp(tokens[t0], "sym_crypto") == 0)) { + struct softnic_cryptodev *cryptodev; + + if (n_tokens < t0 + 5 || + strcmp(tokens[t0 + 1], "dev") || + strcmp(tokens[t0 + 3], "offset")) { + snprintf(out, out_size, MSG_ARG_MISMATCH, + "table action profile sym_crypto"); + return; + } + + cryptodev = softnic_cryptodev_find(softnic, tokens[t0 + 2]); + if (cryptodev == NULL) { + snprintf(out, out_size, MSG_ARG_INVALID, + "table action profile sym_crypto"); + return; + } + + p.sym_crypto.cryptodev_id = cryptodev->dev_id; + + if (softnic_parser_read_uint32(&p.sym_crypto.op_offset, + tokens[t0 + 4]) != 0) { + snprintf(out, out_size, MSG_ARG_INVALID, + "table action profile sym_crypto"); + return; + } + + p.sym_crypto.mp_create = cryptodev->mp_create; + p.sym_crypto.mp_init = cryptodev->mp_init; + + p.action_mask |= 1LLU << RTE_TABLE_ACTION_SYM_CRYPTO; + + t0 += 5; + } /* sym_crypto */ + if (t0 < n_tokens) { snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); return; diff --git a/drivers/net/softnic/rte_eth_softnic_cryptodev.c b/drivers/net/softnic/rte_eth_softnic_cryptodev.c index f031d8803..18a52ed05 100644 --- a/drivers/net/softnic/rte_eth_softnic_cryptodev.c +++ b/drivers/net/softnic/rte_eth_softnic_cryptodev.c @@ -11,6 +11,8 @@ #include "rte_eth_softnic_internals.h" +#define SOFTNIC_CRYPTO_SESSION_CACHE_SIZE 128 + int softnic_cryptodev_init(struct pmd_internals *p) { @@ -61,13 +63,16 @@ softnic_cryptodev_create(struct pmd_internals *p, struct softnic_cryptodev *cryptodev; uint32_t dev_id, i; uint32_t socket_id; + uint32_t cache_size; + char mp_name[NAME_SIZE]; int status; /* Check input params */ if ((name == NULL) || softnic_cryptodev_find(p, name) || (params->n_queues == 0) || - (params->queue_size == 0)) + (params->queue_size == 0) || + (params->session_pool_size == 0)) return NULL; if (params->dev_name) { @@ -83,6 +88,12 @@ softnic_cryptodev_create(struct pmd_internals *p, dev_id = params->dev_id; } + cache_size = (params->session_pool_size / 2 < + SOFTNIC_CRYPTO_SESSION_CACHE_SIZE) ? + (params->session_pool_size / 2) : + SOFTNIC_CRYPTO_SESSION_CACHE_SIZE; + + socket_id = rte_cryptodev_socket_id(dev_id); rte_cryptodev_info_get(dev_id, &dev_info); @@ -119,7 +130,44 @@ softnic_cryptodev_create(struct pmd_internals *p, cryptodev->dev_id = dev_id; cryptodev->n_queues = params->n_queues; + snprintf(mp_name, NAME_SIZE, "%s_mp%u", name, dev_id); + cryptodev->mp_create = rte_cryptodev_sym_session_pool_create( + mp_name, + params->session_pool_size, + 0, + cache_size, + 0, + socket_id); + if (!cryptodev->mp_create) + goto error_exit; + + snprintf(mp_name, NAME_SIZE, "%s_priv_mp%u", name, dev_id); + cryptodev->mp_init = rte_mempool_create( + mp_name, + params->session_pool_size, + rte_cryptodev_sym_get_private_session_size(dev_id), + cache_size, + 0, + NULL, + NULL, + NULL, + NULL, + socket_id, + 0); + if (!cryptodev->mp_init) + goto error_exit; + TAILQ_INSERT_TAIL(&p->cryptodev_list, cryptodev, node); return cryptodev; + +error_exit: + if (cryptodev->mp_create) + rte_mempool_free(cryptodev->mp_create); + if (cryptodev->mp_init) + rte_mempool_free(cryptodev->mp_init); + + free(cryptodev); + + return NULL; } diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h b/drivers/net/softnic/rte_eth_softnic_internals.h index 31698b9f0..685058be6 100644 --- a/drivers/net/softnic/rte_eth_softnic_internals.h +++ b/drivers/net/softnic/rte_eth_softnic_internals.h @@ -286,6 +286,7 @@ struct softnic_cryptodev_params { uint32_t dev_id; /**< Valid only when *dev_name* is NULL. */ uint32_t n_queues; uint32_t queue_size; + uint32_t session_pool_size; }; struct softnic_cryptodev { @@ -293,6 +294,8 @@ struct softnic_cryptodev { char name[NAME_SIZE]; uint16_t dev_id; uint32_t n_queues; + struct rte_mempool *mp_create; + struct rte_mempool *mp_init; }; TAILQ_HEAD(softnic_cryptodev_list, softnic_cryptodev); -- 2.13.6