DPDK patches and discussions
 help / color / mirror / Atom feed
From: <vattunuru@marvell.com>
To: <dev@dpdk.org>
Cc: <jerinj@marvell.com>, <ferruh.yigit@intel.com>,
	<arybchenko@solarflare.com>, <thomas@monjalon.net>,
	Vamsi Attunuru <vattunuru@marvell.com>
Subject: [dpdk-dev] [PATCH v1 1/3] lib/ethdev: add ethdev op to get hash index
Date: Sat, 14 Sep 2019 11:22:45 +0530	[thread overview]
Message-ID: <20190914055247.3841-2-vattunuru@marvell.com> (raw)
In-Reply-To: <20190914055247.3841-1-vattunuru@marvell.com>

From: Vamsi Attunuru <vattunuru@marvell.com>

Some networking devices may use custom algos for computing
hash indices and spread the packets accordingly.

Patch adds a eth_dev op to get the hash index correspond to
the given hash value received on the given port.

Some of use cases where applications would compute hash index
from hash value upfront and it can predict the packets come to
a specific queue.

Signed-off-by: Vamsi Attunuru <vattunuru@marvell.com>
---
 lib/librte_ethdev/rte_ethdev.c           | 13 +++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 20 ++++++++++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      |  5 +++++
 lib/librte_ethdev/rte_ethdev_version.map |  3 +++
 4 files changed, 41 insertions(+)

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 17d183e..6a234d6 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -3022,6 +3022,19 @@ rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
 }
 
 int
+rte_eth_dev_rss_hash_index_get(uint16_t port_id,
+			       uint32_t hash, uint32_t *hash_idx)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_index_get, -ENOTSUP);
+	return eth_err(port_id, (*dev->dev_ops->rss_hash_index_get)(dev, hash,
+								    hash_idx));
+}
+
+int
 rte_eth_dev_udp_tunnel_port_add(uint16_t port_id,
 				struct rte_eth_udp_tunnel *udp_tunnel)
 {
diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index dc6596b..03ca1e9 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -3262,6 +3262,26 @@ rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
 			      struct rte_eth_rss_conf *rss_conf);
 
  /**
+ * Get hash index of the given hash value that received in mbuf from this port.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param hash
+ *   The hash value used to compute hash_idx.
+ * @param hash_idx
+ *   Where to store the computed hash_idx
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if port identifier is invalid.
+ *   - (-EIO) if device is removed.
+ *   - (-ENOTSUP) if hardware doesn't support RSS.
+ */
+__rte_experimental
+int
+rte_eth_dev_rss_hash_index_get(uint16_t port_id,
+			       uint32_t hash, uint32_t *hash_idx);
+
+ /**
  * Add UDP tunneling port for a specific type of tunnel.
  * The packets with this UDP port will be identified as this type of tunnel.
  * Before enabling any offloading function for a tunnel, users can call this API
diff --git a/lib/librte_ethdev/rte_ethdev_core.h b/lib/librte_ethdev/rte_ethdev_core.h
index 2922d5b..aebfb5f 100644
--- a/lib/librte_ethdev/rte_ethdev_core.h
+++ b/lib/librte_ethdev/rte_ethdev_core.h
@@ -240,6 +240,10 @@ typedef int (*rss_hash_conf_get_t)(struct rte_eth_dev *dev,
 				   struct rte_eth_rss_conf *rss_conf);
 /**< @internal Get current RSS hash configuration of an Ethernet device */
 
+typedef int (*rss_hash_index_get_t)(struct rte_eth_dev *dev,
+				    uint32_t hash, uint32_t *hash_idx);
+/**< @internal Get RSS hash id of given hash value */
+
 typedef int (*eth_dev_led_on_t)(struct rte_eth_dev *dev);
 /**< @internal Turn on SW controllable LED on an Ethernet device */
 
@@ -471,6 +475,7 @@ struct eth_dev_ops {
 
 	rss_hash_update_t          rss_hash_update; /** Configure RSS hash protocols. */
 	rss_hash_conf_get_t        rss_hash_conf_get; /** Get current RSS hash configuration. */
+	rss_hash_index_get_t       rss_hash_index_get; /** Get RSS hash idx. */
 	reta_update_t              reta_update;   /** Update redirection table. */
 	reta_query_t               reta_query;    /** Query redirection table. */
 
diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map
index 6df42a4..ea6d1bf 100644
--- a/lib/librte_ethdev/rte_ethdev_version.map
+++ b/lib/librte_ethdev/rte_ethdev_version.map
@@ -283,4 +283,7 @@ EXPERIMENTAL {
 
 	# added in 19.08
 	rte_eth_read_clock;
+
+	# added in 19.11
+	rte_eth_dev_rss_hash_index_get;
 };
-- 
2.8.4


  reply	other threads:[~2019-09-14  5:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-14  5:52 [dpdk-dev] [PATCH v1 0/3] " vattunuru
2019-09-14  5:52 ` vattunuru [this message]
2019-10-03 13:00   ` [dpdk-dev] [PATCH v1 1/3] lib/ethdev: " Andrew Rybchenko
2019-10-07  4:45     ` [dpdk-dev] [EXT] " Vamsi Krishna Attunuru
2019-10-15  9:52   ` [dpdk-dev] [PATCH v2 0/3] " vattunuru
2019-10-15  9:52     ` [dpdk-dev] [PATCH v2 1/3] lib/ethdev: " vattunuru
2019-10-15 16:47       ` Ferruh Yigit
2019-10-15 17:28         ` Vamsi Krishna Attunuru
2019-10-16 17:47           ` Ferruh Yigit
2019-10-16 17:48       ` Ferruh Yigit
2019-10-15  9:52     ` [dpdk-dev] [PATCH v2 2/3] app/test: add hash index verify autotest vattunuru
2019-10-15 16:49       ` Ferruh Yigit
2019-10-15  9:52     ` [dpdk-dev] [PATCH v2 3/3] net/octeontx2: add eth dev op callback to get hash index vattunuru
2019-09-14  5:52 ` [dpdk-dev] [PATCH v1 2/3] app/test: add hash index verify autotest vattunuru
2019-09-14  5:52 ` [dpdk-dev] [PATCH v1 3/3] net/octeontx2: add eth dev op callback to get hash index vattunuru

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=20190914055247.3841-2-vattunuru@marvell.com \
    --to=vattunuru@marvell.com \
    --cc=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=jerinj@marvell.com \
    --cc=thomas@monjalon.net \
    /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).