DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Hunt, David" <david.hunt@intel.com>
To: Hemant Agrawal <hemant.agrawal@nxp.com>, olivier.matz@6wind.com
Cc: dev@dpdk.org, jerin.jacob@caviumnetworks.com
Subject: Re: [dpdk-dev] [PATCH v2 1/2] eal/mempool: introduce check for external mempool availability
Date: Fri, 16 Sep 2016 10:13:33 +0100	[thread overview]
Message-ID: <f6f72a80-f6ec-ef10-c60b-f59b47bf1771@intel.com> (raw)
In-Reply-To: <1473959607-1951-1-git-send-email-hemant.agrawal@nxp.com>

Hi Hemant,

On 15/9/2016 6:13 PM, Hemant Agrawal wrote:
> External offloaded mempool may not be available always. This check enables
> run time verification of the presence of external mempool before the
> mempool ops are installed.
>
> An application built with a specific external mempool may work fine
> on host. But, may not work on VM, specificaly if non-hw specific interfaces
> are used e.g. virtio-net.
>
> This is required to make sure that same application can work in all
> environment for a given hw platform.
>
> The solution proposed here is that rte_mempool_set_ops_byname should return
> specific error in case the current execution environment is not supporting
> the given mempool. Thereby allowing it to fallback on software mempool
> implementation e.g. "ring_mp_mc"
>
> This patch introduces new optional "pool_verify" as mempool ops function
> to check if external mempool instance is available or not.

I've a small suggestion around the naming of the new functions. It seems 
to me that this patch is more about mempool handler 'support' than 
'verification'.
Could I suggest a different name for this new function? I think maybe 
"supported" may be more appropriate than "pool_verify". The return code 
that's returned when a mempool handler is not available is -EOPNOTSUPP, 
which is what suggested the word "supported" to me. I think that:

	if (ops->supported)
		return ops->supported(mp);

makes for slightly easier reading. The wrapper function would logically 
then be called  rte_mempool_ops_supported().


> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
> ---
> Changes in v2:
> * fixed the pool_verify copy in rte_mempool_register_ops
> ---
>   lib/librte_mempool/rte_mempool.h       | 21 +++++++++++++++++++++
>   lib/librte_mempool/rte_mempool_ops.c   | 19 +++++++++++++++++++
>   lib/librte_mempool/rte_mempool_ring.c  |  4 ++++
>   lib/librte_mempool/rte_mempool_stack.c |  3 ++-
>   4 files changed, 46 insertions(+), 1 deletion(-)
>
> diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
> index 0243f9e..8599df1 100644
> --- a/lib/librte_mempool/rte_mempool.h
> +++ b/lib/librte_mempool/rte_mempool.h
> @@ -387,6 +387,12 @@ typedef int (*rte_mempool_dequeue_t)(struct rte_mempool *mp,
>    */
>   typedef unsigned (*rte_mempool_get_count)(const struct rte_mempool *mp);
>   
> +/**
> + * Return if the given external mempool is available for this instance.
> + * it is optional to implement for mempools
> + */
> +typedef int (*rte_mempool_pool_verify)(const struct rte_mempool *mp);
> +
>   /** Structure defining mempool operations structure */
>   struct rte_mempool_ops {
>   	char name[RTE_MEMPOOL_OPS_NAMESIZE]; /**< Name of mempool ops struct. */
> @@ -395,6 +401,8 @@ struct rte_mempool_ops {
>   	rte_mempool_enqueue_t enqueue;   /**< Enqueue an object. */
>   	rte_mempool_dequeue_t dequeue;   /**< Dequeue an object. */
>   	rte_mempool_get_count get_count; /**< Get qty of available objs. */
> +	rte_mempool_pool_verify pool_verify;
> +	/**< Verify if external mempool is available for usages*/
>   } __rte_cache_aligned;
>   
>   #define RTE_MEMPOOL_MAX_OPS_IDX 16  /**< Max registered ops structs */
> @@ -516,6 +524,18 @@ void
>   rte_mempool_ops_free(struct rte_mempool *mp);
>   
>   /**
> + * @internal wrapper to verify the external mempool availability
> + *
> + * @param mp
> + *   Pointer to the memory pool.
> + * @return
> + *   0: Success; external mempool instance is available
> + * - <0: Error; external mempool instance is not available
> + */
> +int
> +rte_mempool_ops_pool_verify(const struct rte_mempool *mp);
> +
> +/**
>    * Set the ops of a mempool.
>    *
>    * This can only be done on a mempool that is not populated, i.e. just after
> @@ -531,6 +551,7 @@ rte_mempool_ops_free(struct rte_mempool *mp);
>    *   - 0: Success; the mempool is now using the requested ops functions.
>    *   - -EINVAL - Invalid ops struct name provided.
>    *   - -EEXIST - mempool already has an ops struct assigned.
> + *   - -EOPNOTSUPP  - mempool instance not available.
>    */
>   int
>   rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
> diff --git a/lib/librte_mempool/rte_mempool_ops.c b/lib/librte_mempool/rte_mempool_ops.c
> index 5f24de2..c2e765f 100644
> --- a/lib/librte_mempool/rte_mempool_ops.c
> +++ b/lib/librte_mempool/rte_mempool_ops.c
> @@ -85,6 +85,7 @@ rte_mempool_register_ops(const struct rte_mempool_ops *h)
>   	ops->enqueue = h->enqueue;
>   	ops->dequeue = h->dequeue;
>   	ops->get_count = h->get_count;
> +	ops->pool_verify = h->pool_verify;
>   
>   	rte_spinlock_unlock(&rte_mempool_ops_table.sl);
>   
> @@ -123,6 +124,18 @@ rte_mempool_ops_get_count(const struct rte_mempool *mp)
>   	return ops->get_count(mp);
>   }
>   
> +/* wrapper to check if given external mempool is available for this instance.*/
> +int
> +rte_mempool_ops_pool_verify(const struct rte_mempool *mp)
> +{
> +	struct rte_mempool_ops *ops;
> +
> +	ops = rte_mempool_get_ops(mp->ops_index);
> +	if (ops->pool_verify)
> +		return ops->pool_verify(mp);
> +	return 0;
> +}
> +
>   /* sets mempool ops previously registered by rte_mempool_register_ops. */
>   int
>   rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
> @@ -146,6 +159,12 @@ rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
>   	if (ops == NULL)
>   		return -EINVAL;
>   
> +	/*verify if the given mempool is available for this instance */
> +	if (ops->pool_verify) {
> +		if (ops->pool_verify(mp))
> +			return -EOPNOTSUPP;
> +	}
> +
>   	mp->ops_index = i;
>   	mp->pool_config = pool_config;
>   	return 0;
> diff --git a/lib/librte_mempool/rte_mempool_ring.c b/lib/librte_mempool/rte_mempool_ring.c
> index b9aa64d..d86d5e0 100644
> --- a/lib/librte_mempool/rte_mempool_ring.c
> +++ b/lib/librte_mempool/rte_mempool_ring.c
> @@ -126,6 +126,7 @@ static const struct rte_mempool_ops ops_mp_mc = {
>   	.enqueue = common_ring_mp_enqueue,
>   	.dequeue = common_ring_mc_dequeue,
>   	.get_count = common_ring_get_count,
> +	.pool_verify = NULL,
>   };
>   
>   static const struct rte_mempool_ops ops_sp_sc = {
> @@ -135,6 +136,7 @@ static const struct rte_mempool_ops ops_sp_sc = {
>   	.enqueue = common_ring_sp_enqueue,
>   	.dequeue = common_ring_sc_dequeue,
>   	.get_count = common_ring_get_count,
> +	.pool_verify = NULL,
>   };
>   
>   static const struct rte_mempool_ops ops_mp_sc = {
> @@ -144,6 +146,7 @@ static const struct rte_mempool_ops ops_mp_sc = {
>   	.enqueue = common_ring_mp_enqueue,
>   	.dequeue = common_ring_sc_dequeue,
>   	.get_count = common_ring_get_count,
> +	.pool_verify = NULL,
>   };
>   
>   static const struct rte_mempool_ops ops_sp_mc = {
> @@ -153,6 +156,7 @@ static const struct rte_mempool_ops ops_sp_mc = {
>   	.enqueue = common_ring_sp_enqueue,
>   	.dequeue = common_ring_mc_dequeue,
>   	.get_count = common_ring_get_count,
> +	.pool_verify = NULL,
>   };
>   
>   MEMPOOL_REGISTER_OPS(ops_mp_mc);
> diff --git a/lib/librte_mempool/rte_mempool_stack.c b/lib/librte_mempool/rte_mempool_stack.c
> index 5fd8af2..0198b70 100644
> --- a/lib/librte_mempool/rte_mempool_stack.c
> +++ b/lib/librte_mempool/rte_mempool_stack.c
> @@ -141,7 +141,8 @@ static struct rte_mempool_ops ops_stack = {
>   	.free = stack_free,
>   	.enqueue = stack_enqueue,
>   	.dequeue = stack_dequeue,
> -	.get_count = stack_get_count
> +	.get_count = stack_get_count,
> +	.pool_verify = NULL,
>   };
>   
>   MEMPOOL_REGISTER_OPS(ops_stack);

Regards,
Dave.

  parent reply	other threads:[~2016-09-16  9:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-08 14:50 [dpdk-dev] [PATCH " Hemant Agrawal
2016-09-08 14:50 ` [dpdk-dev] [PATCH 2/2] mempool:pktmbuf pool default fallback for mempool ops error Hemant Agrawal
2016-09-15 17:13 ` [dpdk-dev] [PATCH v2 1/2] eal/mempool: introduce check for external mempool availability Hemant Agrawal
2016-09-15 17:13   ` [dpdk-dev] [PATCH v2 2/2] mempool:pktmbuf pool default fallback for mempool ops error Hemant Agrawal
2016-09-16  8:29     ` Hunt, David
2016-09-16  9:34       ` Hemant Agrawal
2016-09-16  9:13   ` Hunt, David [this message]
2016-09-16  9:34     ` [dpdk-dev] [PATCH v2 1/2] eal/mempool: introduce check for external mempool availability Hemant Agrawal
2016-09-16 16:46   ` [dpdk-dev] [PATCH v3 1/2] eal/mempool: check for external mempool support Hemant Agrawal
2016-09-16 16:46     ` [dpdk-dev] [PATCH v3 2/2] mempool: pktmbuf pool default fallback for mempool ops error Hemant Agrawal
2016-09-19 13:57       ` Olivier Matz
2016-09-22 13:12         ` Hemant Agrawal
2016-10-13 13:15           ` Hemant Agrawal
2016-10-14 12:10             ` Olivier Matz
2016-11-07 12:30               ` Hemant Agrawal
2016-11-22  9:24                 ` Olivier Matz
2016-12-08  8:57                   ` Hemant Agrawal

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=f6f72a80-f6ec-ef10-c60b-f59b47bf1771@intel.com \
    --to=david.hunt@intel.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=jerin.jacob@caviumnetworks.com \
    --cc=olivier.matz@6wind.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).