DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/3] ethdev: add API to get preferred mbuf pool ops
@ 2017-12-13 19:55 Pavan Nikhilesh
  2017-12-13 19:55 ` [dpdk-dev] [PATCH 1/3] eal: add API to set default mbuf mempool ops Pavan Nikhilesh
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Pavan Nikhilesh @ 2017-12-13 19:55 UTC (permalink / raw)
  To: jerin.jacob, jingjing.wu, bruce.richardson, hemant.agrawal,
	ferruh.yigit, thomas, olivier.matz
  Cc: dev, Pavan Nikhilesh

This patch set provides new API to get and set the preferred mbuf mempool
ops across all the probed ethernet devices.
The API depends relies on ethernet devices to provide their preferred
mempool through `rte_eth_dev_pool_ops_supported`.

Currently, this patchset modifies only testpmd to used the API but it is
aimed towards modifying all the examples/tests to create packet pools
based on the preferred mempool ops.

Pavan Nikhilesh (3):
  eal: add API to set default mbuf mempool ops
  ethdev: add API to get preferred mempool ops name
  app/testpmd: set preferred mempool as default pktpool

 app/test-pmd/testpmd.c                  |  2 ++
 lib/librte_eal/bsdapp/eal/eal.c         |  6 +++++
 lib/librte_eal/common/include/rte_eal.h |  9 ++++++++
 lib/librte_eal/linuxapp/eal/eal.c       |  6 +++++
 lib/librte_eal/rte_eal_version.map      |  6 +++++
 lib/librte_ether/rte_ethdev.c           | 41 +++++++++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h           | 12 ++++++++++
 lib/librte_ether/rte_ethdev_version.map |  7 ++++++
 lib/librte_mempool/rte_mempool.h        | 12 ++++++++++
 9 files changed, 101 insertions(+)

--
2.14.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [PATCH 1/3] eal: add API to set default mbuf mempool ops
  2017-12-13 19:55 [dpdk-dev] [PATCH 0/3] ethdev: add API to get preferred mbuf pool ops Pavan Nikhilesh
@ 2017-12-13 19:55 ` Pavan Nikhilesh
  2017-12-13 19:55 ` [dpdk-dev] [PATCH 2/3] ethdev: add API to get preferred mempool ops name Pavan Nikhilesh
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Pavan Nikhilesh @ 2017-12-13 19:55 UTC (permalink / raw)
  To: jerin.jacob, jingjing.wu, bruce.richardson, hemant.agrawal,
	ferruh.yigit, thomas, olivier.matz
  Cc: dev, Pavan Nikhilesh

Add new API to set the default mbuf mempool ops name i.e. set the provided
ops name to `internal_config.mbuf_pool_ops_name`.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
---
 lib/librte_eal/bsdapp/eal/eal.c         | 6 ++++++
 lib/librte_eal/common/include/rte_eal.h | 9 +++++++++
 lib/librte_eal/linuxapp/eal/eal.c       | 6 ++++++
 lib/librte_eal/rte_eal_version.map      | 6 ++++++
 4 files changed, 27 insertions(+)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 369a682a8..dc87ffbdc 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -117,6 +117,12 @@ rte_eal_mbuf_default_mempool_ops(void)
 	return internal_config.mbuf_pool_ops_name;
 }
 
+void
+rte_eal_set_mbuf_default_mempool_ops(const char *ops_name)
+{
+	internal_config.mbuf_pool_ops_name = ops_name;
+}
+
 /* Return a pointer to the configuration structure */
 struct rte_config *
 rte_eal_get_configuration(void)
diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h
index 8e4e71cc1..eb7db5797 100644
--- a/lib/librte_eal/common/include/rte_eal.h
+++ b/lib/librte_eal/common/include/rte_eal.h
@@ -335,6 +335,15 @@ enum rte_iova_mode rte_eal_iova_mode(void);
 const char *
 rte_eal_mbuf_default_mempool_ops(void);
 
+/**
+ * Set default pool ops name for mbuf
+ *
+ * @param ops_name
+ *   mempool ops name that is to be set as default.
+ */
+void
+rte_eal_set_mbuf_default_mempool_ops(const char *ops_name);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 229eec9f1..5c6feff64 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -127,6 +127,12 @@ rte_eal_mbuf_default_mempool_ops(void)
 	return internal_config.mbuf_pool_ops_name;
 }
 
+void
+rte_eal_set_mbuf_default_mempool_ops(const char *ops_name)
+{
+	internal_config.mbuf_pool_ops_name = ops_name;
+}
+
 /* Return a pointer to the configuration structure */
 struct rte_config *
 rte_eal_get_configuration(void)
diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map
index f4f46c1be..43a6fa97f 100644
--- a/lib/librte_eal/rte_eal_version.map
+++ b/lib/librte_eal/rte_eal_version.map
@@ -200,6 +200,12 @@ DPDK_17.11 {
 
 } DPDK_17.08;
 
+DPDK_18.02 {
+	global:
+
+	rte_eal_set_mbuf_default_mempool_ops;
+} DPDK_17.11;
+
 EXPERIMENTAL {
 	global:
 
-- 
2.14.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [PATCH 2/3] ethdev: add API to get preferred mempool ops name
  2017-12-13 19:55 [dpdk-dev] [PATCH 0/3] ethdev: add API to get preferred mbuf pool ops Pavan Nikhilesh
  2017-12-13 19:55 ` [dpdk-dev] [PATCH 1/3] eal: add API to set default mbuf mempool ops Pavan Nikhilesh
@ 2017-12-13 19:55 ` Pavan Nikhilesh
  2017-12-13 19:55 ` [dpdk-dev] [PATCH 3/3] app/testpmd: set preferred mempool as default pktpool Pavan Nikhilesh
  2017-12-13 21:22 ` [dpdk-dev] [PATCH 0/3] ethdev: add API to get preferred mbuf pool ops Thomas Monjalon
  3 siblings, 0 replies; 7+ messages in thread
From: Pavan Nikhilesh @ 2017-12-13 19:55 UTC (permalink / raw)
  To: jerin.jacob, jingjing.wu, bruce.richardson, hemant.agrawal,
	ferruh.yigit, thomas, olivier.matz
  Cc: dev, Pavan Nikhilesh

Add API to scan through the ethernet devices and return the best mbuf
mempool ops name.
If no such mempool is found it returns the default mempool configured.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
---
 lib/librte_ether/rte_ethdev.c           | 41 +++++++++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h           | 12 ++++++++++
 lib/librte_ether/rte_ethdev_version.map |  7 ++++++
 lib/librte_mempool/rte_mempool.h        | 12 ++++++++++
 4 files changed, 72 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 318af2869..514037ec2 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3591,3 +3591,44 @@ rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool)
 
 	return (*dev->dev_ops->pool_ops_supported)(dev, pool);
 }
+
+const char *
+rte_eth_dev_get_preferred_pool_name(uint8_t set_default)
+{
+	int i, j;
+	int ret;
+	int best_weight = 0;
+	int default_pool_weight = 0;
+	const char *default_pool_name = rte_eal_mbuf_default_mempool_ops();
+	const char *preferred_pool_name = NULL;
+
+	for (i = 0; i < rte_mempool_ops_count(); i++) {
+		int weight = 0;
+		const char *name = rte_mempool_get_ops(i)->name;
+
+		for (j = 0; j < rte_eth_dev_count(); j++) {
+			ret = rte_eth_dev_pool_ops_supported(j, name);
+			if (ret < 0) {
+				weight = -1;
+				break;
+			}
+			weight += ret ? 1 : 2;
+		}
+
+		if (weight > best_weight) {
+			best_weight = weight;
+			preferred_pool_name = name;
+		}
+
+		if (!strcmp(name, default_pool_name))
+			default_pool_weight = weight;
+	}
+
+	if (!best_weight || best_weight == default_pool_weight)
+		preferred_pool_name = default_pool_name;
+
+	if (set_default)
+		rte_eal_set_mbuf_default_mempool_ops(preferred_pool_name);
+
+	return preferred_pool_name;
+}
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 341c2d624..3f4b234a0 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -4606,6 +4606,18 @@ int rte_eth_dev_adjust_nb_rx_tx_desc(uint16_t port_id,
 int
 rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool);
 
+/**
+ * Scan through the ethernet devices and select the best mempool ops supported
+ * across them.
+ *
+ * @param set_default
+ *   Set the selected mempool ops as default.
+ * @return
+ *   The name of the selected mempool ops.
+ */
+const char *
+rte_eth_dev_get_preferred_pool_name(uint8_t set_default);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map
index e9681ac8e..674a59c92 100644
--- a/lib/librte_ether/rte_ethdev_version.map
+++ b/lib/librte_ether/rte_ethdev_version.map
@@ -198,6 +198,13 @@ DPDK_17.11 {
 
 } DPDK_17.08;
 
+DPDK_18.02 {
+	global:
+
+	rte_eth_dev_get_preferred_pool_name;
+
+} DPDK_17.11;
+
 EXPERIMENTAL {
 	global:
 
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index 721227f6d..27033102d 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -485,6 +485,18 @@ rte_mempool_get_ops(int ops_index)
 	return &rte_mempool_ops_table.ops[ops_index];
 }
 
+/**
+ * @internal Get the total number of mempool ops.
+ *
+ * @return
+ *   The number of mempool ops in the ops table.
+ */
+static inline int
+rte_mempool_ops_count(void)
+{
+	return rte_mempool_ops_table.num_ops;
+}
+
 /**
  * @internal Wrapper for mempool_ops alloc callback.
  *
-- 
2.14.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [PATCH 3/3] app/testpmd: set preferred mempool as default pktpool
  2017-12-13 19:55 [dpdk-dev] [PATCH 0/3] ethdev: add API to get preferred mbuf pool ops Pavan Nikhilesh
  2017-12-13 19:55 ` [dpdk-dev] [PATCH 1/3] eal: add API to set default mbuf mempool ops Pavan Nikhilesh
  2017-12-13 19:55 ` [dpdk-dev] [PATCH 2/3] ethdev: add API to get preferred mempool ops name Pavan Nikhilesh
@ 2017-12-13 19:55 ` Pavan Nikhilesh
  2018-01-16  6:06   ` Lu, Wenzhuo
  2017-12-13 21:22 ` [dpdk-dev] [PATCH 0/3] ethdev: add API to get preferred mbuf pool ops Thomas Monjalon
  3 siblings, 1 reply; 7+ messages in thread
From: Pavan Nikhilesh @ 2017-12-13 19:55 UTC (permalink / raw)
  To: jerin.jacob, jingjing.wu, bruce.richardson, hemant.agrawal,
	ferruh.yigit, thomas, olivier.matz
  Cc: dev, Pavan Nikhilesh

Set the mempool preferred by the ethernet devices as default mbuf
mempool before creating the pktpool.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
---
 app/test-pmd/testpmd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index c3ab44849..bfea35613 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -533,6 +533,8 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,
 		rte_mempool_obj_iter(rte_mp, rte_pktmbuf_init, NULL);
 	} else {
 		/* wrapper to rte_mempool_create() */
+		RTE_LOG(INFO, USER1, "preferred mempool ops %s selected\n",
+				rte_eth_dev_get_preferred_pool_name(1));
 		rte_mp = rte_pktmbuf_pool_create(pool_name, nb_mbuf,
 			mb_mempool_cache, 0, mbuf_seg_size, socket_id);
 	}
-- 
2.14.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH 0/3] ethdev: add API to get preferred mbuf pool ops
  2017-12-13 19:55 [dpdk-dev] [PATCH 0/3] ethdev: add API to get preferred mbuf pool ops Pavan Nikhilesh
                   ` (2 preceding siblings ...)
  2017-12-13 19:55 ` [dpdk-dev] [PATCH 3/3] app/testpmd: set preferred mempool as default pktpool Pavan Nikhilesh
@ 2017-12-13 21:22 ` Thomas Monjalon
  3 siblings, 0 replies; 7+ messages in thread
From: Thomas Monjalon @ 2017-12-13 21:22 UTC (permalink / raw)
  To: Pavan Nikhilesh
  Cc: dev, jerin.jacob, jingjing.wu, bruce.richardson, hemant.agrawal,
	ferruh.yigit, olivier.matz

13/12/2017 20:55, Pavan Nikhilesh:
> This patch set provides new API to get and set the preferred mbuf mempool
> ops across all the probed ethernet devices.
> The API depends relies on ethernet devices to provide their preferred
> mempool through `rte_eth_dev_pool_ops_supported`.

Note that this new feature is too late for 18.02.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH 3/3] app/testpmd: set preferred mempool as default pktpool
  2017-12-13 19:55 ` [dpdk-dev] [PATCH 3/3] app/testpmd: set preferred mempool as default pktpool Pavan Nikhilesh
@ 2018-01-16  6:06   ` Lu, Wenzhuo
  2018-01-16  8:20     ` Pavan Nikhilesh
  0 siblings, 1 reply; 7+ messages in thread
From: Lu, Wenzhuo @ 2018-01-16  6:06 UTC (permalink / raw)
  To: Pavan Nikhilesh, jerin.jacob, Wu, Jingjing, Richardson, Bruce,
	hemant.agrawal, Yigit, Ferruh, thomas, olivier.matz
  Cc: dev

Hi Pavan,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pavan Nikhilesh
> Sent: Thursday, December 14, 2017 3:56 AM
> To: jerin.jacob@caviumnetworks.com; Wu, Jingjing <jingjing.wu@intel.com>;
> Richardson, Bruce <bruce.richardson@intel.com>; hemant.agrawal@nxp.com;
> Yigit, Ferruh <ferruh.yigit@intel.com>; thomas@monjalon.net;
> olivier.matz@6wind.com
> Cc: dev@dpdk.org; Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> Subject: [dpdk-dev] [PATCH 3/3] app/testpmd: set preferred mempool as
> default pktpool
> 
> Set the mempool preferred by the ethernet devices as default mbuf
> mempool before creating the pktpool.
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> ---
>  app/test-pmd/testpmd.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> c3ab44849..bfea35613 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -533,6 +533,8 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned
> nb_mbuf,
>  		rte_mempool_obj_iter(rte_mp, rte_pktmbuf_init, NULL);
>  	} else {
>  		/* wrapper to rte_mempool_create() */
> +		RTE_LOG(INFO, USER1, "preferred mempool ops %s
> selected\n",
> +				rte_eth_dev_get_preferred_pool_name(1));
This '1'  looks like hardcode. May I suggest to change it to 'true'?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH 3/3] app/testpmd: set preferred mempool as default pktpool
  2018-01-16  6:06   ` Lu, Wenzhuo
@ 2018-01-16  8:20     ` Pavan Nikhilesh
  0 siblings, 0 replies; 7+ messages in thread
From: Pavan Nikhilesh @ 2018-01-16  8:20 UTC (permalink / raw)
  To: Lu, Wenzhuo; +Cc: dev

Hi Lu,

On Tue, Jan 16, 2018 at 06:06:50AM +0000, Lu, Wenzhuo wrote:
> Hi Pavan,
>
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pavan Nikhilesh
> > Sent: Thursday, December 14, 2017 3:56 AM
> > To: jerin.jacob@caviumnetworks.com; Wu, Jingjing <jingjing.wu@intel.com>;
> > Richardson, Bruce <bruce.richardson@intel.com>; hemant.agrawal@nxp.com;
> > Yigit, Ferruh <ferruh.yigit@intel.com>; thomas@monjalon.net;
> > olivier.matz@6wind.com
> > Cc: dev@dpdk.org; Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> > Subject: [dpdk-dev] [PATCH 3/3] app/testpmd: set preferred mempool as
> > default pktpool
> >
> > Set the mempool preferred by the ethernet devices as default mbuf
> > mempool before creating the pktpool.
> >
> > Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> > ---
> >  app/test-pmd/testpmd.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> > c3ab44849..bfea35613 100644
> > --- a/app/test-pmd/testpmd.c
> > +++ b/app/test-pmd/testpmd.c
> > @@ -533,6 +533,8 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned
> > nb_mbuf,
> >  		rte_mempool_obj_iter(rte_mp, rte_pktmbuf_init, NULL);
> >  	} else {
> >  		/* wrapper to rte_mempool_create() */
> > +		RTE_LOG(INFO, USER1, "preferred mempool ops %s
> > selected\n",
> > +				rte_eth_dev_get_preferred_pool_name(1));
> This '1'  looks like hardcode. May I suggest to change it to 'true'?

This patchset will be superseeded by http://dpdk.org/dev/patchwork/patch/33716/
I will mark the same.

Thanks,
Pavan.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-01-16  8:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-13 19:55 [dpdk-dev] [PATCH 0/3] ethdev: add API to get preferred mbuf pool ops Pavan Nikhilesh
2017-12-13 19:55 ` [dpdk-dev] [PATCH 1/3] eal: add API to set default mbuf mempool ops Pavan Nikhilesh
2017-12-13 19:55 ` [dpdk-dev] [PATCH 2/3] ethdev: add API to get preferred mempool ops name Pavan Nikhilesh
2017-12-13 19:55 ` [dpdk-dev] [PATCH 3/3] app/testpmd: set preferred mempool as default pktpool Pavan Nikhilesh
2018-01-16  6:06   ` Lu, Wenzhuo
2018-01-16  8:20     ` Pavan Nikhilesh
2017-12-13 21:22 ` [dpdk-dev] [PATCH 0/3] ethdev: add API to get preferred mbuf pool ops Thomas Monjalon

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).