From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DEB46A00C5; Tue, 4 Jan 2022 09:19:35 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0BFC941156; Tue, 4 Jan 2022 09:19:18 +0100 (CET) Received: from relay.smtp-ext.broadcom.com (relay.smtp-ext.broadcom.com [192.19.166.231]) by mails.dpdk.org (Postfix) with ESMTP id C6A5341156 for ; Tue, 4 Jan 2022 09:19:16 +0100 (CET) Received: from dhcp-10-123-153-22.dhcp.broadcom.net (bgccx-dev-host-lnx2.bec.broadcom.net [10.123.153.22]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id 255D4C0000F1; Tue, 4 Jan 2022 00:19:14 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 255D4C0000F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1641284356; bh=Lc8i/u7wj8KIuE9bjEMu38Tt9/FVygmPy5BR/q2RlhU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rEHGo1AYsgcCGvUKlCLCYe7zjgFZWTmOgrDFaJbvwfzoMrqeVOBmhI32niA7h+HRV QUj2NZw1YSSHalrwdc0cUjsOioNzq6eyeSgp23QFmbNp4Ipb45e1NHUemzeAE0XoAz OGlRferHwxq+SX1Z8iIIRr+KR5couB2YgFPZntcM= From: Kalesh A P To: dev@dpdk.org Cc: ferruh.yigit@intel.com, ajit.khaparde@broadcom.com Subject: [dpdk-dev] [PATCH 04/18] net/bnxt: restore RSS configuration after reset recovery Date: Tue, 4 Jan 2022 14:08:10 +0530 Message-Id: <20220104083824.23001-5-kalesh-anakkur.purayil@broadcom.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20220104083824.23001-1-kalesh-anakkur.purayil@broadcom.com> References: <20220104083824.23001-1-kalesh-anakkur.purayil@broadcom.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Kalesh AP 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") Cc: stable@dpdk.org Signed-off-by: Kalesh AP Reviewed-by: Ajit Khaparde Reviewed-by: Somnath Kotur --- 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 521fcb7..614ea57 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -896,6 +896,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 bac9600..dcf2839 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -368,7 +368,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; @@ -1067,6 +1067,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 = ð_dev->data->dev_conf.rx_adv_conf.rss_conf; int rc; bp->rx_queues = (void *)eth_dev->data->rx_queues; @@ -1141,6 +1142,17 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev) rx_offloads |= RTE_ETH_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; + bnxt_mtu_set_op(eth_dev, eth_dev->data->mtu); return 0; @@ -2126,9 +2138,6 @@ static int bnxt_rss_hash_update_op(struct rte_eth_dev *eth_dev, } bp->flags |= BNXT_FLAG_UPDATE_HASH; - memcpy(ð_dev->data->dev_conf.rx_adv_conf.rss_conf, - rss_conf, - sizeof(*rss_conf)); /* Update the default RSS VNIC(s) */ vnic = BNXT_GET_DEFAULT_VNIC(bp); @@ -2137,6 +2146,9 @@ static int bnxt_rss_hash_update_op(struct rte_eth_dev *eth_dev, bnxt_rte_to_hwrm_hash_level(bp, rss_conf->rss_hf, RTE_ETH_RSS_LEVEL(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 @@ -2152,6 +2164,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; @@ -5304,6 +5319,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; @@ -5950,6 +5975,8 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev) bnxt_free_error_recovery_info(bp); 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_ctx_mem(bp); diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c index c9d9903..9f1d1d4 100644 --- a/drivers/net/bnxt/bnxt_rxq.c +++ b/drivers/net/bnxt/bnxt_rxq.c @@ -148,7 +148,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 & RTE_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 e05dc24..09d67ef 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 af3a2dd..25481fc 100644 --- a/drivers/net/bnxt/bnxt_vnic.h +++ b/drivers/net/bnxt/bnxt_vnic.h @@ -60,7 +60,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