diff mbox series

[18/22] net/ena: move default RSS key to shared mem

Message ID 20210430125725.28796-19-mk@semihalf.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show
Series net/ena: update ENA PMD to v2.3.0 | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Michal Krawczyk April 30, 2021, 12:57 p.m. UTC
From: Stanislaw Kardach <kda@semihalf.com>

Make sure the same random generated RSS key is available to all ENA PMD
instances in all processes.

Signed-off-by: Stanislaw Kardach <kda@semihalf.com>
Reviewed-by: Michal Krawczyk <mk@semihalf.com>
Reviewed-by: Igor Chauskin <igorch@amazon.com>
Reviewed-by: Shay Agroskin <shayagr@amazon.com>
---
 drivers/net/ena/ena_ethdev.c | 16 +++++-----------
 drivers/net/ena/ena_ethdev.h |  1 +
 2 files changed, 6 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index 0780e2fee2..5c365e1ab5 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -276,19 +276,9 @@  static const struct eth_dev_ops ena_dev_ops = {
 
 void ena_rss_key_fill(void *key, size_t size)
 {
-	static bool key_generated;
-	static uint8_t default_key[ENA_HASH_KEY_SIZE];
-	size_t i;
-
 	RTE_ASSERT(size <= ENA_HASH_KEY_SIZE);
 
-	if (!key_generated) {
-		for (i = 0; i < ENA_HASH_KEY_SIZE; ++i)
-			default_key[i] = rte_rand() & 0xff;
-		key_generated = true;
-	}
-
-	rte_memcpy(key, default_key, size);
+	rte_memcpy(key, ena_shared_data->default_key, size);
 }
 
 static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf,
@@ -1758,7 +1748,11 @@  static uint32_t ena_calc_max_io_queue_num(struct ena_com_dev *ena_dev,
 
 static void ena_prepare_shared_data(struct ena_shared_data *shared_data)
 {
+	size_t i;
+
 	memset(shared_data, 0, sizeof(*shared_data));
+	for (i = 0; i < ENA_HASH_KEY_SIZE; ++i)
+		shared_data->default_key[i] = rte_rand() & 0xff;
 }
 
 static int ena_shared_data_init(void)
diff --git a/drivers/net/ena/ena_ethdev.h b/drivers/net/ena/ena_ethdev.h
index e8858c6118..1f7383dce0 100644
--- a/drivers/net/ena/ena_ethdev.h
+++ b/drivers/net/ena/ena_ethdev.h
@@ -209,6 +209,7 @@  struct ena_offloads {
 
 /* Holds data shared between all instances of ENA PMD. */
 struct ena_shared_data {
+	uint8_t default_key[ENA_HASH_KEY_SIZE];
 	/* Each rte_memzone should have unique name.
 	 * To satisfy it, count number of allocation and add it to name.
 	 */