[dpdk-dev,RFC,1/6] mempool: implement abstract mempool info API

Message ID 1511539591-20966-2-git-send-email-arybchenko@solarflare.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Andrew Rybchenko Nov. 24, 2017, 4:06 p.m. UTC
  From: "Artem V. Andreev" <Artem.Andreev@oktetlabs.ru>

Primarily, it is intended as a way for the mempool driver to provide
additional information on how it lays up objects inside the mempool.

Signed-off-by: Artem V. Andreev <Artem.Andreev@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 lib/librte_mempool/rte_mempool.h     | 31 +++++++++++++++++++++++++++++++
 lib/librte_mempool/rte_mempool_ops.c | 15 +++++++++++++++
 2 files changed, 46 insertions(+)
  

Comments

Olivier Matz Dec. 14, 2017, 1:36 p.m. UTC | #1
On Fri, Nov 24, 2017 at 04:06:26PM +0000, Andrew Rybchenko wrote:
> From: "Artem V. Andreev" <Artem.Andreev@oktetlabs.ru>
> 
> Primarily, it is intended as a way for the mempool driver to provide
> additional information on how it lays up objects inside the mempool.
> 
> Signed-off-by: Artem V. Andreev <Artem.Andreev@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
> ---
>  lib/librte_mempool/rte_mempool.h     | 31 +++++++++++++++++++++++++++++++
>  lib/librte_mempool/rte_mempool_ops.c | 15 +++++++++++++++
>  2 files changed, 46 insertions(+)
> 
> diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
> index 721227f..3c59d36 100644
> --- a/lib/librte_mempool/rte_mempool.h
> +++ b/lib/librte_mempool/rte_mempool.h
> @@ -217,6 +217,11 @@ struct rte_mempool_memhdr {
>  	void *opaque;            /**< Argument passed to the free callback */
>  };
>  
> +/*
> + * Additional information about the mempool
> + */
> +struct rte_mempool_info;
> +

While there is no compilation issue, I find a bit strange to define this
API without defining the content of rte_mempool_info.
  
Andrew Rybchenko Jan. 17, 2018, 3:03 p.m. UTC | #2
On 12/14/2017 04:36 PM, Olivier MATZ wrote:
> On Fri, Nov 24, 2017 at 04:06:26PM +0000, Andrew Rybchenko wrote:
>> From: "Artem V. Andreev" <Artem.Andreev@oktetlabs.ru>
>>
>> Primarily, it is intended as a way for the mempool driver to provide
>> additional information on how it lays up objects inside the mempool.
>>
>> Signed-off-by: Artem V. Andreev <Artem.Andreev@oktetlabs.ru>
>> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
>> ---
>>   lib/librte_mempool/rte_mempool.h     | 31 +++++++++++++++++++++++++++++++
>>   lib/librte_mempool/rte_mempool_ops.c | 15 +++++++++++++++
>>   2 files changed, 46 insertions(+)
>>
>> diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
>> index 721227f..3c59d36 100644
>> --- a/lib/librte_mempool/rte_mempool.h
>> +++ b/lib/librte_mempool/rte_mempool.h
>> @@ -217,6 +217,11 @@ struct rte_mempool_memhdr {
>>   	void *opaque;            /**< Argument passed to the free callback */
>>   };
>>   
>> +/*
>> + * Additional information about the mempool
>> + */
>> +struct rte_mempool_info;
>> +
> While there is no compilation issue, I find a bit strange to define this
> API without defining the content of rte_mempool_info.

Agree. Mainly it was an attempt to fit required way to store objects in 
memory
into existing approach. I agree that it is significantly better to solve 
it in
the different way as you suggested. So, the patch will go away.
  

Patch

diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index 721227f..3c59d36 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -217,6 +217,11 @@  struct rte_mempool_memhdr {
 	void *opaque;            /**< Argument passed to the free callback */
 };
 
+/*
+ * Additional information about the mempool
+ */
+struct rte_mempool_info;
+
 /**
  * The RTE mempool structure.
  */
@@ -422,6 +427,12 @@  typedef int (*rte_mempool_get_capabilities_t)(const struct rte_mempool *mp,
 		unsigned int *flags);
 
 /**
+ * Get some additional information about a mempool.
+ */
+typedef int (*rte_mempool_get_info_t)(const struct rte_mempool *mp,
+		struct rte_mempool_info *info);
+
+/**
  * Notify new memory area to mempool.
  */
 typedef int (*rte_mempool_ops_register_memory_area_t)
@@ -443,6 +454,10 @@  struct rte_mempool_ops {
 	 * Notify new memory area to mempool
 	 */
 	rte_mempool_ops_register_memory_area_t register_memory_area;
+	/**
+	 * Get mempool info
+	 */
+	rte_mempool_get_info_t get_info;
 } __rte_cache_aligned;
 
 #define RTE_MEMPOOL_MAX_OPS_IDX 16  /**< Max registered ops structs */
@@ -592,6 +607,22 @@  rte_mempool_ops_register_memory_area(const struct rte_mempool *mp,
 				char *vaddr, rte_iova_t iova, size_t len);
 
 /**
+ * @internal wrapper for mempool_ops get_info callback.
+ *
+ * @param mp [in]
+ *   Pointer to the memory pool.
+ * @param info [out]
+ *   Pointer to the rte_mempool_info structure
+ * @return
+ *   - 0: Success; The mempool driver supports retrieving supplementary
+ *        mempool information
+ *   - -ENOTSUP - doesn't support get_info ops (valid case).
+ */
+int
+rte_mempool_ops_get_info(const struct rte_mempool *mp,
+			 struct rte_mempool_info *info);
+
+/**
  * @internal wrapper for mempool_ops free callback.
  *
  * @param mp
diff --git a/lib/librte_mempool/rte_mempool_ops.c b/lib/librte_mempool/rte_mempool_ops.c
index 92b9f90..23de4db 100644
--- a/lib/librte_mempool/rte_mempool_ops.c
+++ b/lib/librte_mempool/rte_mempool_ops.c
@@ -88,6 +88,7 @@  rte_mempool_register_ops(const struct rte_mempool_ops *h)
 	ops->get_count = h->get_count;
 	ops->get_capabilities = h->get_capabilities;
 	ops->register_memory_area = h->register_memory_area;
+	ops->get_info = h->get_info;
 
 	rte_spinlock_unlock(&rte_mempool_ops_table.sl);
 
@@ -152,6 +153,20 @@  rte_mempool_ops_register_memory_area(const struct rte_mempool *mp, char *vaddr,
 	return ops->register_memory_area(mp, vaddr, iova, len);
 }
 
+/* wrapper to get additional mempool info */
+int
+rte_mempool_ops_get_info(const struct rte_mempool *mp,
+			 struct rte_mempool_info *info)
+{
+	struct rte_mempool_ops *ops;
+
+	ops = rte_mempool_get_ops(mp->ops_index);
+
+	RTE_FUNC_PTR_OR_ERR_RET(ops->get_info, -ENOTSUP);
+	return ops->get_info(mp, info);
+}
+
+
 /* sets mempool ops previously registered by rte_mempool_register_ops. */
 int
 rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,