Blame SOURCES/0063-netdrv-bnxt_en-Prepare-bnxt_init_one-to-be-called-mu.patch

f95c89
From 3b43bc011b31d52e3923a4eac7951a8b4e528acb Mon Sep 17 00:00:00 2001
f95c89
From: Jonathan Toppins <jtoppins@redhat.com>
f95c89
Date: Wed, 2 Oct 2019 18:23:18 -0400
f95c89
Subject: [PATCH 63/96] [netdrv] bnxt_en: Prepare bnxt_init_one() to be called
f95c89
 multiple times
f95c89
f95c89
Message-id: <1d65105ec743b3e52499fccd91176b5b117cf449.1570027456.git.jtoppins@redhat.com>
f95c89
Patchwork-id: 276482
f95c89
O-Subject: [RHEL-8.2 PATCH 56/78] bnxt_en: Prepare bnxt_init_one() to be called multiple times.
f95c89
Bugzilla: 1724766
f95c89
RH-Acked-by: John Linville <linville@redhat.com>
f95c89
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
f95c89
f95c89
In preparation for the new firmware reset feature, some of the logic
f95c89
in bnxt_init_one() and related functions will be called again after
f95c89
firmware has reset.  Reset some of the flags and capabilities so that
f95c89
everything that can change can be re-initialized.  Refactor some
f95c89
functions to probe firmware versions and capabilities.  Check some
f95c89
buffers before allocating as they may have been allocated previously.
f95c89
f95c89
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
f95c89
Signed-off-by: David S. Miller <davem@davemloft.net>
f95c89
(cherry picked from commit ba642ab773db97c32293547485f562d2dfc06666)
f95c89
Bugzilla: 1724766
f95c89
Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=23809532
f95c89
Tested: build, boot, basic ping
f95c89
Signed-off-by: Jonathan Toppins <jtoppins@redhat.com>
f95c89
Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
f95c89
---
f95c89
 drivers/net/ethernet/broadcom/bnxt/bnxt.c         | 126 +++++++++++++++-------
f95c89
 drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c     |   2 +
f95c89
 drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c |   5 +-
f95c89
 3 files changed, 93 insertions(+), 40 deletions(-)
f95c89
f95c89
Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt.c
f95c89
===================================================================
f95c89
--- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt.c	2020-02-06 16:23:18.605486578 +0100
f95c89
+++ src/drivers/net/ethernet/broadcom/bnxt/bnxt.c	2020-02-06 16:23:18.730485431 +0100
f95c89
@@ -3560,6 +3560,9 @@
f95c89
 {
f95c89
 	struct pci_dev *pdev = bp->pdev;
f95c89
 
f95c89
+	if (bp->hwrm_cmd_kong_resp_addr)
f95c89
+		return 0;
f95c89
+
f95c89
 	bp->hwrm_cmd_kong_resp_addr =
f95c89
 		dma_alloc_coherent(&pdev->dev, PAGE_SIZE,
f95c89
 				   &bp->hwrm_cmd_kong_resp_dma_addr,
f95c89
@@ -3599,6 +3602,9 @@
f95c89
 {
f95c89
 	struct pci_dev *pdev = bp->pdev;
f95c89
 
f95c89
+	if (bp->hwrm_short_cmd_req_addr)
f95c89
+		return 0;
f95c89
+
f95c89
 	bp->hwrm_short_cmd_req_addr =
f95c89
 		dma_alloc_coherent(&pdev->dev, bp->hwrm_max_ext_req_len,
f95c89
 				   &bp->hwrm_short_cmd_req_dma_addr,
f95c89
@@ -5022,6 +5028,7 @@
f95c89
 	int rc;
f95c89
 
f95c89
 	bp->hw_ring_stats_size = sizeof(struct ctx_hw_stats);
f95c89
+	bp->flags &= ~(BNXT_FLAG_NEW_RSS_CAP | BNXT_FLAG_ROCE_MIRROR_CAP);
f95c89
 	if (bp->hwrm_spec_code < 0x10600)
f95c89
 		return 0;
f95c89
 
f95c89
@@ -6876,6 +6883,7 @@
f95c89
 		pf->max_tx_wm_flows = le32_to_cpu(resp->max_tx_wm_flows);
f95c89
 		pf->max_rx_em_flows = le32_to_cpu(resp->max_rx_em_flows);
f95c89
 		pf->max_rx_wm_flows = le32_to_cpu(resp->max_rx_wm_flows);
f95c89
+		bp->flags &= ~BNXT_FLAG_WOL_CAP;
f95c89
 		if (flags & FUNC_QCAPS_RESP_FLAGS_WOL_MAGICPKT_SUPPORTED)
f95c89
 			bp->flags |= BNXT_FLAG_WOL_CAP;
f95c89
 	} else {
f95c89
@@ -7004,20 +7012,30 @@
f95c89
 	return rc;
f95c89
 }
f95c89
 
f95c89
-static int bnxt_hwrm_ver_get(struct bnxt *bp)
f95c89
+static int __bnxt_hwrm_ver_get(struct bnxt *bp, bool silent)
f95c89
 {
f95c89
-	int rc;
f95c89
 	struct hwrm_ver_get_input req = {0};
f95c89
-	struct hwrm_ver_get_output *resp = bp->hwrm_cmd_resp_addr;
f95c89
-	u32 dev_caps_cfg;
f95c89
+	int rc;
f95c89
 
f95c89
-	bp->hwrm_max_req_len = HWRM_MAX_REQ_LEN;
f95c89
 	bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_VER_GET, -1, -1);
f95c89
 	req.hwrm_intf_maj = HWRM_VERSION_MAJOR;
f95c89
 	req.hwrm_intf_min = HWRM_VERSION_MINOR;
f95c89
 	req.hwrm_intf_upd = HWRM_VERSION_UPDATE;
f95c89
+
f95c89
+	rc = bnxt_hwrm_do_send_msg(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT,
f95c89
+				   silent);
f95c89
+	return rc;
f95c89
+}
f95c89
+
f95c89
+static int bnxt_hwrm_ver_get(struct bnxt *bp)
f95c89
+{
f95c89
+	struct hwrm_ver_get_output *resp = bp->hwrm_cmd_resp_addr;
f95c89
+	u32 dev_caps_cfg;
f95c89
+	int rc;
f95c89
+
f95c89
+	bp->hwrm_max_req_len = HWRM_MAX_REQ_LEN;
f95c89
 	mutex_lock(&bp->hwrm_cmd_lock);
f95c89
-	rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
f95c89
+	rc = __bnxt_hwrm_ver_get(bp, false);
f95c89
 	if (rc)
f95c89
 		goto hwrm_ver_get_exit;
f95c89
 
f95c89
@@ -8186,6 +8204,9 @@
f95c89
 	struct hwrm_port_phy_qcaps_output *resp = bp->hwrm_cmd_resp_addr;
f95c89
 	struct bnxt_link_info *link_info = &bp->link_info;
f95c89
 
f95c89
+	bp->flags &= ~BNXT_FLAG_EEE_CAP;
f95c89
+	if (bp->test_info)
f95c89
+		bp->test_info->flags &= ~BNXT_TEST_FL_EXT_LPBK;
f95c89
 	if (bp->hwrm_spec_code < 0x10201)
f95c89
 		return 0;
f95c89
 
f95c89
@@ -8551,6 +8572,7 @@
f95c89
 	struct bnxt_pf_info *pf = &bp->pf;
f95c89
 	int rc;
f95c89
 
f95c89
+	bp->num_leds = 0;
f95c89
 	if (BNXT_VF(bp) || bp->hwrm_spec_code < 0x10601)
f95c89
 		return 0;
f95c89
 
f95c89
@@ -8645,6 +8667,7 @@
f95c89
 {
f95c89
 	u16 handle = 0;
f95c89
 
f95c89
+	bp->wol = 0;
f95c89
 	if (!BNXT_PF(bp) || !(bp->flags & BNXT_FLAG_WOL_CAP))
f95c89
 		return;
f95c89
 
f95c89
@@ -8691,6 +8714,9 @@
f95c89
 {
f95c89
 	struct pci_dev *pdev = bp->pdev;
f95c89
 
f95c89
+	if (bp->hwmon_dev)
f95c89
+		return;
f95c89
+
f95c89
 	bp->hwmon_dev = hwmon_device_register_with_groups(&pdev->dev,
f95c89
 							  DRV_MODULE_NAME, bp,
f95c89
 							  bnxt_groups);
f95c89
@@ -10007,6 +10033,53 @@
f95c89
 	return 0;
f95c89
 }
f95c89
 
f95c89
+static void bnxt_set_dflt_rss_hash_type(struct bnxt *bp)
f95c89
+{
f95c89
+	bp->flags &= ~BNXT_FLAG_UDP_RSS_CAP;
f95c89
+	bp->rss_hash_cfg = VNIC_RSS_CFG_REQ_HASH_TYPE_IPV4 |
f95c89
+			   VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV4 |
f95c89
+			   VNIC_RSS_CFG_REQ_HASH_TYPE_IPV6 |
f95c89
+			   VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV6;
f95c89
+	if (BNXT_CHIP_P4(bp) && bp->hwrm_spec_code >= 0x10501) {
f95c89
+		bp->flags |= BNXT_FLAG_UDP_RSS_CAP;
f95c89
+		bp->rss_hash_cfg |= VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV4 |
f95c89
+				    VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV6;
f95c89
+	}
f95c89
+}
f95c89
+
f95c89
+static void bnxt_set_dflt_rfs(struct bnxt *bp)
f95c89
+{
f95c89
+	struct net_device *dev = bp->dev;
f95c89
+
f95c89
+	dev->hw_features &= ~NETIF_F_NTUPLE;
f95c89
+	dev->features &= ~NETIF_F_NTUPLE;
f95c89
+	bp->flags &= ~BNXT_FLAG_RFS;
f95c89
+	if (bnxt_rfs_supported(bp)) {
f95c89
+		dev->hw_features |= NETIF_F_NTUPLE;
f95c89
+		if (bnxt_rfs_capable(bp)) {
f95c89
+			bp->flags |= BNXT_FLAG_RFS;
f95c89
+			dev->features |= NETIF_F_NTUPLE;
f95c89
+		}
f95c89
+	}
f95c89
+}
f95c89
+
f95c89
+static void bnxt_fw_init_one_p3(struct bnxt *bp)
f95c89
+{
f95c89
+	struct pci_dev *pdev = bp->pdev;
f95c89
+
f95c89
+	bnxt_set_dflt_rss_hash_type(bp);
f95c89
+	bnxt_set_dflt_rfs(bp);
f95c89
+
f95c89
+	bnxt_get_wol_settings(bp);
f95c89
+	if (bp->flags & BNXT_FLAG_WOL_CAP)
f95c89
+		device_set_wakeup_enable(&pdev->dev, bp->wol);
f95c89
+	else
f95c89
+		device_set_wakeup_capable(&pdev->dev, false);
f95c89
+
f95c89
+	bnxt_hwrm_set_cache_line_size(bp, cache_line_size());
f95c89
+	bnxt_hwrm_coal_params_qcaps(bp);
f95c89
+}
f95c89
+
f95c89
 static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev)
f95c89
 {
f95c89
 	int rc;
f95c89
@@ -10636,7 +10709,7 @@
f95c89
 	free_netdev(dev);
f95c89
 }
f95c89
 
f95c89
-static int bnxt_probe_phy(struct bnxt *bp)
f95c89
+static int bnxt_probe_phy(struct bnxt *bp, bool fw_dflt)
f95c89
 {
f95c89
 	int rc = 0;
f95c89
 	struct bnxt_link_info *link_info = &bp->link_info;
f95c89
@@ -10647,8 +10720,6 @@
f95c89
 			   rc);
f95c89
 		return rc;
f95c89
 	}
f95c89
-	mutex_init(&bp->link_lock);
f95c89
-
f95c89
 	rc = bnxt_update_link(bp, false);
f95c89
 	if (rc) {
f95c89
 		netdev_err(bp->dev, "Probe phy can't update link (rc: %x)\n",
f95c89
@@ -10662,6 +10733,9 @@
f95c89
 	if (link_info->auto_link_speeds && !link_info->support_auto_speeds)
f95c89
 		link_info->support_auto_speeds = link_info->support_speeds;
f95c89
 
f95c89
+	if (!fw_dflt)
f95c89
+		return 0;
f95c89
+
f95c89
 	/*initialize the ethool setting copy with NVM settings */
f95c89
 	if (BNXT_AUTO_MODE(link_info->auto_mode)) {
f95c89
 		link_info->autoneg = BNXT_AUTONEG_SPEED;
f95c89
@@ -10682,7 +10756,7 @@
f95c89
 			link_info->auto_pause_setting & BNXT_LINK_PAUSE_BOTH;
f95c89
 	else
f95c89
 		link_info->req_flow_ctrl = link_info->force_pause_setting;
f95c89
-	return rc;
f95c89
+	return 0;
f95c89
 }
f95c89
 
f95c89
 static int bnxt_get_max_irq(struct pci_dev *pdev)
f95c89
@@ -10986,6 +11060,7 @@
f95c89
 		goto init_err_pci_clean;
f95c89
 
f95c89
 	mutex_init(&bp->hwrm_cmd_lock);
f95c89
+	mutex_init(&bp->link_lock);
f95c89
 
f95c89
 	rc = bnxt_fw_init_one_p1(bp);
f95c89
 	if (rc)
f95c89
@@ -11061,7 +11136,7 @@
f95c89
 	dev->min_mtu = ETH_ZLEN;
f95c89
 	dev->max_mtu = bp->max_mtu;
f95c89
 
f95c89
-	rc = bnxt_probe_phy(bp);
f95c89
+	rc = bnxt_probe_phy(bp, true);
f95c89
 	if (rc)
f95c89
 		goto init_err_pci_clean;
f95c89
 
f95c89
@@ -11075,24 +11150,7 @@
f95c89
 		goto init_err_pci_clean;
f95c89
 	}
f95c89
 
f95c89
-	/* Default RSS hash cfg. */
f95c89
-	bp->rss_hash_cfg = VNIC_RSS_CFG_REQ_HASH_TYPE_IPV4 |
f95c89
-			   VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV4 |
f95c89
-			   VNIC_RSS_CFG_REQ_HASH_TYPE_IPV6 |
f95c89
-			   VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV6;
f95c89
-	if (BNXT_CHIP_P4(bp) && bp->hwrm_spec_code >= 0x10501) {
f95c89
-		bp->flags |= BNXT_FLAG_UDP_RSS_CAP;
f95c89
-		bp->rss_hash_cfg |= VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV4 |
f95c89
-				    VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV6;
f95c89
-	}
f95c89
-
f95c89
-	if (bnxt_rfs_supported(bp)) {
f95c89
-		dev->hw_features |= NETIF_F_NTUPLE;
f95c89
-		if (bnxt_rfs_capable(bp)) {
f95c89
-			bp->flags |= BNXT_FLAG_RFS;
f95c89
-			dev->features |= NETIF_F_NTUPLE;
f95c89
-		}
f95c89
-	}
f95c89
+	bnxt_fw_init_one_p3(bp);
f95c89
 
f95c89
 	if (dev->hw_features & NETIF_F_HW_VLAN_CTAG_RX)
f95c89
 		bp->flags |= BNXT_FLAG_STRIP_VLAN;
f95c89
@@ -11106,16 +11164,6 @@
f95c89
 	 */
f95c89
 	bp->tx_nr_rings_per_tc = bp->tx_nr_rings;
f95c89
 
f95c89
-	bnxt_get_wol_settings(bp);
f95c89
-	if (bp->flags & BNXT_FLAG_WOL_CAP)
f95c89
-		device_set_wakeup_enable(&pdev->dev, bp->wol);
f95c89
-	else
f95c89
-		device_set_wakeup_capable(&pdev->dev, false);
f95c89
-
f95c89
-	bnxt_hwrm_set_cache_line_size(bp, cache_line_size());
f95c89
-
f95c89
-	bnxt_hwrm_coal_params_qcaps(bp);
f95c89
-
f95c89
 	if (BNXT_PF(bp)) {
f95c89
 		if (!bnxt_pf_wq) {
f95c89
 			bnxt_pf_wq =
f95c89
Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c
f95c89
===================================================================
f95c89
--- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c	2020-02-06 16:23:18.306489323 +0100
f95c89
+++ src/drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c	2020-02-06 16:23:18.730485431 +0100
f95c89
@@ -389,6 +389,7 @@
f95c89
 	struct hwrm_queue_dscp_qcaps_input req = {0};
f95c89
 	int rc;
f95c89
 
f95c89
+	bp->max_dscp_value = 0;
f95c89
 	if (bp->hwrm_spec_code < 0x10800 || BNXT_VF(bp))
f95c89
 		return 0;
f95c89
 
f95c89
@@ -718,6 +719,7 @@
f95c89
 
f95c89
 void bnxt_dcb_init(struct bnxt *bp)
f95c89
 {
f95c89
+	bp->dcbx_cap = 0;
f95c89
 	if (bp->hwrm_spec_code < 0x10501)
f95c89
 		return;
f95c89
 
f95c89
Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
f95c89
===================================================================
f95c89
--- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c	2020-02-06 16:23:18.307489314 +0100
f95c89
+++ src/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c	2020-02-06 16:23:18.730485431 +0100
f95c89
@@ -3350,6 +3350,7 @@
f95c89
 	if (!(bp->fw_cap & BNXT_FW_CAP_PKG_VER))
f95c89
 		bnxt_get_pkgver(dev);
f95c89
 
f95c89
+	bp->num_tests = 0;
f95c89
 	if (bp->hwrm_spec_code < 0x10704 || !BNXT_SINGLE_PF(bp))
f95c89
 		return;
f95c89
 
f95c89
@@ -3359,7 +3360,9 @@
f95c89
 	if (rc)
f95c89
 		goto ethtool_init_exit;
f95c89
 
f95c89
-	test_info = kzalloc(sizeof(*bp->test_info), GFP_KERNEL);
f95c89
+	test_info = bp->test_info;
f95c89
+	if (!test_info)
f95c89
+		test_info = kzalloc(sizeof(*bp->test_info), GFP_KERNEL);
f95c89
 	if (!test_info)
f95c89
 		goto ethtool_init_exit;
f95c89