From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f68.google.com (mail-lf0-f68.google.com [209.85.215.68]) by dpdk.org (Postfix) with ESMTP id 0E5941B461 for ; Tue, 10 Jul 2018 12:42:14 +0200 (CEST) Received: by mail-lf0-f68.google.com with SMTP id b22-v6so5433270lfa.3 for ; Tue, 10 Jul 2018 03:42:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=9sp6iAu6ei6l4gJwZahKjdMMVbcDeYz7biGHcSNDSyg=; b=GcDKGBr4ky+51pnr8CegqjgG37bPiE4lsexCeT8Tfv5pcCD+RIaZ97gFVtNUACW7hX b0S3Rh3gdrd21kSGgjN40SQWDflOPBhM86bYSUb4vH7DzNbdTQxV8c2Qk3eK2mgzrc/c dnk5vvfNWxgHdvNjeeuNwZ3SWfqByYS2+8VAU26RMU0nCWL4dJFauhnEHQYSG/vroEam Ijwnk8HmZfubtIJzSPFPpVRpR9SLehRpV/7YVTcFNSsCZwPdeA4oLvrcJfeZWV46djPX kSe0Sc3vyHHlkJ6L19Aoo2lKKs4aalH00q7BlMKxfQvXmjKJkm+CL8KIC+BHQQ5gbD3s RpQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=9sp6iAu6ei6l4gJwZahKjdMMVbcDeYz7biGHcSNDSyg=; b=PkV4l87iFR2CKTcHdcB/GWdnbMtThcVqLivVEFGDic+eYiDoQ1ae16eu/TsA80ri4M M3tTabfpR5xxQHqJmAeeYVkRqo/49UqHmQOHhrddAqKPJu6zX6Yfapl0yhGNNEI/iv6i 1f8enZkWoCxQk9L3b81OM4/0TFl6pOnSo+G0DoRtRAU0aWdrvJE9SawuyrHV+QOLULbb ifgOUuRZXTrs3FGPS8llK6IE3/M2km28GU3byuxw1DllOUM+7eoMdwXMfHaAGUxcqZsv uelwg3aMnbpENKiXlcL770ORhfL8tugJZjkhaSPxaHsb4yP0TU02z7+eto1VJMFrEZgj yNsQ== X-Gm-Message-State: APt69E0n5Wmude4wurO2Pt/xNtEXzLQkW6AmNwQqsxIuPonPrHRQVlpj 73g5Bz80x6+OhjQ+ymzSnycd5w== X-Google-Smtp-Source: AAOMgpfDciMx9oO3FryOPjeYcPYEdPxEbWjn4tVgQdBY+eQUA2DchYYs4UfltSIgBUE043hJYNrWHw== X-Received: by 2002:a19:ca09:: with SMTP id a9-v6mr2383930lfg.142.1531219333645; Tue, 10 Jul 2018 03:42:13 -0700 (PDT) Received: from localhost (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id x21-v6sm4688949lfe.70.2018.07.10.03.42.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jul 2018 03:42:12 -0700 (PDT) Date: Tue, 10 Jul 2018 12:42:12 +0200 From: Tomasz Duszynski To: Pablo de Lara Cc: 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, dev@dpdk.org Message-ID: <20180710104211.GA3496@sh> References: <20180608220234.10170-1-pablo.de.lara.guarch@intel.com> <20180710003623.1463-1-pablo.de.lara.guarch@intel.com> <20180710003623.1463-8-pablo.de.lara.guarch@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20180710003623.1463-8-pablo.de.lara.guarch@intel.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH v6 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: Tue, 10 Jul 2018 10:42:14 -0000 Looks good. Acked-by: Tomasz Duszynski On Tue, Jul 10, 2018 at 01:36:14AM +0100, Pablo de Lara wrote: > 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/r= te_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[] =3D { > + 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 =3D rte_cryptodev_pmd_create(name, &vdev->device, init_params); > + dev =3D rte_cryptodev_pmd_create(name, &vdev->device, > + &init_params->common); > if (dev =3D=3D 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 =3D dev->data->dev_private; > > - internals->max_nb_qpairs =3D init_params->max_nb_queue_pairs; > + internals->max_nb_qpairs =3D init_params->common.max_nb_queue_pairs; > internals->max_nb_sessions =3D 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 =3D (int *) extra_args; > + > + *i =3D 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 =3D extra_args; > + > + if (strlen(value) >=3D 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 =3D NULL; > + int ret =3D 0; > + > + if (params =3D=3D NULL) > + return -EINVAL; > + > + if (input_args) { > + kvlist =3D rte_kvargs_parse(input_args, > + mrvl_pmd_valid_params); > + if (kvlist =3D=3D NULL) > + return -1; > + > + /* Common VDEV parameters */ > + ret =3D 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 =3D rte_kvargs_process(kvlist, > + RTE_CRYPTODEV_PMD_SOCKET_ID_ARG, > + &parse_integer_arg, > + ¶ms->common.socket_id); > + if (ret < 0) > + goto free_kvlist; > + > + ret =3D rte_kvargs_process(kvlist, > + RTE_CRYPTODEV_PMD_NAME_ARG, > + &parse_name_arg, > + ¶ms->common); > + if (ret < 0) > + goto free_kvlist; > + > + ret =3D 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 =3D { }; > + struct mrvl_pmd_init_params init_params =3D { > + .common =3D { > + .name =3D "", > + .private_data_size =3D > + sizeof(struct mrvl_crypto_private), > + .max_nb_queue_pairs =3D > + sam_get_num_inst() * SAM_HW_RING_NUM, > + .socket_id =3D rte_socket_id() > + }, > + .max_nb_sessions =3D MRVL_PMD_DEFAULT_MAX_NB_SESSIONS > + }; > + > const char *name, *args; > int ret; > > @@ -764,13 +878,7 @@ cryptodev_mrvl_crypto_init(struct rte_vdev_device *v= dev) > return -EINVAL; > args =3D rte_vdev_device_args(vdev); > > - init_params.private_data_size =3D sizeof(struct mrvl_crypto_private); > - init_params.max_nb_queue_pairs =3D sam_get_num_inst() * SAM_HW_RING_NUM; > - init_params.max_nb_sessions =3D > - RTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_SESSIONS; > - init_params.socket_id =3D rte_socket_id(); > - > - ret =3D rte_cryptodev_pmd_parse_input_args(&init_params, args); > + ret =3D mrvl_pmd_parse_input_args(&init_params, args); > if (ret) { > RTE_LOG(ERR, PMD, > "Failed to parse initialisation arguments[%s]\n", > -- > 2.14.4 > -- - Tomasz Duszy=C5=84ski