Skip to contentSkip to conversation

add ethdev op to get hash index

PATCH Superseded [email protected] 3 participants 15 messages Sep 14, 2019 – Oct 16, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover add ethdev op to get hash index

From: Vamsi Attunuru <[email protected]>

***
Following patch set adds ethdev op to fetch hash index from ethdev pmd for a given hash value. It enables pmds to compute hash index using HW supported custom algos.

Patch set also adds autotest for these API to verify whether packet distribution is as per computed hash index or not.

Vamsi Attunuru (3):
lib/ethdev: add ethdev op to get hash index app/test: add hash index verify autotest net/octeontx2: add eth dev op callback to get hash index

 app/test/Makefile                        |   1 +
 app/test/autotest_data.py                |   6 +
 app/test/meson.build                     |   1 +
 app/test/test_hash_index.c               | 347 +++++++++++++++++++++++++++++++
 drivers/net/octeontx2/otx2_ethdev.c      |   1 +
 drivers/net/octeontx2/otx2_ethdev.h      |   3 +
 drivers/net/octeontx2/otx2_rss.c         |  18 ++
 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 +
 11 files changed, 418 insertions(+)
 create mode 100644 app/test/test_hash_index.c
Signature · 1 line
2.8.4
#1 lore raw

PATCH 1/3 lib/ethdev: add ethdev op to get hash index

From: Vamsi Attunuru <[email protected]>

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.

---
 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(+)
lib/librte_ethdev/rte_ethdev.c +13 -0
index 17d183e..6a234d6 100644
@@ -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)
 {
lib/librte_ethdev/rte_ethdev.h +20 -0
index dc6596b..03ca1e9 100644
@@ -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
lib/librte_ethdev/rte_ethdev_core.h +5 -0
index 2922d5b..aebfb5f 100644
@@ -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. */
 
lib/librte_ethdev/rte_ethdev_version.map +3 -0
index 6df42a4..ea6d1bf 100644
@@ -283,4 +283,7 @@ EXPERIMENTAL {
 
 	# added in 19.08
 	rte_eth_read_clock;
+
+	# added in 19.11
+	rte_eth_dev_rss_hash_index_get;
 };
Signature · 1 line
2.8.4
#2 lore raw

Re: [dpdk-dev] [PATCH v1 1/3] lib/ethdev: add ethdev op to get hash index

Hi,

Quoted 5 lines · On 9/14/19 8:52 AM, [email protected] wrote:

From: Vamsi Attunuru <[email protected]>

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

Quoted 8 lines

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.

I'm sorry, but the purpose of the API and provided functionality is unclear for me from above description.

#3 lore raw

Re: [dpdk-dev] [EXT] Re: [PATCH v1 1/3] lib/ethdev: add ethdev op to get hash index

Quoted 25 lines

-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Thursday, October 3, 2019 6:31 PM
To: Vamsi Krishna Attunuru <[email protected]>; [email protected]
Cc: Jerin Jacob Kollanukkaran <[email protected]>; [email protected]; [email protected]
Subject: [EXT] Re: [dpdk-dev] [PATCH v1 1/3] lib/ethdev: add ethdev op to get hash index

External Email

----------------------------------------------------------------------
Hi,

Quoted 8 lines · On 9/14/19 8:52 AM, [email protected] wrote:

From: Vamsi Attunuru <[email protected]>

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.

Quoted 8 lines
Quoted 5 lines

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.

I'm sorry, but the purpose of the API and provided functionality is unclear for me from above description.

@Andrew, Please see the below description, if it explains the patch clearly, will send v2.

" 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 in the initial packet on the given port.

Some of the applications compute hash index from the hash value received in the initial packet and than configure the rxq to lcore mapping to make sure the mapped lcore/rxq would receive the upcoming traffic that has similar hash. Such applications may use these API to get the hash index used by the PMD for spreading those traffic."

#4 lore raw

v2 cover add ethdev op to get hash index

In reply to [email protected]

From: Vamsi Attunuru <[email protected]>

---
Following patch set adds ethdev op to fetch hash index from ethdev pmd for a given hash value. It enables pmds to compute hash index using HW supported custom algos.

Patch set also adds autotest for these API to verify whether packet distribution is as per computed hash index or not.

V2 Change:
* Updated description in the commit message.

Vamsi Attunuru (3):
lib/ethdev: add ethdev op to get hash index app/test: add hash index verify autotest net/octeontx2: add eth dev op callback to get hash index

 app/test/Makefile                        |   1 +
 app/test/autotest_data.py                |   6 +
 app/test/meson.build                     |   1 +
 app/test/test_hash_index.c               | 347 +++++++++++++++++++++++++++++++
 drivers/net/octeontx2/otx2_ethdev.c      |   1 +
 drivers/net/octeontx2/otx2_ethdev.h      |   3 +
 drivers/net/octeontx2/otx2_rss.c         |  18 ++
 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 +
 11 files changed, 418 insertions(+)
 create mode 100644 app/test/test_hash_index.c
Signature · 1 line
2.8.4
#5 lore raw

PATCH v2 1/3 lib/ethdev: add ethdev op to get hash index

From: Vamsi Attunuru <[email protected]>

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

Patch adds an eth_dev op to get the hash index correspond to the given hash value received in the initial packet on the given port.

Some of the applications compute hash index from the hash value received in the initial packet and than configure the rxq to lcore mapping to make sure the mapped lcore/rxq would receive the upcoming traffic that has similar hash. Such applications may use these API to get the hash index used by the PMD for spreading those traffic.

---
 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(+)
lib/librte_ethdev/rte_ethdev.c +13 -0
index af82360..ed02168 100644
@@ -3140,6 +3140,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)
 {
lib/librte_ethdev/rte_ethdev.h +20 -0
index d937fb4..8198130 100644
@@ -3306,6 +3306,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
lib/librte_ethdev/rte_ethdev_core.h +5 -0
index dcb5ae6..ad6cdc5 100644
@@ -364,6 +364,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 */
 
@@ -595,6 +599,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. */
 
lib/librte_ethdev/rte_ethdev_version.map +3 -0
index 6df42a4..ea6d1bf 100644
@@ -283,4 +283,7 @@ EXPERIMENTAL {
 
 	# added in 19.08
 	rte_eth_read_clock;
+
+	# added in 19.11
+	rte_eth_dev_rss_hash_index_get;
 };
Signature · 1 line
2.8.4
#6 lore raw

Re: [dpdk-dev] [PATCH v2 1/3] lib/ethdev: add ethdev op to get hash index

Quoted 9 lines · On 10/15/2019 10:52 AM, [email protected] wrote:

From: Vamsi Attunuru <[email protected]>

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

Patch adds an eth_dev op to get the hash index correspond to the given hash value received in the initial packet on the given port.

Quoted 6 lines

Some of the applications compute hash index from the hash value received in the initial packet and than configure the rxq to lcore mapping to make sure the mapped lcore/rxq would receive the upcoming traffic that has similar hash. Such applications may use these API to get the hash index used by the PMD for spreading those traffic.

Hi Vamsi,

Can you please describe this usecase?
If the application is receiving the packet, it already knows which queue it is coming from, what is the benefit of the getting hash index?

The concern is adding a new API which is specific to a use case and HW and won't be used in long term. That will only create technical dept for us.

Quoted 2 lines

<...>

#7 lore raw

Re: [dpdk-dev] [PATCH v2 1/3] lib/ethdev: add ethdev op to get hash index

Quoted 27 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Ferruh Yigit
Sent: Tuesday, October 15, 2019 10:17 PM
To: Vamsi Krishna Attunuru <[email protected]>; [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2 1/3] lib/ethdev: add ethdev op to get hash index

Quoted 8 lines · On 10/15/2019 10:52 AM, [email protected] wrote:

From: Vamsi Attunuru <[email protected]>

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

Patch adds an eth_dev op to get the hash index correspond to the given hash value received in the initial packet on the given port.

Quoted 6 lines

Some of the applications compute hash index from the hash value received in the initial packet and than configure the rxq to lcore mapping to make sure the mapped lcore/rxq would receive the upcoming traffic that has similar hash.
Such applications may use these API to get the hash index used by the PMD for spreading those traffic.

Quoted 5 lines

Hi Vamsi,

Can you please describe this usecase?
If the application is receiving the packet, it already knows which queue it is coming from, what is the benefit of the getting hash index?

Hi Ferruh,

I think the commit msg is incomplete and did not explain the use case clearly, my apologies.
Actual usecase is when application precalculates the hash value using some hashlib for a specific type of packet headers with the same hash key that's configured in the HW, application would compute hash_index as hash % reta_size and predict the packets on the computed queue index. But these hash_index computation might be different from PMD/HW computed index(based it's algo design). To fix those disparity, these API been introduced which can be used during configuration time to have required lcore-rq mapping.

Quoted 8 lines

The concern is adding a new API which is specific to a use case and HW and won't be used in long term. That will only create technical dept for us.

Quoted 2 lines

<...>

#8 lore raw

Re: [dpdk-dev] [PATCH v2 1/3] lib/ethdev: add ethdev op to get hash index

Quoted 33 lines · Vamsi Krishna Attunuru
Quoted 27 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Ferruh Yigit
Sent: Tuesday, October 15, 2019 10:17 PM
To: Vamsi Krishna Attunuru <[email protected]>; [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2 1/3] lib/ethdev: add ethdev op to get hash index

Quoted 8 lines · On 10/15/2019 10:52 AM, [email protected] wrote:

From: Vamsi Attunuru <[email protected]>

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

Patch adds an eth_dev op to get the hash index correspond to the given hash value received in the initial packet on the given port.

Quoted 6 lines

Some of the applications compute hash index from the hash value received in the initial packet and than configure the rxq to lcore mapping to make sure the mapped lcore/rxq would receive the upcoming traffic that has similar hash.
Such applications may use these API to get the hash index used by the PMD for spreading those traffic.

Quoted 5 lines

Hi Vamsi,

Can you please describe this usecase?
If the application is receiving the packet, it already knows which queue it is coming from, what is the benefit of the getting hash index?

Quoted 5 lines

Hi Ferruh,

I think the commit msg is incomplete and did not explain the use case clearly, my apologies.
Actual usecase is when application precalculates the hash value using some hashlib for a specific type of packet headers with the same hash key that's configured in the HW, application would compute hash_index as hash % reta_size and predict the packets on the computed queue index. But these hash_index computation might be different from PMD/HW computed index(based it's algo design). To fix those disparity, these API been introduced which can be used during configuration time to have required lcore-rq mapping.

Does application tries to predict in which queue a specific flow will land? And configure RETA table OR do the lcore-queue mapping accordingly?

Not sure if other PMDs need this too but API seems trivial and it doesn't affect existing code, so no objection from my end for the API. Can you please check the unit test comments?

Quoted 11 lines
Quoted 10 lines

The concern is adding a new API which is specific to a use case and HW and won't be used in long term. That will only create technical dept for us.

Quoted 2 lines

<...>

#9 lore raw

Re: [dpdk-dev] [PATCH v2 1/3] lib/ethdev: add ethdev op to get hash index

In reply to [email protected]
Quoted 17 lines · On 10/15/2019 10:52 AM, [email protected] wrote:

From: Vamsi Attunuru <[email protected]>

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

Patch adds an eth_dev op to get the hash index correspond to the given hash value received in the initial packet on the given port.

Some of the applications compute hash index from the hash value received in the initial packet and than configure the rxq to lcore mapping to make sure the mapped lcore/rxq would receive the upcoming traffic that has similar hash. Such applications may use these API to get the hash index used by the PMD for spreading those traffic.

<...>

lib/librte_ethdev/rte_ethdev_core.h typedef int (*rss_hash_conf_get_t)(struct rte_eth_dev *dev, · line 369

Quoted 7 lines
lib/librte_ethdev/rte_ethdev_core.h +3 -0
@@ -364,6 +364,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 */

s/hash id/hash index/ ?

#10 lore raw

PATCH v2 2/3 app/test: add hash index verify autotest

In reply to [email protected]

From: Vamsi Attunuru <[email protected]>

Patch adds a autotest to validate rte_eth_dev_rss_hash_index_get() ethdev op.

Test configures the ethport in loopback mode and enables RSS for IP packets. The hash indices returned by those API gets validated by matching queue number in the reta table with the rxq(queue's idx) on which the packet received.

---
 app/test/Makefile          |   1 +
 app/test/autotest_data.py  |   6 +
 app/test/meson.build       |   1 +
 app/test/test_hash_index.c | 347 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 355 insertions(+)
app/test/Makefile +1 -0
index df7f77f..8674cfe 100644
@@ -79,6 +79,7 @@ SRCS-y += test_rand_perf.c
 SRCS-y += test_ring.c
 SRCS-y += test_ring_perf.c
 SRCS-y += test_pmd_perf.c
+SRCS-y += test_hash_index.c
 
 ifeq ($(CONFIG_RTE_LIBRTE_TABLE),y)
 SRCS-y += test_table.c
app/test/autotest_data.py +6 -0
index 7405149..fef76d0 100644
@@ -653,6 +653,12 @@
         "Report":  None,
     },
     {
+        "Name":    "Hash index verify autotest",
+        "Command": "hash_index_verify_autotest",
+        "Func":    default_autotest,
+        "Report":  None,
+    },
+    {
         "Name":    "Ring pmd perf autotest",
         "Command": "ring_pmd_perf_autotest",
         "Func":    default_autotest,
app/test/meson.build +1 -0
index 2c23c63..8eefe5e 100644
@@ -85,6 +85,7 @@ test_sources = files('commands.c',
 	'test_mp_secondary.c',
 	'test_pdump.c',
 	'test_per_lcore.c',
+	'test_hash_index.c',
 	'test_pmd_perf.c',
 	'test_pmd_ring.c',
 	'test_pmd_ring_perf.c',
app/test/test_hash_index.c new file +347 -0

347 lines not on this page · raw message

Signature · 1 line
2.8.4
#11 lore raw

Re: [dpdk-dev] [PATCH v2 2/3] app/test: add hash index verify autotest

Quoted 9 lines · On 10/15/2019 10:52 AM, [email protected] wrote:

From: Vamsi Attunuru <[email protected]>

Patch adds a autotest to validate rte_eth_dev_rss_hash_index_get() ethdev op.

Test configures the ethport in loopback mode and enables RSS for IP packets. The hash indices returned by those API gets validated by matching queue number in the reta table with the rxq(queue's idx) on which the packet received.

As I said implementation is not major concern, so please wait until ethdev API discussion resolved before modifying but unit test failing me for i40e because of:
1) RSS hash function selected without checking what device is capable of, so configuration fails.

2) rte_eth_dev_rss_reta_update() failed because of provided incompatible size

Thanks,
ferruh

Quoted 2 lines

<...>

#12 lore raw

PATCH v2 3/3 net/octeontx2: add eth dev op callback to get hash index

In reply to [email protected]

From: Vamsi Attunuru <[email protected]>

patch adds pmd support for hash_index_get() ethdev_op callback.

---
 drivers/net/octeontx2/otx2_ethdev.c |  1 +
 drivers/net/octeontx2/otx2_ethdev.h |  3 +++
 drivers/net/octeontx2/otx2_rss.c    | 18 ++++++++++++++++++
 3 files changed, 22 insertions(+)
drivers/net/octeontx2/otx2_ethdev.c +1 -0
index 4a60f9f..eb41ba4 100644
@@ -1961,6 +1961,7 @@ static const struct eth_dev_ops otx2_eth_dev_ops = {
 	.reta_query               = otx2_nix_dev_reta_query,
 	.rss_hash_update          = otx2_nix_rss_hash_update,
 	.rss_hash_conf_get        = otx2_nix_rss_hash_conf_get,
+	.rss_hash_index_get       = otx2_nix_rss_hash_index_get,
 	.xstats_get               = otx2_nix_xstats_get,
 	.xstats_get_names         = otx2_nix_xstats_get_names,
 	.xstats_reset             = otx2_nix_xstats_reset,
drivers/net/octeontx2/otx2_ethdev.h +3 -0
index 33fa0c6..b410988 100644
@@ -471,6 +471,9 @@ int otx2_nix_rss_hash_update(struct rte_eth_dev *eth_dev,
 int otx2_nix_rss_hash_conf_get(struct rte_eth_dev *eth_dev,
 			       struct rte_eth_rss_conf *rss_conf);
 
+int otx2_nix_rss_hash_index_get(struct rte_eth_dev *eth_dev,
+				uint32_t hash, uint32_t *hash_idx);
+
 /* CGX */
 int otx2_cgx_rxtx_start(struct otx2_eth_dev *dev);
 int otx2_cgx_rxtx_stop(struct otx2_eth_dev *dev);
drivers/net/octeontx2/otx2_rss.c +18 -0
index 5afa214..4b40dfd 100644
@@ -328,6 +328,24 @@ otx2_nix_rss_hash_conf_get(struct rte_eth_dev *eth_dev,
 }
 
 int
+otx2_nix_rss_hash_index_get(struct rte_eth_dev *eth_dev,
+			    uint32_t hash, uint32_t *hash_idx)
+{
+	struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
+	union flow_tag {
+		uint32_t hash;
+		uint8_t byte[4];
+	} tag;
+
+	tag.hash = hash;
+
+	*hash_idx = (tag.byte[0] ^ tag.byte[1] ^ tag.byte[2] ^ tag.byte[3]) %
+			dev->rss_info.rss_size;
+
+	return 0;
+}
+
+int
 otx2_nix_rss_config(struct rte_eth_dev *eth_dev)
 {
 	struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
Signature · 1 line
2.8.4
#13 lore raw

PATCH 2/3 app/test: add hash index verify autotest

In reply to [email protected]

From: Vamsi Attunuru <[email protected]>

Patch adds a autotest to validate rte_eth_dev_rss_hash_index_get() ethdev op.

Test configures the ethport in loopback mode and enables RSS for IP packets. The hash indices returned by those API gets validated by matching queue number in the reta table with the rxq(queue's idx) on which the packet received.

---
 app/test/Makefile          |   1 +
 app/test/autotest_data.py  |   6 +
 app/test/meson.build       |   1 +
 app/test/test_hash_index.c | 347 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 355 insertions(+)
app/test/Makefile +1 -0
index 26ba6fe..04ff705 100644
@@ -79,6 +79,7 @@ SRCS-y += test_rand_perf.c
 SRCS-y += test_ring.c
 SRCS-y += test_ring_perf.c
 SRCS-y += test_pmd_perf.c
+SRCS-y += test_hash_index.c
 
 ifeq ($(CONFIG_RTE_LIBRTE_TABLE),y)
 SRCS-y += test_table.c
app/test/autotest_data.py +6 -0
index 7405149..fef76d0 100644
@@ -653,6 +653,12 @@
         "Report":  None,
     },
     {
+        "Name":    "Hash index verify autotest",
+        "Command": "hash_index_verify_autotest",
+        "Func":    default_autotest,
+        "Report":  None,
+    },
+    {
         "Name":    "Ring pmd perf autotest",
         "Command": "ring_pmd_perf_autotest",
         "Func":    default_autotest,
app/test/meson.build +1 -0
index ec40943..3da13231 100644
@@ -84,6 +84,7 @@ test_sources = files('commands.c',
 	'test_mp_secondary.c',
 	'test_pdump.c',
 	'test_per_lcore.c',
+	'test_hash_index.c',
 	'test_pmd_perf.c',
 	'test_pmd_ring.c',
 	'test_pmd_ring_perf.c',
app/test/test_hash_index.c new file +347 -0

347 lines not on this page · raw message

Signature · 1 line
2.8.4
#14 lore raw

PATCH 3/3 net/octeontx2: add eth dev op callback to get hash index

In reply to [email protected]

From: Vamsi Attunuru <[email protected]>

patch adds pmd support for hash_index_get() ethdev_op callback.

---
 drivers/net/octeontx2/otx2_ethdev.c |  1 +
 drivers/net/octeontx2/otx2_ethdev.h |  3 +++
 drivers/net/octeontx2/otx2_rss.c    | 18 ++++++++++++++++++
 3 files changed, 22 insertions(+)
drivers/net/octeontx2/otx2_ethdev.c +1 -0
index b84128f..bfca60c 100644
@@ -1636,6 +1636,7 @@ static const struct eth_dev_ops otx2_eth_dev_ops = {
 	.reta_query               = otx2_nix_dev_reta_query,
 	.rss_hash_update          = otx2_nix_rss_hash_update,
 	.rss_hash_conf_get        = otx2_nix_rss_hash_conf_get,
+	.rss_hash_index_get       = otx2_nix_rss_hash_index_get,
 	.xstats_get               = otx2_nix_xstats_get,
 	.xstats_get_names         = otx2_nix_xstats_get_names,
 	.xstats_reset             = otx2_nix_xstats_reset,
drivers/net/octeontx2/otx2_ethdev.h +3 -0
index 7b15d6b..6ea5974 100644
@@ -465,6 +465,9 @@ int otx2_nix_rss_hash_update(struct rte_eth_dev *eth_dev,
 int otx2_nix_rss_hash_conf_get(struct rte_eth_dev *eth_dev,
 			       struct rte_eth_rss_conf *rss_conf);
 
+int otx2_nix_rss_hash_index_get(struct rte_eth_dev *eth_dev,
+				uint32_t hash, uint32_t *hash_idx);
+
 /* CGX */
 int otx2_cgx_rxtx_start(struct otx2_eth_dev *dev);
 int otx2_cgx_rxtx_stop(struct otx2_eth_dev *dev);
drivers/net/octeontx2/otx2_rss.c +18 -0
index 5afa214..4b40dfd 100644
@@ -328,6 +328,24 @@ otx2_nix_rss_hash_conf_get(struct rte_eth_dev *eth_dev,
 }
 
 int
+otx2_nix_rss_hash_index_get(struct rte_eth_dev *eth_dev,
+			    uint32_t hash, uint32_t *hash_idx)
+{
+	struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
+	union flow_tag {
+		uint32_t hash;
+		uint8_t byte[4];
+	} tag;
+
+	tag.hash = hash;
+
+	*hash_idx = (tag.byte[0] ^ tag.byte[1] ^ tag.byte[2] ^ tag.byte[3]) %
+			dev->rss_info.rss_size;
+
+	return 0;
+}
+
+int
 otx2_nix_rss_config(struct rte_eth_dev *eth_dev)
 {
 	struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
Signature · 1 line
2.8.4