diff mbox

[RFCv2,API-NEXT] Adding API for Multi crypto operation support.

Message ID 1465405715-4764-1-git-send-email-nikhil.agarwal@linaro.org
State New
Headers show

Commit Message

Nikhil Agarwal June 8, 2016, 5:08 p.m. UTC
Signed-off-by: Nikhil Agarwal <nikhil.agarwal@linaro.org>
---
 include/odp/api/spec/crypto.h | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

Comments

Balasubramanian Manoharan June 9, 2016, 11:20 a.m. UTC | #1
Regards,
Bala


On 8 June 2016 at 22:38, Nikhil Agarwal <nikhil.agarwal@linaro.org> wrote:
> Signed-off-by: Nikhil Agarwal <nikhil.agarwal@linaro.org>
> ---
>  include/odp/api/spec/crypto.h | 29 +++++++++++++++++++++++++++--
>  1 file changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h
> index d8123e9..7b4424d 100644
> --- a/include/odp/api/spec/crypto.h
> +++ b/include/odp/api/spec/crypto.h
> @@ -214,7 +214,6 @@ typedef struct odp_crypto_session_params {
>   * @todo Clarify who zero's ICV and how this relates to "hash_result_offset"
>   */
>  typedef struct odp_crypto_op_params {
> -       odp_crypto_session_t session;   /**< Session handle from creation */
>         void *ctx;                      /**< User context */
>         odp_packet_t pkt;               /**< Input packet buffer */
>         odp_packet_t out_pkt;           /**< Output packet buffer */
> @@ -406,6 +405,7 @@ void odp_crypto_compl_free(odp_crypto_compl_t completion_event);
>   * If "posted" returns TRUE the result will be delivered via the completion
>   * queue specified when the session was created.
>   *
> + * @param session           Session handle
>   * @param params            Operation parameters
>   * @param posted            Pointer to return posted, TRUE for async operation
>   * @param result            Results of operation (when posted returns FALSE)
> @@ -413,10 +413,35 @@ void odp_crypto_compl_free(odp_crypto_compl_t completion_event);
>   * @retval 0 on success
>   * @retval <0 on failure
>   */
> -int odp_crypto_operation(odp_crypto_op_params_t *params,
> +int odp_crypto_operation(odp_crypto_session_t session,
> +                        odp_crypto_op_params_t *params,
>                          odp_bool_t *posted,
>                          odp_crypto_op_result_t *result);
>
> +
> +/**
> + * Crypto packet burst operation
> + *
> + * Performs the cryptographic operations specified during session creation
> + * on the list of packets. Burst operation can only be performed asynchronously,
> + * and the result will be delivered via the completion queue specified when the
> + * session was created.
> + *
> + * @param session           Session handle
> + * @param params            Array of Operation parameters
> + * @param posted            Pointer to return posted, TRUE for async operation
> + * @param result            Results of operation (when posted returns FALSE)
> + * @param num               Number of operations reuested
> + *
> + * @return Number of operations actually enqueued/completed (0 ... num)
> + * @retval <0 on failure
> + */
> +int odp_crypto_operation_multi(odp_crypto_session_t session,
> +                              odp_crypto_op_params_t *params[],
> +                              odp_bool_t *posted,
> +                              odp_crypto_op_result_t *result[],
> +                              int num);

This function will have a performance issue with synchronous crypto
operations since in sync crypto odp_crypto_operation_multi() is a
blocking call and the call will have to be blocked for all the packets
to complete before posting the result. Also the crypto operations were
kept agnostic of the internal behaviour of the implementation so help
in portability of the applications.

Regards,
Bala
> +
>  /**
>   * Crypto per packet operation query result from completion event
>   *
> --
> 2.8.2
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
Nikhil Agarwal June 10, 2016, 9:30 a.m. UTC | #2
On 9 June 2016 at 16:50, Bala Manoharan <bala.manoharan@linaro.org> wrote:

> Regards,
> Bala
>
>
> On 8 June 2016 at 22:38, Nikhil Agarwal <nikhil.agarwal@linaro.org> wrote:
> > Signed-off-by: Nikhil Agarwal <nikhil.agarwal@linaro.org>
> > ---
> >  include/odp/api/spec/crypto.h | 29 +++++++++++++++++++++++++++--
> >  1 file changed, 27 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/odp/api/spec/crypto.h
> b/include/odp/api/spec/crypto.h
> > index d8123e9..7b4424d 100644
> > --- a/include/odp/api/spec/crypto.h
> > +++ b/include/odp/api/spec/crypto.h
> > @@ -214,7 +214,6 @@ typedef struct odp_crypto_session_params {
> >   * @todo Clarify who zero's ICV and how this relates to
> "hash_result_offset"
> >   */
> >  typedef struct odp_crypto_op_params {
> > -       odp_crypto_session_t session;   /**< Session handle from
> creation */
> >         void *ctx;                      /**< User context */
> >         odp_packet_t pkt;               /**< Input packet buffer */
> >         odp_packet_t out_pkt;           /**< Output packet buffer */
> > @@ -406,6 +405,7 @@ void odp_crypto_compl_free(odp_crypto_compl_t
> completion_event);
> >   * If "posted" returns TRUE the result will be delivered via the
> completion
> >   * queue specified when the session was created.
> >   *
> > + * @param session           Session handle
> >   * @param params            Operation parameters
> >   * @param posted            Pointer to return posted, TRUE for async
> operation
> >   * @param result            Results of operation (when posted returns
> FALSE)
> > @@ -413,10 +413,35 @@ void odp_crypto_compl_free(odp_crypto_compl_t
> completion_event);
> >   * @retval 0 on success
> >   * @retval <0 on failure
> >   */
> > -int odp_crypto_operation(odp_crypto_op_params_t *params,
> > +int odp_crypto_operation(odp_crypto_session_t session,
> > +                        odp_crypto_op_params_t *params,
> >                          odp_bool_t *posted,
> >                          odp_crypto_op_result_t *result);
> >
> > +
> > +/**
> > + * Crypto packet burst operation
> > + *
> > + * Performs the cryptographic operations specified during session
> creation
> > + * on the list of packets. Burst operation can only be performed
> asynchronously,
> > + * and the result will be delivered via the completion queue specified
> when the
> > + * session was created.
> > + *
> > + * @param session           Session handle
> > + * @param params            Array of Operation parameters
> > + * @param posted            Pointer to return posted, TRUE for async
> operation
> > + * @param result            Results of operation (when posted returns
> FALSE)
> > + * @param num               Number of operations reuested
> > + *
> > + * @return Number of operations actually enqueued/completed (0 ... num)
> > + * @retval <0 on failure
> > + */
> > +int odp_crypto_operation_multi(odp_crypto_session_t session,
> > +                              odp_crypto_op_params_t *params[],
> > +                              odp_bool_t *posted,
> > +                              odp_crypto_op_result_t *result[],
> > +                              int num);
>
> This function will have a performance issue with synchronous crypto
> operations since in sync crypto odp_crypto_operation_multi() is a
> blocking call and the call will have to be blocked for all the packets
> to complete before posting the result. Also the crypto operations were
> kept agnostic of the internal behaviour of the implementation so help
> in portability of the applications.
>

This API will work with both synchronous and asynchronous modes. There may
be different recommendations from different implementations for
performance. All APIs may not perform equally on all implementations.
Moreover there will not be much difference in performance of this API
compared to calling odp_crypto_operation multiple times in a implementation
like linux generic.

>
> Regards,
> Bala
> > +
> >  /**
> >   * Crypto per packet operation query result from completion event
> >   *
> > --
> > 2.8.2
> >
> > _______________________________________________
> > lng-odp mailing list
> > lng-odp@lists.linaro.org
> > https://lists.linaro.org/mailman/listinfo/lng-odp
>
Balasubramanian Manoharan June 10, 2016, 11 a.m. UTC | #3
On 10 June 2016 at 15:00, Nikhil Agarwal <nikhil.agarwal@linaro.org> wrote:
>
>
> On 9 June 2016 at 16:50, Bala Manoharan <bala.manoharan@linaro.org> wrote:
>>
>> Regards,
>> Bala
>>
>>
>> On 8 June 2016 at 22:38, Nikhil Agarwal <nikhil.agarwal@linaro.org> wrote:
>> > Signed-off-by: Nikhil Agarwal <nikhil.agarwal@linaro.org>
>> > ---
>> >  include/odp/api/spec/crypto.h | 29 +++++++++++++++++++++++++++--
>> >  1 file changed, 27 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/include/odp/api/spec/crypto.h
>> > b/include/odp/api/spec/crypto.h
>> > index d8123e9..7b4424d 100644
>> > --- a/include/odp/api/spec/crypto.h
>> > +++ b/include/odp/api/spec/crypto.h
>> > @@ -214,7 +214,6 @@ typedef struct odp_crypto_session_params {
>> >   * @todo Clarify who zero's ICV and how this relates to
>> > "hash_result_offset"
>> >   */
>> >  typedef struct odp_crypto_op_params {
>> > -       odp_crypto_session_t session;   /**< Session handle from
>> > creation */
>> >         void *ctx;                      /**< User context */
>> >         odp_packet_t pkt;               /**< Input packet buffer */
>> >         odp_packet_t out_pkt;           /**< Output packet buffer */
>> > @@ -406,6 +405,7 @@ void odp_crypto_compl_free(odp_crypto_compl_t
>> > completion_event);
>> >   * If "posted" returns TRUE the result will be delivered via the
>> > completion
>> >   * queue specified when the session was created.
>> >   *
>> > + * @param session           Session handle
>> >   * @param params            Operation parameters
>> >   * @param posted            Pointer to return posted, TRUE for async
>> > operation
>> >   * @param result            Results of operation (when posted returns
>> > FALSE)
>> > @@ -413,10 +413,35 @@ void odp_crypto_compl_free(odp_crypto_compl_t
>> > completion_event);
>> >   * @retval 0 on success
>> >   * @retval <0 on failure
>> >   */
>> > -int odp_crypto_operation(odp_crypto_op_params_t *params,
>> > +int odp_crypto_operation(odp_crypto_session_t session,
>> > +                        odp_crypto_op_params_t *params,
>> >                          odp_bool_t *posted,
>> >                          odp_crypto_op_result_t *result);
>> >
>> > +
>> > +/**
>> > + * Crypto packet burst operation
>> > + *
>> > + * Performs the cryptographic operations specified during session
>> > creation
>> > + * on the list of packets. Burst operation can only be performed
>> > asynchronously,
>> > + * and the result will be delivered via the completion queue specified
>> > when the
>> > + * session was created.
>> > + *
>> > + * @param session           Session handle
>> > + * @param params            Array of Operation parameters
>> > + * @param posted            Pointer to return posted, TRUE for async
>> > operation
>> > + * @param result            Results of operation (when posted returns
>> > FALSE)
>> > + * @param num               Number of operations reuested
>> > + *
>> > + * @return Number of operations actually enqueued/completed (0 ... num)
>> > + * @retval <0 on failure
>> > + */
>> > +int odp_crypto_operation_multi(odp_crypto_session_t session,
>> > +                              odp_crypto_op_params_t *params[],
>> > +                              odp_bool_t *posted,
>> > +                              odp_crypto_op_result_t *result[],
>> > +                              int num);
>>
>> This function will have a performance issue with synchronous crypto
>> operations since in sync crypto odp_crypto_operation_multi() is a
>> blocking call and the call will have to be blocked for all the packets
>> to complete before posting the result. Also the crypto operations were
>> kept agnostic of the internal behaviour of the implementation so help
>> in portability of the applications.
>
>
> This API will work with both synchronous and asynchronous modes. There may
> be different recommendations from different implementations for performance.
> All APIs may not perform equally on all implementations. Moreover there will
> not be much difference in performance of this API compared to calling
> odp_crypto_operation multiple times in a implementation like linux generic.

Linux-generic is not a performance target. My concern is when this
proposed API is run on a target which only supports synchronous crypto
operations, the sync crypto will be a blocking call and this API will
have a performance impact since as per this proposal the crypto
operation result of any single packet can be updated only after
completion of the entire set of packets sent in this call.

Regards,
Bala
>>
>>
>> Regards,
>> Bala
>> > +
>> >  /**
>> >   * Crypto per packet operation query result from completion event
>> >   *
>> > --
>> > 2.8.2
>> >
>> > _______________________________________________
>> > lng-odp mailing list
>> > lng-odp@lists.linaro.org
>> > https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
Balasubramanian Manoharan June 10, 2016, 12:11 p.m. UTC | #4
Regards,
Bala


On 10 June 2016 at 16:37, Nikhil Agarwal <nikhil.agarwal@nxp.com> wrote:
>
>
> -----Original Message-----
> From: lng-odp [mailto:lng-odp-bounces@lists.linaro.org] On Behalf Of Bala Manoharan
> Sent: Friday, June 10, 2016 4:30 PM
> To: Nikhil Agarwal <nikhil.agarwal@linaro.org>
> Cc: LNG ODP Mailman List <lng-odp@lists.linaro.org>
> Subject: Re: [lng-odp] [RFCv2 API-NEXT] Adding API for Multi crypto operation support.
>
> On 10 June 2016 at 15:00, Nikhil Agarwal <nikhil.agarwal@linaro.org> wrote:
>>
>>
>> On 9 June 2016 at 16:50, Bala Manoharan <bala.manoharan@linaro.org> wrote:
>>>
>>> Regards,
>>> Bala
>>>
>>>
>>> On 8 June 2016 at 22:38, Nikhil Agarwal <nikhil.agarwal@linaro.org> wrote:
>>> > Signed-off-by: Nikhil Agarwal <nikhil.agarwal@linaro.org>
>>> > ---
>>> >  include/odp/api/spec/crypto.h | 29 +++++++++++++++++++++++++++--
>>> >  1 file changed, 27 insertions(+), 2 deletions(-)
>>> >
>>> > diff --git a/include/odp/api/spec/crypto.h
>>> > b/include/odp/api/spec/crypto.h index d8123e9..7b4424d 100644
>>> > --- a/include/odp/api/spec/crypto.h
>>> > +++ b/include/odp/api/spec/crypto.h
>>> > @@ -214,7 +214,6 @@ typedef struct odp_crypto_session_params {
>>> >   * @todo Clarify who zero's ICV and how this relates to
>>> > "hash_result_offset"
>>> >   */
>>> >  typedef struct odp_crypto_op_params {
>>> > -       odp_crypto_session_t session;   /**< Session handle from
>>> > creation */
>>> >         void *ctx;                      /**< User context */
>>> >         odp_packet_t pkt;               /**< Input packet buffer */
>>> >         odp_packet_t out_pkt;           /**< Output packet buffer */
>>> > @@ -406,6 +405,7 @@ void odp_crypto_compl_free(odp_crypto_compl_t
>>> > completion_event);
>>> >   * If "posted" returns TRUE the result will be delivered via the
>>> > completion
>>> >   * queue specified when the session was created.
>>> >   *
>>> > + * @param session           Session handle
>>> >   * @param params            Operation parameters
>>> >   * @param posted            Pointer to return posted, TRUE for async
>>> > operation
>>> >   * @param result            Results of operation (when posted returns
>>> > FALSE)
>>> > @@ -413,10 +413,35 @@ void odp_crypto_compl_free(odp_crypto_compl_t
>>> > completion_event);
>>> >   * @retval 0 on success
>>> >   * @retval <0 on failure
>>> >   */
>>> > -int odp_crypto_operation(odp_crypto_op_params_t *params,
>>> > +int odp_crypto_operation(odp_crypto_session_t session,
>>> > +                        odp_crypto_op_params_t *params,
>>> >                          odp_bool_t *posted,
>>> >                          odp_crypto_op_result_t *result);
>>> >
>>> > +
>>> > +/**
>>> > + * Crypto packet burst operation
>>> > + *
>>> > + * Performs the cryptographic operations specified during session
>>> > creation
>>> > + * on the list of packets. Burst operation can only be performed
>>> > asynchronously,
>>> > + * and the result will be delivered via the completion queue
>>> > + specified
>>> > when the
>>> > + * session was created.
>>> > + *
>>> > + * @param session           Session handle
>>> > + * @param params            Array of Operation parameters
>>> > + * @param posted            Pointer to return posted, TRUE for async
>>> > operation
>>> > + * @param result            Results of operation (when posted returns
>>> > FALSE)
>>> > + * @param num               Number of operations reuested
>>> > + *
>>> > + * @return Number of operations actually enqueued/completed (0 ...
>>> > +num)
>>> > + * @retval <0 on failure
>>> > + */
>>> > +int odp_crypto_operation_multi(odp_crypto_session_t session,
>>> > +                              odp_crypto_op_params_t *params[],
>>> > +                              odp_bool_t *posted,
>>> > +                              odp_crypto_op_result_t *result[],
>>> > +                              int num);
>>>
>>> This function will have a performance issue with synchronous crypto
>>> operations since in sync crypto odp_crypto_operation_multi() is a
>>> blocking call and the call will have to be blocked for all the
>>> packets to complete before posting the result. Also the crypto
>>> operations were kept agnostic of the internal behaviour of the
>>> implementation so help in portability of the applications.
>>
>>
>> This API will work with both synchronous and asynchronous modes. There
>> may be different recommendations from different implementations for performance.
>> All APIs may not perform equally on all implementations. Moreover
>> there will not be much difference in performance of this API compared
>> to calling odp_crypto_operation multiple times in a implementation like linux generic.
>
> Linux-generic is not a performance target. My concern is when this proposed API is run on a target which only supports synchronous crypto operations, the sync crypto will be a blocking call and this API will have a performance impact since as per this proposal the crypto operation result of any single packet can be updated only after completion of the entire set of packets sent in this call.
>
> Yes it will updated after batch operation is complete. If application wants individual packet results then why it would call batch operation API?

Precisely the point. This API is only favourable for a particular type
of crypto operations and will have devastating effect on other
platforms which do not have async crypto. Having different APIs for
different crypto operations will be very difficult to incorporate in
the application code since the design of the application code calling
thread has to change as in sync the result is returned immediately
whereas in async the result is enqueued to output queue.

Regards,
Bala
>
> Regards,
> Bala
>>>
>>>
>>> Regards,
>>> Bala
>>> > +
>>> >  /**
>>> >   * Crypto per packet operation query result from completion event
>>> >   *
>>> > --
>>> > 2.8.2
>>> >
>>> > _______________________________________________
>>> > lng-odp mailing list
>>> > lng-odp@lists.linaro.org
>>> > https://lists.linaro.org/mailman/listinfo/lng-odp
>>
>>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
diff mbox

Patch

diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h
index d8123e9..7b4424d 100644
--- a/include/odp/api/spec/crypto.h
+++ b/include/odp/api/spec/crypto.h
@@ -214,7 +214,6 @@  typedef struct odp_crypto_session_params {
  * @todo Clarify who zero's ICV and how this relates to "hash_result_offset"
  */
 typedef struct odp_crypto_op_params {
-	odp_crypto_session_t session;   /**< Session handle from creation */
 	void *ctx;                      /**< User context */
 	odp_packet_t pkt;               /**< Input packet buffer */
 	odp_packet_t out_pkt;           /**< Output packet buffer */
@@ -406,6 +405,7 @@  void odp_crypto_compl_free(odp_crypto_compl_t completion_event);
  * If "posted" returns TRUE the result will be delivered via the completion
  * queue specified when the session was created.
  *
+ * @param session           Session handle
  * @param params            Operation parameters
  * @param posted            Pointer to return posted, TRUE for async operation
  * @param result            Results of operation (when posted returns FALSE)
@@ -413,10 +413,35 @@  void odp_crypto_compl_free(odp_crypto_compl_t completion_event);
  * @retval 0 on success
  * @retval <0 on failure
  */
-int odp_crypto_operation(odp_crypto_op_params_t *params,
+int odp_crypto_operation(odp_crypto_session_t session,
+			 odp_crypto_op_params_t *params,
 			 odp_bool_t *posted,
 			 odp_crypto_op_result_t *result);
 
+
+/**
+ * Crypto packet burst operation
+ *
+ * Performs the cryptographic operations specified during session creation
+ * on the list of packets. Burst operation can only be performed asynchronously,
+ * and the result will be delivered via the completion queue specified when the
+ * session was created.
+ *
+ * @param session           Session handle
+ * @param params            Array of Operation parameters
+ * @param posted            Pointer to return posted, TRUE for async operation
+ * @param result            Results of operation (when posted returns FALSE)
+ * @param num               Number of operations reuested
+ *
+ * @return Number of operations actually enqueued/completed (0 ... num)
+ * @retval <0 on failure
+ */
+int odp_crypto_operation_multi(odp_crypto_session_t session,
+			       odp_crypto_op_params_t *params[],
+			       odp_bool_t *posted,
+			       odp_crypto_op_result_t *result[],
+			       int num);
+
 /**
  * Crypto per packet operation query result from completion event
  *