[v1] eventdev/crypto: add memzone lookup

Message ID 20221018093926.562384-1-ganapati.kundapura@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series [v1] eventdev/crypto: add memzone lookup |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Ganapati Kundapura Oct. 18, 2022, 9:39 a.m. UTC
  Secondary process is not able to call the crypto adapter
api's stats get/reset as crypto adapter memzone memory is not accessible by
secondary process.

Added memzone lookup so that secondary process can call the
crypto adapter api's(stats_get etc)

Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
  

Comments

Jerin Jacob Oct. 19, 2022, 1:43 p.m. UTC | #1
On Tue, Oct 18, 2022 at 3:09 PM Ganapati Kundapura
<ganapati.kundapura@intel.com> wrote:
>
> Secondary process is not able to call the crypto adapter
> api's stats get/reset as crypto adapter memzone memory is not accessible by
> secondary process.
>
> Added memzone lookup so that secondary process can call the
> crypto adapter api's(stats_get etc)
>
> Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>

@Gujjar, Abhinandan S  Does this patch need to be part of rc2? If so,
please review ASAP. I will complete the rc2 PR by tomorrow.


>
> diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c
> index a11cbcf..7c9901c 100644
> --- a/lib/eventdev/rte_event_crypto_adapter.c
> +++ b/lib/eventdev/rte_event_crypto_adapter.c
> @@ -33,6 +33,8 @@
>   */
>  #define CRYPTO_ENQ_FLUSH_THRESHOLD 1024
>
> +#define ECA_ADAPTER_ARRAY "crypto_adapter_array"
> +
>  struct crypto_ops_circular_buffer {
>         /* index of head element in circular buffer */
>         uint16_t head;
> @@ -138,7 +140,6 @@ eca_valid_id(uint8_t id)
>  static int
>  eca_init(void)
>  {
> -       const char *name = "crypto_adapter_array";
>         const struct rte_memzone *mz;
>         unsigned int sz;
>
> @@ -146,9 +147,10 @@ eca_init(void)
>             RTE_EVENT_CRYPTO_ADAPTER_MAX_INSTANCE;
>         sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
>
> -       mz = rte_memzone_lookup(name);
> +       mz = rte_memzone_lookup(ECA_ADAPTER_ARRAY);
>         if (mz == NULL) {
> -               mz = rte_memzone_reserve_aligned(name, sz, rte_socket_id(), 0,
> +               mz = rte_memzone_reserve_aligned(ECA_ADAPTER_ARRAY, sz,
> +                                                rte_socket_id(), 0,
>                                                  RTE_CACHE_LINE_SIZE);
>                 if (mz == NULL) {
>                         RTE_EDEV_LOG_ERR("failed to reserve memzone err = %"
> @@ -161,6 +163,22 @@ eca_init(void)
>         return 0;
>  }
>
> +static int
> +eca_memzone_lookup(void)
> +{
> +       const struct rte_memzone *mz;
> +
> +       if (event_crypto_adapter == NULL) {
> +               mz = rte_memzone_lookup(ECA_ADAPTER_ARRAY);
> +               if (mz == NULL)
> +                       return -ENOMEM;
> +
> +               event_crypto_adapter = mz->addr;
> +       }
> +
> +       return 0;
> +}
> +
>  static inline bool
>  eca_circular_buffer_batch_ready(struct crypto_ops_circular_buffer *bufp)
>  {
> @@ -1234,6 +1252,9 @@ rte_event_crypto_adapter_stats_get(uint8_t id,
>         uint32_t i;
>         int ret;
>
> +       if (eca_memzone_lookup())
> +               return -ENOMEM;
> +
>         EVENT_CRYPTO_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
>
>         adapter = eca_id_to_adapter(id);
> @@ -1275,6 +1296,9 @@ rte_event_crypto_adapter_stats_reset(uint8_t id)
>         struct rte_eventdev *dev;
>         uint32_t i;
>
> +       if (eca_memzone_lookup())
> +               return -ENOMEM;
> +
>         EVENT_CRYPTO_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
>
>         adapter = eca_id_to_adapter(id);
> --
> 2.6.4
>
  
Gujjar, Abhinandan S Oct. 19, 2022, 2:04 p.m. UTC | #2
> -----Original Message-----
> From: Jerin Jacob <jerinjacobk@gmail.com>
> Sent: Wednesday, October 19, 2022 7:13 PM
> To: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>; dev@dpdk.org;
> jerinj@marvell.com; Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>
> Subject: Re: [PATCH v1] eventdev/crypto: add memzone lookup
> 
> On Tue, Oct 18, 2022 at 3:09 PM Ganapati Kundapura
> <ganapati.kundapura@intel.com> wrote:
> >
> > Secondary process is not able to call the crypto adapter api's stats
> > get/reset as crypto adapter memzone memory is not accessible by
> > secondary process.
> >
> > Added memzone lookup so that secondary process can call the crypto
> > adapter api's(stats_get etc)
> >
> > Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> 
> @Gujjar, Abhinandan S  Does this patch need to be part of rc2? If so, please
> review ASAP. I will complete the rc2 PR by tomorrow.
Hi Jerin,

I have already reviewed it internally. This can go to rc2. Thanks!

Acked-by: Abhinandan Gujjar <abhinandan.gujjar@intel.com>

> 
> 
> >
> > diff --git a/lib/eventdev/rte_event_crypto_adapter.c
> > b/lib/eventdev/rte_event_crypto_adapter.c
> > index a11cbcf..7c9901c 100644
> > --- a/lib/eventdev/rte_event_crypto_adapter.c
> > +++ b/lib/eventdev/rte_event_crypto_adapter.c
> > @@ -33,6 +33,8 @@
> >   */
> >  #define CRYPTO_ENQ_FLUSH_THRESHOLD 1024
> >
> > +#define ECA_ADAPTER_ARRAY "crypto_adapter_array"
> > +
> >  struct crypto_ops_circular_buffer {
> >         /* index of head element in circular buffer */
> >         uint16_t head;
> > @@ -138,7 +140,6 @@ eca_valid_id(uint8_t id)  static int
> >  eca_init(void)
> >  {
> > -       const char *name = "crypto_adapter_array";
> >         const struct rte_memzone *mz;
> >         unsigned int sz;
> >
> > @@ -146,9 +147,10 @@ eca_init(void)
> >             RTE_EVENT_CRYPTO_ADAPTER_MAX_INSTANCE;
> >         sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
> >
> > -       mz = rte_memzone_lookup(name);
> > +       mz = rte_memzone_lookup(ECA_ADAPTER_ARRAY);
> >         if (mz == NULL) {
> > -               mz = rte_memzone_reserve_aligned(name, sz, rte_socket_id(), 0,
> > +               mz = rte_memzone_reserve_aligned(ECA_ADAPTER_ARRAY, sz,
> > +                                                rte_socket_id(), 0,
> >                                                  RTE_CACHE_LINE_SIZE);
> >                 if (mz == NULL) {
> >                         RTE_EDEV_LOG_ERR("failed to reserve memzone err = %"
> > @@ -161,6 +163,22 @@ eca_init(void)
> >         return 0;
> >  }
> >
> > +static int
> > +eca_memzone_lookup(void)
> > +{
> > +       const struct rte_memzone *mz;
> > +
> > +       if (event_crypto_adapter == NULL) {
> > +               mz = rte_memzone_lookup(ECA_ADAPTER_ARRAY);
> > +               if (mz == NULL)
> > +                       return -ENOMEM;
> > +
> > +               event_crypto_adapter = mz->addr;
> > +       }
> > +
> > +       return 0;
> > +}
> > +
> >  static inline bool
> >  eca_circular_buffer_batch_ready(struct crypto_ops_circular_buffer
> > *bufp)  { @@ -1234,6 +1252,9 @@
> > rte_event_crypto_adapter_stats_get(uint8_t id,
> >         uint32_t i;
> >         int ret;
> >
> > +       if (eca_memzone_lookup())
> > +               return -ENOMEM;
> > +
> >         EVENT_CRYPTO_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
> >
> >         adapter = eca_id_to_adapter(id); @@ -1275,6 +1296,9 @@
> > rte_event_crypto_adapter_stats_reset(uint8_t id)
> >         struct rte_eventdev *dev;
> >         uint32_t i;
> >
> > +       if (eca_memzone_lookup())
> > +               return -ENOMEM;
> > +
> >         EVENT_CRYPTO_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
> >
> >         adapter = eca_id_to_adapter(id);
> > --
> > 2.6.4
> >
  
Jerin Jacob Kollanukkaran Oct. 19, 2022, 2:33 p.m. UTC | #3
> -----Original Message-----
> From: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>
> Sent: Wednesday, October 19, 2022 7:35 PM
> To: Jerin Jacob <jerinjacobk@gmail.com>; Kundapura, Ganapati
> <ganapati.kundapura@intel.com>
> Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>; dev@dpdk.org; Jerin
> Jacob Kollanukkaran <jerinj@marvell.com>
> Subject: [EXT] RE: [PATCH v1] eventdev/crypto: add memzone lookup
> 
> External Email
> 
> ----------------------------------------------------------------------
> 
> > -----Original Message-----
> > From: Jerin Jacob <jerinjacobk@gmail.com>
> > Sent: Wednesday, October 19, 2022 7:13 PM
> > To: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> > Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>; dev@dpdk.org;
> > jerinj@marvell.com; Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>
> > Subject: Re: [PATCH v1] eventdev/crypto: add memzone lookup
> >
> > On Tue, Oct 18, 2022 at 3:09 PM Ganapati Kundapura
> > <ganapati.kundapura@intel.com> wrote:
> > >
> > > Secondary process is not able to call the crypto adapter api's stats
> > > get/reset as crypto adapter memzone memory is not accessible by
> > > secondary process.
> > >
> > > Added memzone lookup so that secondary process can call the crypto
> > > adapter api's(stats_get etc)
> > >
> > > Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
> >
> > @Gujjar, Abhinandan S  Does this patch need to be part of rc2? If so,
> > please review ASAP. I will complete the rc2 PR by tomorrow.
> Hi Jerin,
> 
> I have already reviewed it internally. This can go to rc2. Thanks!
> 
> Acked-by: Abhinandan Gujjar <abhinandan.gujjar@intel.com>


Since it is a fix,

Updated the git commit as follows and applied to dpdk-next-net-eventdev/for-main. Thanks

    eventdev/crypto: fix multiprocess issue

    Secondary process is not able to call the crypto adapter
    APIs stats get/reset as crypto adapter memzone memory
    is not accessible by secondary process.

    Added memzone lookup so that secondary process can call the
    crypto adapter APIs(stats_get etc)

    Fixes: 7901eac3409a ("eventdev: add crypto adapter implementation")
    Cc: stable@dpdk.org

    Signed-off-by: Ganapati Kundapura <ganapati.kundapura@intel.com>
    Acked-by: Abhinandan Gujjar <abhinandan.gujjar@intel.com>


> 
> >
> >
> > >
> > > diff --git a/lib/eventdev/rte_event_crypto_adapter.c
> > > b/lib/eventdev/rte_event_crypto_adapter.c
> > > index a11cbcf..7c9901c 100644
> > > --- a/lib/eventdev/rte_event_crypto_adapter.c
> > > +++ b/lib/eventdev/rte_event_crypto_adapter.c
> > > @@ -33,6 +33,8 @@
> > >   */
> > >  #define CRYPTO_ENQ_FLUSH_THRESHOLD 1024
> > >
> > > +#define ECA_ADAPTER_ARRAY "crypto_adapter_array"
> > > +
> > >  struct crypto_ops_circular_buffer {
> > >         /* index of head element in circular buffer */
> > >         uint16_t head;
> > > @@ -138,7 +140,6 @@ eca_valid_id(uint8_t id)  static int
> > >  eca_init(void)
> > >  {
> > > -       const char *name = "crypto_adapter_array";
> > >         const struct rte_memzone *mz;
> > >         unsigned int sz;
> > >
> > > @@ -146,9 +147,10 @@ eca_init(void)
> > >             RTE_EVENT_CRYPTO_ADAPTER_MAX_INSTANCE;
> > >         sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
> > >
> > > -       mz = rte_memzone_lookup(name);
> > > +       mz = rte_memzone_lookup(ECA_ADAPTER_ARRAY);
> > >         if (mz == NULL) {
> > > -               mz = rte_memzone_reserve_aligned(name, sz, rte_socket_id(), 0,
> > > +               mz = rte_memzone_reserve_aligned(ECA_ADAPTER_ARRAY, sz,
> > > +                                                rte_socket_id(), 0,
> > >                                                  RTE_CACHE_LINE_SIZE);
> > >                 if (mz == NULL) {
> > >                         RTE_EDEV_LOG_ERR("failed to reserve memzone err = %"
> > > @@ -161,6 +163,22 @@ eca_init(void)
> > >         return 0;
> > >  }
> > >
> > > +static int
> > > +eca_memzone_lookup(void)
> > > +{
> > > +       const struct rte_memzone *mz;
> > > +
> > > +       if (event_crypto_adapter == NULL) {
> > > +               mz = rte_memzone_lookup(ECA_ADAPTER_ARRAY);
> > > +               if (mz == NULL)
> > > +                       return -ENOMEM;
> > > +
> > > +               event_crypto_adapter = mz->addr;
> > > +       }
> > > +
> > > +       return 0;
> > > +}
> > > +
> > >  static inline bool
> > >  eca_circular_buffer_batch_ready(struct crypto_ops_circular_buffer
> > > *bufp)  { @@ -1234,6 +1252,9 @@
> > > rte_event_crypto_adapter_stats_get(uint8_t id,
> > >         uint32_t i;
> > >         int ret;
> > >
> > > +       if (eca_memzone_lookup())
> > > +               return -ENOMEM;
> > > +
> > >         EVENT_CRYPTO_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
> > >
> > >         adapter = eca_id_to_adapter(id); @@ -1275,6 +1296,9 @@
> > > rte_event_crypto_adapter_stats_reset(uint8_t id)
> > >         struct rte_eventdev *dev;
> > >         uint32_t i;
> > >
> > > +       if (eca_memzone_lookup())
> > > +               return -ENOMEM;
> > > +
> > >         EVENT_CRYPTO_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
> > >
> > >         adapter = eca_id_to_adapter(id);
> > > --
> > > 2.6.4
> > >
  

Patch

diff --git a/lib/eventdev/rte_event_crypto_adapter.c b/lib/eventdev/rte_event_crypto_adapter.c
index a11cbcf..7c9901c 100644
--- a/lib/eventdev/rte_event_crypto_adapter.c
+++ b/lib/eventdev/rte_event_crypto_adapter.c
@@ -33,6 +33,8 @@ 
  */
 #define CRYPTO_ENQ_FLUSH_THRESHOLD 1024
 
+#define ECA_ADAPTER_ARRAY "crypto_adapter_array"
+
 struct crypto_ops_circular_buffer {
 	/* index of head element in circular buffer */
 	uint16_t head;
@@ -138,7 +140,6 @@  eca_valid_id(uint8_t id)
 static int
 eca_init(void)
 {
-	const char *name = "crypto_adapter_array";
 	const struct rte_memzone *mz;
 	unsigned int sz;
 
@@ -146,9 +147,10 @@  eca_init(void)
 	    RTE_EVENT_CRYPTO_ADAPTER_MAX_INSTANCE;
 	sz = RTE_ALIGN(sz, RTE_CACHE_LINE_SIZE);
 
-	mz = rte_memzone_lookup(name);
+	mz = rte_memzone_lookup(ECA_ADAPTER_ARRAY);
 	if (mz == NULL) {
-		mz = rte_memzone_reserve_aligned(name, sz, rte_socket_id(), 0,
+		mz = rte_memzone_reserve_aligned(ECA_ADAPTER_ARRAY, sz,
+						 rte_socket_id(), 0,
 						 RTE_CACHE_LINE_SIZE);
 		if (mz == NULL) {
 			RTE_EDEV_LOG_ERR("failed to reserve memzone err = %"
@@ -161,6 +163,22 @@  eca_init(void)
 	return 0;
 }
 
+static int
+eca_memzone_lookup(void)
+{
+	const struct rte_memzone *mz;
+
+	if (event_crypto_adapter == NULL) {
+		mz = rte_memzone_lookup(ECA_ADAPTER_ARRAY);
+		if (mz == NULL)
+			return -ENOMEM;
+
+		event_crypto_adapter = mz->addr;
+	}
+
+	return 0;
+}
+
 static inline bool
 eca_circular_buffer_batch_ready(struct crypto_ops_circular_buffer *bufp)
 {
@@ -1234,6 +1252,9 @@  rte_event_crypto_adapter_stats_get(uint8_t id,
 	uint32_t i;
 	int ret;
 
+	if (eca_memzone_lookup())
+		return -ENOMEM;
+
 	EVENT_CRYPTO_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 
 	adapter = eca_id_to_adapter(id);
@@ -1275,6 +1296,9 @@  rte_event_crypto_adapter_stats_reset(uint8_t id)
 	struct rte_eventdev *dev;
 	uint32_t i;
 
+	if (eca_memzone_lookup())
+		return -ENOMEM;
+
 	EVENT_CRYPTO_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);
 
 	adapter = eca_id_to_adapter(id);