DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Gujjar, Abhinandan S" <abhinandan.gujjar@intel.com>
To: Akhil Goyal <gakhil@marvell.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: Anoob Joseph <anoobj@marvell.com>,
	Jerin Jacob Kollanukkaran <jerinj@marvell.com>,
	"Jayatheerthan, Jay" <jay.jayatheerthan@intel.com>,
	"Vangati, Narender" <narender.vangati@intel.com>,
	Volodymyr Fialko <vfialko@marvell.com>
Subject: RE: [PATCH v3 1/7] cryptodev: add APIs to get/set event metadata
Date: Sun, 1 May 2022 12:24:56 +0000	[thread overview]
Message-ID: <PH0PR11MB583283A11F2EE858A82C8566E8FE9@PH0PR11MB5832.namprd11.prod.outlook.com> (raw)
In-Reply-To: <CO6PR18MB448440E5F468B0E1AE12366CD8FC9@CO6PR18MB4484.namprd18.prod.outlook.com>


> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Sent: Friday, April 29, 2022 5:47 PM
> To: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>; dev@dpdk.org
> Cc: Anoob Joseph <anoobj@marvell.com>; Jerin Jacob Kollanukkaran
> <jerinj@marvell.com>; Jayatheerthan, Jay <jay.jayatheerthan@intel.com>;
> Vangati, Narender <narender.vangati@intel.com>; Volodymyr Fialko
> <vfialko@marvell.com>
> Subject: RE: [PATCH v3 1/7] cryptodev: add APIs to get/set event metadata
> 
> Hi Abhinandan,
> 
> Please see inline.
> > > +
> > > +void *
> > > +rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op) {
> > Null check for op?
> 
> Null check can be added, but this a datapath dpdk internal API.
> We do not normally add checks in datapath.
> If you insist, I can add, but before calling this API, PMD/lib would have already
> checked for null op.
It is ok for get API. It is better to add the check for set API as it exposed to user application.
Currently, the set API is validating dev_id. It is better to add a null check only for set API.
> 
> > > +	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
> > > +			op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
> > > +		return rte_cryptodev_sym_session_get_user_data(op->sym-
> > > >session);
> > > +	else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC &&
> > > +			op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)
> > > +		return op->asym->session->event_mdata;
> > > +	else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS &&
> > > +			op->private_data_offset)
> > > +		return ((uint8_t *)op + op->private_data_offset);
> > > +	else
> > > +		return NULL;
> > > +}
> > > diff --git a/lib/cryptodev/cryptodev_pmd.h
> > > b/lib/cryptodev/cryptodev_pmd.h index 2b1ce2da2d..7969944b66 100644
> > > --- a/lib/cryptodev/cryptodev_pmd.h
> > > +++ b/lib/cryptodev/cryptodev_pmd.h
> > > @@ -398,6 +398,25 @@ typedef int
> > > (*cryptodev_sym_configure_raw_dp_ctx_t)(
> > >  	enum rte_crypto_op_sess_type sess_type,
> > >  	union rte_cryptodev_session_ctx session_ctx, uint8_t is_update);
> > >
> > > +/**
> > > + * Typedef that the driver provided to set event crypto meta data.
> > > + *
> > > + * @param	dev		Crypto device pointer.
> > > + * @param	sess		Crypto or security session.
> > > + * @param	op_type		Operation type.
> > > + * @param	sess_type	Session type.
> > > + * @param	ev_mdata	Pointer to the event crypto meta data
> > > + *				(aka *union rte_event_crypto_metadata*)
> > > + * @return
> > > + *   - On success return 0.
> > > + *   - On failure return negative integer.
> > > + */
> > > +typedef int (*cryptodev_session_event_mdata_set_t)(
> > > +	struct rte_cryptodev *dev, void *sess,
> > > +	enum rte_crypto_op_type op_type,
> > > +	enum rte_crypto_op_sess_type sess_type,
> > > +	void *ev_mdata);
> > > +
> > >  /** Crypto device operations function pointer table */  struct
> > > rte_cryptodev_ops {
> > >  	cryptodev_configure_t dev_configure;	/**< Configure device. */
> > > @@ -442,6 +461,8 @@ struct rte_cryptodev_ops {
> > >  			/**< Initialize raw data path context data. */
> > >  		};
> > >  	};
> > > +	cryptodev_session_event_mdata_set_t session_ev_mdata_set;
> > > +	/**< Set a Crypto or Security session even meta data. */
> > >  };
> > >
> > >
> > > @@ -603,6 +624,19 @@ void
> > >  cryptodev_fp_ops_set(struct rte_crypto_fp_ops *fp_ops,
> > >  		     const struct rte_cryptodev *dev);
> > >
> > > +/**
> > > + * Get session event meta data (aka *union
> > > +rte_event_crypto_metadata*)
> > > + *
> > > + * @param	op            pointer to *rte_crypto_op* structure.
> > > + *
> > > + * @return
> > > + *  - On success, pointer to event crypto metadata
> > > + *  - On failure, a negative value.
> > > + */
> > > +__rte_internal
> > > +void *
> > > +rte_cryptodev_session_event_mdata_get(struct rte_crypto_op *op);
> > > +
> > >  static inline void *
> > >  get_sym_session_private_data(const struct rte_cryptodev_sym_session
> > *sess,
> > >  		uint8_t driver_id) {
> > > @@ -636,6 +670,8 @@ RTE_STD_C11 struct rte_cryptodev_asym_session {
> > >  	/**< Size of private data used when creating mempool */
> > >  	uint16_t user_data_sz;
> > >  	/**< Session user data will be placed after sess_data */
> > > +	void *event_mdata;
> > > +	/**< Event crypto adapter metadata */
> > Add reference to rte_event_crypto_metadata for clarity?
> 
> Ok will add the comment.
> 
> > >  	uint8_t padding[3];
> > >  	uint8_t sess_private_data[0];
> > >  };
> > > diff --git a/lib/cryptodev/rte_cryptodev.c
> > > b/lib/cryptodev/rte_cryptodev.c
> > index
> > > 3500a2d470..a070cb2a00 100644
> > > --- a/lib/cryptodev/rte_cryptodev.c
> > > +++ b/lib/cryptodev/rte_cryptodev.c
> > > @@ -2051,6 +2051,9 @@ rte_cryptodev_asym_session_free(uint8_t
> > > dev_id, void *sess)
> > >
> > >  	dev->dev_ops->asym_session_clear(dev, sess);
> > >
> > > +	if (((struct rte_cryptodev_asym_session *)sess)->event_mdata)
> > > +		rte_free(((struct rte_cryptodev_asym_session *)sess)-
> > > >event_mdata);
> > > +
> > Who allocates memory for event_mdata? If this done by application
> > before calling rte_cryptodev_session_event_mdata_set(), please
> > document it.
> 
> It is same as was done before this patch.
> The rte_cryptodev_session_event_mdata_set is allocating and making the copy
> as it was copied in userdata before. Hence, no update is required.
ok
> 
> > >  	/* Return session to mempool */
> > >  	sess_mp = rte_mempool_from_obj(sess);
> > >  	rte_mempool_put(sess_mp, sess);
> > > @@ -2259,6 +2262,44 @@ rte_cryptodev_configure_raw_dp_ctx(uint8_t
> > > dev_id, uint16_t qp_id,
> > >  			sess_type, session_ctx, is_update);  }
> > >
> > > +int
> > > +rte_cryptodev_session_event_mdata_set(uint8_t dev_id, void *sess,
> > > +	enum rte_crypto_op_type op_type,
> > > +	enum rte_crypto_op_sess_type sess_type,
> > > +	void *ev_mdata,
> > > +	uint16_t size)
> > > +{
> > > +	struct rte_cryptodev *dev;
> > > +
> > > +	if (!rte_cryptodev_is_valid_dev(dev_id))
> > > +		goto skip_pmd_op;
> > > +
> > > +	dev = rte_cryptodev_pmd_get_dev(dev_id);
> > > +	if (dev->dev_ops->session_ev_mdata_set == NULL)
> > > +		goto skip_pmd_op;
> > > +
> > > +	return (*dev->dev_ops->session_ev_mdata_set)(dev, sess, op_type,
> > > +			sess_type, ev_mdata);
> > > +
> > > +skip_pmd_op:
> > > +	if (op_type == RTE_CRYPTO_OP_TYPE_SYMMETRIC)
> > > +		return rte_cryptodev_sym_session_set_user_data(sess,
> > > ev_mdata,
> > > +				size);
> > > +	else if (op_type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
> > > +		struct rte_cryptodev_asym_session *s = sess;
> > Null check for sess?
> 
> Again, it is a datapath, avoided extra checks.
> 
> > > +
> > > +		if (s->event_mdata == NULL) {
> > > +			s->event_mdata = rte_malloc(NULL, size, 0);
> > > +			if (s->event_mdata == NULL)
> > > +				return -ENOMEM;
> > > +		}
> > > +		rte_memcpy(s->event_mdata, ev_mdata, size);
> > > +
> > > +		return 0;
> > > +	} else
> > > +		return -ENOTSUP;
> > > +}


  reply	other threads:[~2022-05-01 12:25 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-25 11:16 [PATCH 0/2] Session crypto event metadata api Volodymyr Fialko
2022-03-25 11:16 ` [PATCH 1/2] security: introduce per session event metadata Volodymyr Fialko
2022-04-04  8:38   ` Gujjar, Abhinandan S
2022-04-04  9:48     ` Akhil Goyal
2022-04-04 10:42       ` Gujjar, Abhinandan S
2022-04-13  7:13         ` Akhil Goyal
2022-04-18 19:36           ` Akhil Goyal
2022-03-25 11:16 ` [PATCH 2/2] crypto/cnxk: support for security session enqueue Volodymyr Fialko
2022-04-18 19:33 ` [PATCH v2 0/7] Add new cryptodev op for event metadata Akhil Goyal
2022-04-18 19:33   ` [PATCH v2 1/7] cryptodev: add APIs to get/set " Akhil Goyal
2022-04-18 19:33   ` [PATCH v2 2/7] crypto/cnxk: add event metadata set operation Akhil Goyal
2022-04-18 19:33   ` [PATCH v2 3/7] crypto/octeontx: use new API for event metadata Akhil Goyal
2022-04-18 19:33   ` [PATCH v2 4/7] test/event: use new API to set event crypto metadata Akhil Goyal
2022-04-18 19:33   ` [PATCH v2 5/7] eventdev: use new API to get " Akhil Goyal
2022-04-18 19:33   ` [PATCH v2 6/7] test/event: add asymmetric cases for crypto adapter Akhil Goyal
2022-04-18 19:33   ` [PATCH v2 7/7] test-eventdev: support asym ops " Akhil Goyal
2022-04-21 14:37   ` [PATCH v3 0/7] Add new cryptodev op for event metadata Akhil Goyal
2022-04-21 14:37     ` [PATCH v3 1/7] cryptodev: add APIs to get/set " Akhil Goyal
2022-04-27 15:38       ` Zhang, Roy Fan
2022-04-28 14:42       ` Gujjar, Abhinandan S
2022-04-29 12:16         ` Akhil Goyal
2022-05-01 12:24           ` Gujjar, Abhinandan S [this message]
2022-05-01 18:37             ` Akhil Goyal
2022-04-21 14:37     ` [PATCH v3 2/7] crypto/cnxk: add event metadata set operation Akhil Goyal
2022-04-27 15:38       ` Zhang, Roy Fan
2022-05-01 13:17       ` Gujjar, Abhinandan S
2022-05-01 18:29         ` Akhil Goyal
2022-04-21 14:37     ` [PATCH v3 3/7] crypto/octeontx: use new API for event metadata Akhil Goyal
2022-04-27 15:38       ` Zhang, Roy Fan
2022-05-01 13:18       ` Gujjar, Abhinandan S
2022-04-21 14:37     ` [PATCH v3 4/7] test/event: use new API to set event crypto metadata Akhil Goyal
2022-04-27 15:39       ` Zhang, Roy Fan
2022-04-28 14:47       ` Gujjar, Abhinandan S
2022-04-21 14:37     ` [PATCH v3 5/7] eventdev: use new API to get " Akhil Goyal
2022-04-27 15:39       ` Zhang, Roy Fan
2022-04-28 15:08       ` Gujjar, Abhinandan S
2022-04-21 14:37     ` [PATCH v3 6/7] test/event: add asymmetric cases for crypto adapter Akhil Goyal
2022-04-27 15:39       ` Zhang, Roy Fan
2022-04-28 15:14       ` Gujjar, Abhinandan S
2022-04-29 12:23         ` Akhil Goyal
2022-05-01 12:45           ` Gujjar, Abhinandan S
2022-05-01 18:36             ` Akhil Goyal
2022-04-21 14:37     ` [PATCH v3 7/7] test-eventdev: support asym ops " Akhil Goyal
2022-04-27 15:40       ` Zhang, Roy Fan
2022-05-01 13:00       ` Gujjar, Abhinandan S
2022-04-27 15:37     ` [PATCH v3 0/7] Add new cryptodev op for event metadata Zhang, Roy Fan
2022-04-28 14:24     ` Gujjar, Abhinandan S
2022-05-01 19:24     ` [PATCH v4 " Akhil Goyal
2022-05-01 19:24       ` [PATCH v4 1/7] cryptodev: add APIs to get/set " Akhil Goyal
2022-05-02  9:01         ` Anoob Joseph
2022-05-02 11:06         ` Gujjar, Abhinandan S
2022-05-01 19:24       ` [PATCH v4 2/7] crypto/cnxk: add event metadata set operation Akhil Goyal
2022-05-02 11:07         ` Gujjar, Abhinandan S
2022-05-01 19:24       ` [PATCH v4 3/7] crypto/octeontx: use new API for event metadata Akhil Goyal
2022-05-01 19:24       ` [PATCH v4 4/7] test/event: use new API to set event crypto metadata Akhil Goyal
2022-05-01 19:24       ` [PATCH v4 5/7] eventdev: use new API to get " Akhil Goyal
2022-05-01 19:24       ` [PATCH v4 6/7] test/event: add asymmetric cases for crypto adapter Akhil Goyal
2022-05-02 11:08         ` Gujjar, Abhinandan S
2022-05-01 19:24       ` [PATCH v4 7/7] test-eventdev: support asym ops " Akhil Goyal
2022-05-02 11:08       ` [PATCH v4 0/7] Add new cryptodev op for event metadata Gujjar, Abhinandan S
2022-05-12 12:45       ` [PATCH v5 " Akhil Goyal
2022-05-12 12:45         ` [PATCH v5 1/7] cryptodev: add APIs to get/set " Akhil Goyal
2022-05-12 12:45         ` [PATCH v5 2/7] crypto/cnxk: add event metadata set operation Akhil Goyal
2022-05-12 12:45         ` [PATCH v5 3/7] crypto/octeontx: use new API for event metadata Akhil Goyal
2022-05-12 12:45         ` [PATCH v5 4/7] test/event: use new API to set event crypto metadata Akhil Goyal
2022-05-12 12:45         ` [PATCH v5 5/7] eventdev: use new API to get " Akhil Goyal
2022-05-12 12:45         ` [PATCH v5 6/7] test/event: add asymmetric cases for crypto adapter Akhil Goyal
2022-05-12 12:45         ` [PATCH v5 7/7] test-eventdev: support asym ops " Akhil Goyal
2022-05-16 18:30         ` [PATCH v5 0/7] Add new cryptodev op for event metadata Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PH0PR11MB583283A11F2EE858A82C8566E8FE9@PH0PR11MB5832.namprd11.prod.outlook.com \
    --to=abhinandan.gujjar@intel.com \
    --cc=anoobj@marvell.com \
    --cc=dev@dpdk.org \
    --cc=gakhil@marvell.com \
    --cc=jay.jayatheerthan@intel.com \
    --cc=jerinj@marvell.com \
    --cc=narender.vangati@intel.com \
    --cc=vfialko@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).