[dpdk-dev,v4,2/2] ethdev: get the supported pools for a port

Message ID 20170911151837.25092-3-santosh.shukla@caviumnetworks.com
State New
Headers show

Checks

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

Commit Message

Santosh Shukla Sept. 11, 2017, 3:18 p.m.
Now that dpdk supports more than one mempool drivers and
each mempool driver works best for specific PMD, example:
- sw ring based mempool for Intel PMD drivers.
- dpaa2 HW mempool manager for dpaa2 PMD driver.
- fpa HW mempool manager for Octeontx PMD driver.

Application would like to know the best mempool handle
for any port.

Introducing rte_eth_dev_pools_ops_supported() API,
which allows PMD driver to advertise
his supported pools capability to the application.

Supported pools are categorized in below priority:-
- Best mempool handle for this port (Highest priority '0')
- Port supports this mempool handle (Priority '1')

Signed-off-by: Santosh Shukla <santosh.shukla@caviumnetworks.com>
---
v3 --> v4:
- Replaced __preferred_pool() with
  rte_eth_dev_pools_ops_supported() (suggested by Olivier)

History, Refer [1].
[1] http://dpdk.org/dev/patchwork/patch/27610/

 lib/librte_ether/rte_ethdev.c           | 24 ++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h           | 24 ++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev_version.map |  7 +++++++
 3 files changed, 55 insertions(+)

Patch hide | download patch | download mbox

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 0597641ee..0fa0cc3fa 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3409,3 +3409,27 @@  rte_eth_dev_adjust_nb_rx_tx_desc(uint8_t port_id,
 
 	return 0;
 }
+
+int
+rte_eth_dev_pools_ops_supported(uint8_t port_id, const char *pool)
+{
+	struct rte_eth_dev *dev;
+	const char *tmp;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+	if (pool == NULL)
+		return -EINVAL;
+
+	dev = &rte_eth_devices[port_id];
+
+	if (*dev->dev_ops->pools_ops_supported == NULL) {
+		tmp = rte_eal_mbuf_default_mempool_ops();
+		if (!strcmp(tmp, pool))
+			return 0;
+		else
+			return -ENOTSUP;
+	}
+
+	return (*dev->dev_ops->pools_ops_supported)(dev, pool);
+}
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 0adf3274a..d90029b1e 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1425,6 +1425,10 @@  typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev,
 				 struct rte_eth_dcb_info *dcb_info);
 /**< @internal Get dcb information on an Ethernet device */
 
+typedef int (*eth_pools_ops_supported_t)(struct rte_eth_dev *dev,
+						const char *pool);
+/**< @internal Get the supported pools for a port */
+
 /**
  * @internal A structure containing the functions exported by an Ethernet driver.
  */
@@ -1544,6 +1548,8 @@  struct eth_dev_ops {
 
 	eth_tm_ops_get_t tm_ops_get;
 	/**< Get Traffic Management (TM) operations. */
+	eth_pools_ops_supported_t pools_ops_supported;
+	/**< Get the supported pools for a port */
 };
 
 /**
@@ -4436,6 +4442,24 @@  int rte_eth_dev_adjust_nb_rx_tx_desc(uint8_t port_id,
 				     uint16_t *nb_rx_desc,
 				     uint16_t *nb_tx_desc);
 
+
+/**
+ * Get the supported pools for a port
+ *
+ * @param port_id
+ *   Port identifier of the Ethernet device.
+ * @param [in] pool
+ *   The supported pool handle for this port.
+ *   Maximum length of pool handle name is RTE_MEMPOOL_OPS_NAMESIZE.
+ * @return
+ *   - 0: best mempool ops choice for this port.
+ *   - 1: mempool ops are supported for this port.
+ *   - -ENOTSUP: mempool ops not supported for this port.
+ *   - <0: (-ENODEV, EINVAL) on failure.
+ */
+int
+rte_eth_dev_pools_ops_supported(uint8_t port_id, const char *pool);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map
index 42837285e..644705cf1 100644
--- a/lib/librte_ether/rte_ethdev_version.map
+++ b/lib/librte_ether/rte_ethdev_version.map
@@ -187,3 +187,10 @@  DPDK_17.08 {
 	rte_tm_wred_profile_delete;
 
 } DPDK_17.05;
+
+DPDK_17.11 {
+	global:
+
+	rte_eth_dev_pools_ops_supported;
+
+} DPDK_17.08;