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 798688E65 for ; Thu, 28 Jun 2018 10:59:36 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jun 2018 01:59:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,282,1526367600"; d="scan'208";a="70667027" Received: from silpixa00399466.ir.intel.com (HELO silpixa00399466.ger.corp.intel.com) ([10.237.223.220]) by orsmga002.jf.intel.com with ESMTP; 28 Jun 2018 01:59:17 -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: Thu, 28 Jun 2018 01:52:55 +0100 Message-Id: <20180628005304.26544-8-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180628005304.26544-1-pablo.de.lara.guarch@intel.com> References: <20180608220234.10170-1-pablo.de.lara.guarch@intel.com> <20180628005304.26544-1-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v3 07/16] crypto/mvsam: parse max 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: Thu, 28 Jun 2018 08:59:37 -0000 The maximum number of sessions device argument will be removed, as most PMDs do not have a limitation on this number. Therefore, the MVSAM PMD needs to parse this value internally. Signed-off-by: Pablo de Lara --- drivers/crypto/mvsam/rte_mrvl_pmd.c | 132 ++++++++++++++++++++++++++++++++---- 1 file changed, 120 insertions(+), 12 deletions(-) diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd.c b/drivers/crypto/mvsam/rte_mrvl_pmd.c index 1b6029a56..a7f5389ee 100644 --- a/drivers/crypto/mvsam/rte_mrvl_pmd.c +++ b/drivers/crypto/mvsam/rte_mrvl_pmd.c @@ -16,8 +16,23 @@ #define MRVL_MUSDK_DMA_MEMSIZE 41943040 +#define MRVL_PMD_MAX_NB_SESS_ARG ("max_nb_sessions") +#define MRVL_PMD_DEFAULT_MAX_NB_SESSIONS 2048 + static uint8_t cryptodev_driver_id; +struct mrvl_pmd_init_params { + struct rte_cryptodev_pmd_init_params common; + uint32_t max_nb_sessions; +}; + +const char *mrvl_pmd_valid_params[] = { + RTE_CRYPTODEV_PMD_NAME_ARG, + RTE_CRYPTODEV_PMD_MAX_NB_QP_ARG, + RTE_CRYPTODEV_PMD_SOCKET_ID_ARG, + MRVL_PMD_MAX_NB_SESS_ARG +}; + /** * Flag if particular crypto algorithm is supported by PMD/MUSDK. * @@ -691,14 +706,15 @@ mrvl_crypto_pmd_dequeue_burst(void *queue_pair, static int cryptodev_mrvl_crypto_create(const char *name, struct rte_vdev_device *vdev, - struct rte_cryptodev_pmd_init_params *init_params) + struct mrvl_pmd_init_params *init_params) { struct rte_cryptodev *dev; struct mrvl_crypto_private *internals; struct sam_init_params sam_params; int ret; - dev = rte_cryptodev_pmd_create(name, &vdev->device, init_params); + dev = rte_cryptodev_pmd_create(name, &vdev->device, + &init_params->common); if (dev == NULL) { MRVL_CRYPTO_LOG_ERR("failed to create cryptodev vdev"); goto init_error; @@ -718,7 +734,7 @@ cryptodev_mrvl_crypto_create(const char *name, /* Set vector instructions mode supported */ internals = dev->data->dev_private; - internals->max_nb_qpairs = init_params->max_nb_queue_pairs; + internals->max_nb_qpairs = init_params->common.max_nb_queue_pairs; internals->max_nb_sessions = init_params->max_nb_sessions; /* @@ -740,12 +756,99 @@ cryptodev_mrvl_crypto_create(const char *name, init_error: MRVL_CRYPTO_LOG_ERR( - "driver %s: %s failed", init_params->name, __func__); + "driver %s: %s failed", init_params->common.name, __func__); cryptodev_mrvl_crypto_uninit(vdev); return -EFAULT; } +/** Parse integer from integer argument */ +static int +parse_integer_arg(const char *key __rte_unused, + const char *value, void *extra_args) +{ + int *i = (int *) extra_args; + + *i = atoi(value); + if (*i < 0) { + MRVL_CRYPTO_LOG_ERR("Argument has to be positive.\n"); + return -EINVAL; + } + + return 0; +} + +/** Parse name */ +static int +parse_name_arg(const char *key __rte_unused, + const char *value, void *extra_args) +{ + struct rte_cryptodev_pmd_init_params *params = extra_args; + + if (strlen(value) >= RTE_CRYPTODEV_NAME_MAX_LEN - 1) { + MRVL_CRYPTO_LOG_ERR("Invalid name %s, should be less than " + "%u bytes.\n", value, + RTE_CRYPTODEV_NAME_MAX_LEN - 1); + return -EINVAL; + } + + strncpy(params->name, value, RTE_CRYPTODEV_NAME_MAX_LEN); + + return 0; +} + +static int +mrvl_pmd_parse_input_args(struct mrvl_pmd_init_params *params, + const char *input_args) +{ + struct rte_kvargs *kvlist = NULL; + int ret = 0; + + if (params == NULL) + return -EINVAL; + + if (input_args) { + kvlist = rte_kvargs_parse(input_args, + mrvl_pmd_valid_params); + if (kvlist == NULL) + return -1; + + /* Common VDEV parameters */ + ret = rte_kvargs_process(kvlist, + RTE_CRYPTODEV_PMD_MAX_NB_QP_ARG, + &parse_integer_arg, + ¶ms->common.max_nb_queue_pairs); + if (ret < 0) + goto free_kvlist; + + ret = rte_kvargs_process(kvlist, + RTE_CRYPTODEV_PMD_SOCKET_ID_ARG, + &parse_integer_arg, + ¶ms->common.socket_id); + if (ret < 0) + goto free_kvlist; + + ret = rte_kvargs_process(kvlist, + RTE_CRYPTODEV_PMD_NAME_ARG, + &parse_name_arg, + ¶ms->common); + if (ret < 0) + goto free_kvlist; + + ret = rte_kvargs_process(kvlist, + MRVL_PMD_MAX_NB_SESS_ARG, + &parse_integer_arg, + params); + if (ret < 0) + goto free_kvlist; + + } + +free_kvlist: + rte_kvargs_free(kvlist); + return ret; +} + /** * Initialize the crypto device. * @@ -755,7 +858,18 @@ cryptodev_mrvl_crypto_create(const char *name, static int cryptodev_mrvl_crypto_init(struct rte_vdev_device *vdev) { - struct rte_cryptodev_pmd_init_params init_params = { }; + struct mrvl_pmd_init_params init_params = { + .common = { + .name = "", + .private_data_size = + sizeof(struct mrvl_crypto_private), + .max_nb_queue_pairs = + sam_get_num_inst() * SAM_HW_RING_NUM, + .socket_id = rte_socket_id() + }, + .max_nb_sessions = MRVL_PMD_DEFAULT_MAX_NB_SESSIONS + }; + const char *name, *args; int ret; @@ -764,13 +878,7 @@ cryptodev_mrvl_crypto_init(struct rte_vdev_device *vdev) return -EINVAL; args = rte_vdev_device_args(vdev); - init_params.private_data_size = sizeof(struct mrvl_crypto_private); - init_params.max_nb_queue_pairs = sam_get_num_inst() * SAM_HW_RING_NUM; - init_params.max_nb_sessions = - RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_SESSIONS; - init_params.socket_id = rte_socket_id(); - - ret = rte_cryptodev_pmd_parse_input_args(&init_params, args); + ret = mrvl_pmd_parse_input_args(&init_params, args); if (ret) { RTE_LOG(ERR, PMD, "Failed to parse initialisation arguments[%s]\n", -- 2.14.4