patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Kalesh A P <kalesh-anakkur.purayil@broadcom.com>
To: stable@dpdk.org
Cc: christian.ehrhardt@canonical.com, ajit.khaparde@broadcom.com
Subject: [PATCH 19.11 4/8] net/bnxt: restore RSS configuration after reset recovery
Date: Mon,  7 Mar 2022 20:40:32 +0530	[thread overview]
Message-ID: <20220307151036.7116-5-kalesh-anakkur.purayil@broadcom.com> (raw)
In-Reply-To: <20220307151036.7116-1-kalesh-anakkur.purayil@broadcom.com>

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

[ upstream commit 9b4353bec3d17d241e511f7d6917417fd395c462 ]

During reset recovery, driver is not restoring the VNIC rss hash key.
It's generating a new random hash key which results in unexpected
RSS behavior after recovery. Fixed this by storing the VNIC RSS
configuration to a local struct and then applying the cached value
during the recovery.

Fixes: df6cd7c1f73a ("net/bnxt: handle reset notify async event from FW")

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 drivers/net/bnxt/bnxt.h        |  2 ++
 drivers/net/bnxt/bnxt_ethdev.c | 35 +++++++++++++++++++++++++++++++----
 drivers/net/bnxt/bnxt_rxq.c    |  2 +-
 drivers/net/bnxt/bnxt_vnic.c   |  9 +++++++--
 drivers/net/bnxt/bnxt_vnic.h   |  2 +-
 5 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 31cc60a..bd83005 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -715,6 +715,8 @@ struct bnxt {
 	struct rte_ether_addr	*mcast_addr_list;
 	rte_iova_t		mc_list_dma_addr;
 	uint32_t		nb_mc_addr;
+
+	struct rte_eth_rss_conf	rss_conf; /* RSS configuration. */
 };
 
 static
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 6bd072e..f52ef2b 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -209,7 +209,7 @@ static int bnxt_alloc_mem(struct bnxt *bp, bool reconfig)
 	if (rc)
 		goto alloc_mem_err;
 
-	rc = bnxt_alloc_vnic_attributes(bp);
+	rc = bnxt_alloc_vnic_attributes(bp, reconfig);
 	if (rc)
 		goto alloc_mem_err;
 
@@ -657,6 +657,7 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt *bp = eth_dev->data->dev_private;
 	uint64_t rx_offloads = eth_dev->data->dev_conf.rxmode.offloads;
+	struct rte_eth_rss_conf *rss_conf = &eth_dev->data->dev_conf.rx_adv_conf.rss_conf;
 	int rc;
 
 	bp->rx_queues = (void *)eth_dev->data->rx_queues;
@@ -738,6 +739,17 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
 		rx_offloads |= DEV_RX_OFFLOAD_RSS_HASH;
 	eth_dev->data->dev_conf.rxmode.offloads = rx_offloads;
 
+	/* application provides the hash key to program */
+	if (rss_conf->rss_key != NULL) {
+		if (rss_conf->rss_key_len != HW_HASH_KEY_SIZE)
+			PMD_DRV_LOG(WARNING, "port %u RSS key len must be %d bytes long",
+				    eth_dev->data->port_id, HW_HASH_KEY_SIZE);
+		else
+			memcpy(bp->rss_conf.rss_key, rss_conf->rss_key, HW_HASH_KEY_SIZE);
+	}
+	bp->rss_conf.rss_key_len = HW_HASH_KEY_SIZE;
+	bp->rss_conf.rss_hf = rss_conf->rss_hf;
+
 	if (rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
 		eth_dev->data->mtu =
 			eth_dev->data->dev_conf.rxmode.max_rx_pkt_len -
@@ -1575,14 +1587,14 @@ static int bnxt_rss_hash_update_op(struct rte_eth_dev *eth_dev,
 	}
 
 	bp->flags |= BNXT_FLAG_UPDATE_HASH;
-	memcpy(&eth_dev->data->dev_conf.rx_adv_conf.rss_conf,
-	       rss_conf,
-	       sizeof(*rss_conf));
 
 	/* Update the default RSS VNIC(s) */
 	vnic = &bp->vnic_info[0];
 	vnic->hash_type = bnxt_rte_to_hwrm_hash_types(rss_conf->rss_hf);
 
+	/* Cache the hash function */
+	bp->rss_conf.rss_hf = rss_conf->rss_hf;
+
 	/*
 	 * If hashkey is not specified, use the previously configured
 	 * hashkey
@@ -1598,6 +1610,9 @@ static int bnxt_rss_hash_update_op(struct rte_eth_dev *eth_dev,
 	}
 	memcpy(vnic->rss_hash_key, rss_conf->rss_key, rss_conf->rss_key_len);
 
+	/* Cache the hash key */
+	memcpy(bp->rss_conf.rss_key, rss_conf->rss_key, HW_HASH_KEY_SIZE);
+
 rss_config:
 	rc = bnxt_hwrm_vnic_rss_cfg(bp, vnic);
 	return rc;
@@ -5146,6 +5161,16 @@ static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev)
 		}
 	}
 
+	if (!reconfig_dev) {
+		bp->rss_conf.rss_key = rte_zmalloc("bnxt_rss_key",
+						   HW_HASH_KEY_SIZE, 0);
+		if (bp->rss_conf.rss_key == NULL) {
+			PMD_DRV_LOG(ERR, "port %u cannot allocate RSS hash key memory",
+				    bp->eth_dev->data->port_id);
+			return -ENOMEM;
+		}
+	}
+
 	rc = bnxt_alloc_mem(bp, reconfig_dev);
 	if (rc)
 		return rc;
@@ -5265,6 +5290,8 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev)
 		}
 		rte_free(bp->mcast_addr_list);
 		bp->mcast_addr_list = NULL;
+		rte_free(bp->rss_conf.rss_key);
+		bp->rss_conf.rss_key = NULL;
 	}
 
 	bnxt_uninit_locks(bp);
diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c
index b0ab3df..993219a 100644
--- a/drivers/net/bnxt/bnxt_rxq.c
+++ b/drivers/net/bnxt/bnxt_rxq.c
@@ -137,7 +137,7 @@ int bnxt_mq_rx_configure(struct bnxt *bp)
 	bp->rx_num_qs_per_vnic = nb_q_per_grp;
 
 	if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG) {
-		struct rte_eth_rss_conf *rss = &dev_conf->rx_adv_conf.rss_conf;
+		struct rte_eth_rss_conf *rss = &bp->rss_conf;
 
 		if (bp->flags & BNXT_FLAG_UPDATE_HASH)
 			bp->flags &= ~BNXT_FLAG_UPDATE_HASH;
diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c
index 8a35f7f..9bcf385 100644
--- a/drivers/net/bnxt/bnxt_vnic.c
+++ b/drivers/net/bnxt/bnxt_vnic.c
@@ -114,7 +114,7 @@ void bnxt_free_vnic_attributes(struct bnxt *bp)
 	}
 }
 
-int bnxt_alloc_vnic_attributes(struct bnxt *bp)
+int bnxt_alloc_vnic_attributes(struct bnxt *bp, bool reconfig)
 {
 	struct bnxt_vnic_info *vnic;
 	struct rte_pci_device *pdev = bp->pdev;
@@ -168,7 +168,12 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp)
 
 		vnic->rss_hash_key_dma_addr = vnic->rss_table_dma_addr +
 					      rss_table_size;
-		bnxt_prandom_bytes(vnic->rss_hash_key, HW_HASH_KEY_SIZE);
+		if (!reconfig) {
+			bnxt_prandom_bytes(vnic->rss_hash_key, HW_HASH_KEY_SIZE);
+			memcpy(bp->rss_conf.rss_key, vnic->rss_hash_key, HW_HASH_KEY_SIZE);
+		} else {
+			memcpy(vnic->rss_hash_key, bp->rss_conf.rss_key, HW_HASH_KEY_SIZE);
+		}
 	}
 
 	return 0;
diff --git a/drivers/net/bnxt/bnxt_vnic.h b/drivers/net/bnxt/bnxt_vnic.h
index 80df2c5..a9818b1 100644
--- a/drivers/net/bnxt/bnxt_vnic.h
+++ b/drivers/net/bnxt/bnxt_vnic.h
@@ -57,7 +57,7 @@ int bnxt_free_vnic(struct bnxt *bp, struct bnxt_vnic_info *vnic,
 struct bnxt_vnic_info *bnxt_alloc_vnic(struct bnxt *bp);
 void bnxt_free_all_vnics(struct bnxt *bp);
 void bnxt_free_vnic_attributes(struct bnxt *bp);
-int bnxt_alloc_vnic_attributes(struct bnxt *bp);
+int bnxt_alloc_vnic_attributes(struct bnxt *bp, bool reconfig);
 void bnxt_free_vnic_mem(struct bnxt *bp);
 int bnxt_alloc_vnic_mem(struct bnxt *bp);
 int bnxt_vnic_grp_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic);
-- 
2.10.1


  parent reply	other threads:[~2022-03-07 15:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-07 15:10 [PATCH 19.11 0/8] bnxt fixes backport to 19.11 Kalesh A P
2022-03-07 15:10 ` [PATCH 19.11 1/8] net/bnxt: fix queue stop operation Kalesh A P
2022-03-07 15:10 ` [PATCH 19.11 2/8] net/bnxt: cap maximum number of unicast MAC addresses Kalesh A P
2022-03-07 15:10 ` [PATCH 19.11 3/8] net/bnxt: fix multicast address set Kalesh A P
2022-03-07 15:10 ` Kalesh A P [this message]
2022-03-07 15:10 ` [PATCH 19.11 5/8] net/bnxt: fix memzone allocation per VNIC Kalesh A P
2022-03-07 15:10 ` [PATCH 19.11 6/8] net/bnxt: fix handling of VF configuration change Kalesh A P
2022-03-07 15:10 ` [PATCH 19.11 7/8] net/bnxt: get maximum supported multicast filters count Kalesh A P
2022-03-07 15:10 ` [PATCH 19.11 8/8] net/bnxt: fix xstats names query overrun Kalesh A P
2022-03-09  8:02 ` [PATCH 19.11 0/8] bnxt fixes backport to 19.11 Christian Ehrhardt

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=20220307151036.7116-5-kalesh-anakkur.purayil@broadcom.com \
    --to=kalesh-anakkur.purayil@broadcom.com \
    --cc=ajit.khaparde@broadcom.com \
    --cc=christian.ehrhardt@canonical.com \
    --cc=stable@dpdk.org \
    /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).