Skip to contentSkip to conversation

bnxt patchset to support device error recovery

PATCH Superseded Ajit Khaparde 2 participants 48 messages Aug 22, 2019 – Oct 2, 2019 Network drivers

lore
Share & tools
lore
#0 lore raw

cover bnxt patchset to support device error recovery

This patchset adds support to moitor the health of the firmware and the underlying device and recover to an operational state in case of error. We can also detect if a FW upgrade is in progress and quiesce all access to the device and recover once FW indicates everything is ready.

Patchset against dpdk-next-net. Please apply.

Kalesh AP (13):
net/bnxt: hsi version update
net/bnxt: prevent device access when device is in reset net/bnxt: handle reset notify async event from FW net/bnxt: inform firmware about IF state changes net/bnxt: handle fatal event from FW under error conditions net/bnxt: query firmware error recovery capabilities net/bnxt: map status registers for FW health monitoring net/bnxt: advertise error recovery capability and handle async event net/bnxt: add code for periodic FW health monitoring net/bnxt: use BIT macro instead of bit fields
net/bnxt: reschedule the health check alarm correctly net/bnxt: add support for FW reset
net/bnxt: reduce verbosity of logs

 drivers/net/bnxt/bnxt.h                | 130 +++-
 drivers/net/bnxt/bnxt_cpr.c            |  78 +++
 drivers/net/bnxt/bnxt_cpr.h            |  18 +
 drivers/net/bnxt/bnxt_ethdev.c         | 817 ++++++++++++++++++++-----
 drivers/net/bnxt/bnxt_hwrm.c           | 200 +++++-
 drivers/net/bnxt/bnxt_hwrm.h           |   7 +
 drivers/net/bnxt/bnxt_ring.c           |  39 +-
 drivers/net/bnxt/bnxt_ring.h           |   1 +
 drivers/net/bnxt/bnxt_rxq.c            |  25 +
 drivers/net/bnxt/bnxt_rxr.c            |  17 +
 drivers/net/bnxt/bnxt_rxr.h            |   2 +
 drivers/net/bnxt/bnxt_stats.c          |  34 +-
 drivers/net/bnxt/bnxt_txq.c            |   7 +
 drivers/net/bnxt/bnxt_txr.c            |  27 +
 drivers/net/bnxt/bnxt_txr.h            |   2 +
 drivers/net/bnxt/bnxt_util.h           |   4 +
 drivers/net/bnxt/bnxt_vnic.c           |   7 +-
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 137 +++++
 18 files changed, 1339 insertions(+), 213 deletions(-)
Signature · 1 line
2.20.1 (Apple Git-117)
#1 lore raw

PATCH 1/13 net/bnxt: hsi version update

From: Kalesh AP <[email protected]>

---
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 137 +++++++++++++++++++++++++
 1 file changed, 137 insertions(+)
drivers/net/bnxt/hsi_struct_def_dpdk.h +137 -0
index 6c98c1d6d..009571725 100644
@@ -33621,4 +33621,141 @@ struct hwrm_nvm_validate_option_cmd_err {
 	uint8_t	unused_0[7];
 } __attribute__((packed));
 
+/*****************
+ * hwrm_fw_reset *
+ ******************/
+
+
+/* hwrm_fw_reset_input (size:192b/24B) */
+struct hwrm_fw_reset_input {
+	/* The HWRM command request type. */
+	uint16_t        req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t        cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t        seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFE - Reserved for internal processors
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t        target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t        resp_addr;
+	/* Type of embedded processor. */
+	uint8_t embedded_proc_type;
+	/* Boot Processor */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_BOOT \
+		UINT32_C(0x0)
+	/* Management Processor */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_MGMT \
+		UINT32_C(0x1)
+	/* Network control processor */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_NETCTRL \
+		UINT32_C(0x2)
+	/* RoCE control processor */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_ROCE \
+		UINT32_C(0x3)
+	/*
+	 * Host (in multi-host environment): This is only valid if requester is IPC.
+	 * Reinit host hardware resources and PCIe.
+	 */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_HOST \
+		UINT32_C(0x4)
+	/* AP processor complex (in multi-host environment). Use host_idx to control which core is reset */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_AP \
+		UINT32_C(0x5)
+	/* Reset all blocks of the chip (including all processors) */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_CHIP \
+		UINT32_C(0x6)
+	/*
+	 * Host (in multi-host environment): This is only valid if requester is IPC.
+	 * Reinit host hardware resources.
+	 */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_HOST_RESOURCE_REINIT \
+		UINT32_C(0x7)
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_LAST \
+		HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_HOST_RESOURCE_REINIT
+	/* Type of self reset. */
+	uint8_t selfrst_status;
+	/* No Self Reset */
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTNONE \
+		UINT32_C(0x0)
+	/* Self Reset as soon as possible to do so safely */
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTASAP \
+		UINT32_C(0x1)
+	/* Self Reset on PCIe Reset */
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTPCIERST \
+		UINT32_C(0x2)
+	/* Self Reset immediately after notification to all clients. */
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTIMMEDIATE \
+		UINT32_C(0x3)
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_LAST \
+		HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTIMMEDIATE
+	/*
+	 * Indicate which host is being reset. 0 means first host.
+	 * Only valid when embedded_proc_type is host in multihost
+	 * environment
+	 */
+	uint8_t host_idx;
+	uint8_t flags;
+	/*
+	 * When this bit is '1', then the core firmware initiates
+	 * the reset only after graceful shut down of all registered instances.
+	 * If not, the device will continue with the existing firmware.
+	 */
+	#define HWRM_FW_RESET_INPUT_FLAGS_RESET_GRACEFUL     UINT32_C(0x1)
+	uint8_t unused_0[4];
+} __attribute__((packed));
+
+/* hwrm_fw_reset_output (size:128b/16B) */
+struct hwrm_fw_reset_output {
+	/* The specific error status for the command. */
+	uint16_t        error_code;
+	/* The HWRM command request type. */
+	uint16_t        req_type;
+	/* The sequence ID from the original command. */
+	uint16_t        seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t        resp_len;
+	/* Type of self reset. */
+	uint8_t selfrst_status;
+	/* No Self Reset */
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTNONE \
+		UINT32_C(0x0)
+	/* Self Reset as soon as possible to do so safely */
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTASAP \
+		UINT32_C(0x1)
+	/* Self Reset on PCIe Reset */
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTPCIERST \
+		UINT32_C(0x2)
+	/* Self Reset immediately after notification to all clients. */
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTIMMEDIATE \
+		UINT32_C(0x3)
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_LAST \
+		HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTIMMEDIATE
+	uint8_t unused_0[6];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM.  This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t valid;
+} __attribute__((packed));
+
 #endif /* _HSI_STRUCT_DEF_DPDK_H_ */
Signature · 1 line
2.20.1 (Apple Git-117)
#2 lore raw

Re: [dpdk-dev] [PATCH 01/13] net/bnxt: hsi version update

Quoted 8 lines · Ajit Khaparde

From: Kalesh AP <[email protected]>

---
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 137 +++++++++++++++++++++++++
 1 file changed, 137 insertions(+)

Hi Kalesh,

As far as I can see WRM API version is not changed, only two new structs has been added which are used later for "FW reset" on 12/13. Can you please give a little more detail on the commit log?

#3 lore raw

v2 cover bnxt patchset to support device error recovery

This patchset adds support to monitor the health of the firmware and the underlying device and recover to an operational state in case of error. We can also detect if a FW upgrade is in progress and quiesce all access to the device and recover once FW indicates everything is ready.

Patchset against dpdk-next-net. Please apply.

Kalesh AP (13):
net/bnxt: add FW reset HWRM command
net/bnxt: prevent device access when device is in reset net/bnxt: handle reset notify async event from FW net/bnxt: inform firmware about IF state changes net/bnxt: handle fatal event from FW under error conditions net/bnxt: query firmware error recovery capabilities net/bnxt: map status registers for FW health monitoring net/bnxt: advertise error recovery capability and handle async event net/bnxt: add code for periodic FW health monitoring net/bnxt: add support for FW reset
net/bnxt: reduce verbosity of logs
net/bnxt: use BIT macro instead of bit fields
net/bnxt: avoid null pointer dereference

 drivers/net/bnxt/bnxt.h                | 130 +++-
 drivers/net/bnxt/bnxt_cpr.c            |  80 +++
 drivers/net/bnxt/bnxt_cpr.h            |  18 +
 drivers/net/bnxt/bnxt_ethdev.c         | 815 ++++++++++++++++++++-----
 drivers/net/bnxt/bnxt_hwrm.c           | 200 +++++-
 drivers/net/bnxt/bnxt_hwrm.h           |   7 +
 drivers/net/bnxt/bnxt_ring.c           |  45 +-
 drivers/net/bnxt/bnxt_ring.h           |   1 +
 drivers/net/bnxt/bnxt_rxq.c            |  25 +
 drivers/net/bnxt/bnxt_rxr.c            |  17 +
 drivers/net/bnxt/bnxt_rxr.h            |   2 +
 drivers/net/bnxt/bnxt_stats.c          |  34 +-
 drivers/net/bnxt/bnxt_txq.c            |   7 +
 drivers/net/bnxt/bnxt_txr.c            |  27 +
 drivers/net/bnxt/bnxt_txr.h            |   2 +
 drivers/net/bnxt/bnxt_util.h           |   4 +
 drivers/net/bnxt/bnxt_vnic.c           |   7 +-
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 137 +++++
 18 files changed, 1343 insertions(+), 215 deletions(-)
Signature · 1 line
2.20.1 (Apple Git-117)
#4 lore raw

PATCH v2 1/13 net/bnxt: add FW reset HWRM command

From: Kalesh AP <[email protected]>

This patch adds new FW reset HWRM command.
This command allows the host software to reset the underlying hardware if a device error is detected.
Code using this command will be added in future patch.

---
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 137 +++++++++++++++++++++++++
 1 file changed, 137 insertions(+)
drivers/net/bnxt/hsi_struct_def_dpdk.h +137 -0
index 6c98c1d6d..009571725 100644
@@ -33621,4 +33621,141 @@ struct hwrm_nvm_validate_option_cmd_err {
 	uint8_t	unused_0[7];
 } __attribute__((packed));
 
+/*****************
+ * hwrm_fw_reset *
+ ******************/
+
+
+/* hwrm_fw_reset_input (size:192b/24B) */
+struct hwrm_fw_reset_input {
+	/* The HWRM command request type. */
+	uint16_t        req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t        cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t        seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFE - Reserved for internal processors
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t        target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t        resp_addr;
+	/* Type of embedded processor. */
+	uint8_t embedded_proc_type;
+	/* Boot Processor */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_BOOT \
+		UINT32_C(0x0)
+	/* Management Processor */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_MGMT \
+		UINT32_C(0x1)
+	/* Network control processor */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_NETCTRL \
+		UINT32_C(0x2)
+	/* RoCE control processor */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_ROCE \
+		UINT32_C(0x3)
+	/*
+	 * Host (in multi-host environment): This is only valid if requester is IPC.
+	 * Reinit host hardware resources and PCIe.
+	 */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_HOST \
+		UINT32_C(0x4)
+	/* AP processor complex (in multi-host environment). Use host_idx to control which core is reset */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_AP \
+		UINT32_C(0x5)
+	/* Reset all blocks of the chip (including all processors) */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_CHIP \
+		UINT32_C(0x6)
+	/*
+	 * Host (in multi-host environment): This is only valid if requester is IPC.
+	 * Reinit host hardware resources.
+	 */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_HOST_RESOURCE_REINIT \
+		UINT32_C(0x7)
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_LAST \
+		HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_HOST_RESOURCE_REINIT
+	/* Type of self reset. */
+	uint8_t selfrst_status;
+	/* No Self Reset */
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTNONE \
+		UINT32_C(0x0)
+	/* Self Reset as soon as possible to do so safely */
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTASAP \
+		UINT32_C(0x1)
+	/* Self Reset on PCIe Reset */
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTPCIERST \
+		UINT32_C(0x2)
+	/* Self Reset immediately after notification to all clients. */
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTIMMEDIATE \
+		UINT32_C(0x3)
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_LAST \
+		HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTIMMEDIATE
+	/*
+	 * Indicate which host is being reset. 0 means first host.
+	 * Only valid when embedded_proc_type is host in multihost
+	 * environment
+	 */
+	uint8_t host_idx;
+	uint8_t flags;
+	/*
+	 * When this bit is '1', then the core firmware initiates
+	 * the reset only after graceful shut down of all registered instances.
+	 * If not, the device will continue with the existing firmware.
+	 */
+	#define HWRM_FW_RESET_INPUT_FLAGS_RESET_GRACEFUL     UINT32_C(0x1)
+	uint8_t unused_0[4];
+} __attribute__((packed));
+
+/* hwrm_fw_reset_output (size:128b/16B) */
+struct hwrm_fw_reset_output {
+	/* The specific error status for the command. */
+	uint16_t        error_code;
+	/* The HWRM command request type. */
+	uint16_t        req_type;
+	/* The sequence ID from the original command. */
+	uint16_t        seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t        resp_len;
+	/* Type of self reset. */
+	uint8_t selfrst_status;
+	/* No Self Reset */
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTNONE \
+		UINT32_C(0x0)
+	/* Self Reset as soon as possible to do so safely */
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTASAP \
+		UINT32_C(0x1)
+	/* Self Reset on PCIe Reset */
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTPCIERST \
+		UINT32_C(0x2)
+	/* Self Reset immediately after notification to all clients. */
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTIMMEDIATE \
+		UINT32_C(0x3)
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_LAST \
+		HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTIMMEDIATE
+	uint8_t unused_0[6];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM.  This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t valid;
+} __attribute__((packed));
+
 #endif /* _HSI_STRUCT_DEF_DPDK_H_ */
Signature · 1 line
2.20.1 (Apple Git-117)
#5 lore raw

PATCH v2 2/13 net/bnxt: prevent device access when device is in reset

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

Refactor init and uninit functions so that the driver can fail the eth_dev_ops callbacks and accessing Tx and Rx queues when device is in reset or in error state.

Transmit and receive queues are freed during reset cleanup and reallocated during recovery. So we block all data path handling in this state. The eth_dev dev_started field is updated depending on the status of the device.

---
 drivers/net/bnxt/bnxt.h        |   3 +
 drivers/net/bnxt/bnxt_ethdev.c | 455 ++++++++++++++++++++++-----------
 drivers/net/bnxt/bnxt_hwrm.c   |   2 -
 drivers/net/bnxt/bnxt_ring.c   |  32 +++
 drivers/net/bnxt/bnxt_ring.h   |   1 +
 drivers/net/bnxt/bnxt_rxq.c    |  25 ++
 drivers/net/bnxt/bnxt_rxr.c    |  17 ++
 drivers/net/bnxt/bnxt_rxr.h    |   2 +
 drivers/net/bnxt/bnxt_stats.c  |  34 ++-
 drivers/net/bnxt/bnxt_txq.c    |   7 +
 drivers/net/bnxt/bnxt_txr.c    |  27 ++
 drivers/net/bnxt/bnxt_txr.h    |   2 +
 12 files changed, 454 insertions(+), 153 deletions(-)
drivers/net/bnxt/bnxt.h +3 -0
index 0c9f994ea..37b4c717d 100644
@@ -358,6 +358,8 @@ struct bnxt {
 #define BNXT_FLAG_DFLT_VNIC_SET	(1 << 12)
 #define BNXT_FLAG_THOR_CHIP	(1 << 13)
 #define BNXT_FLAG_STINGRAY	(1 << 14)
+#define BNXT_FLAG_FW_RESET	(1 << 15)
+#define BNXT_FLAG_FATAL_ERROR	(1 << 16)
 #define BNXT_FLAG_EXT_STATS_SUPPORTED	(1 << 29)
 #define BNXT_FLAG_NEW_RM	(1 << 30)
 #define BNXT_FLAG_INIT_DONE	(1U << 31)
@@ -465,6 +467,7 @@ struct bnxt {
 
 int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete);
 int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id, void *msg);
+int is_bnxt_in_error(struct bnxt *bp);
 
 bool is_bnxt_supported(struct rte_eth_dev *dev);
 bool bnxt_stratus_device(struct bnxt *bp);
drivers/net/bnxt/bnxt_ethdev.c +305 -150

751 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.c +0 -2
index 9883fb506..24a5a0914 100644
@@ -964,8 +964,6 @@ int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, uint32_t flags)
 	HWRM_CHECK_RESULT();
 	HWRM_UNLOCK();
 
-	bp->flags &= ~BNXT_FLAG_REGISTERED;
-
 	return rc;
 }
 
drivers/net/bnxt/bnxt_ring.c +32 -0
index be15b4bd1..f19865c83 100644
@@ -50,6 +50,38 @@ int bnxt_init_ring_grps(struct bnxt *bp)
 	return 0;
 }
 
+int bnxt_alloc_ring_grps(struct bnxt *bp)
+{
+	if (bp->max_tx_rings == 0) {
+		PMD_DRV_LOG(ERR, "No TX rings available!\n");
+		return -EBUSY;
+	}
+
+	/* THOR does not support ring groups.
+	 * But we will use the array to save RSS context IDs.
+	 */
+	if (BNXT_CHIP_THOR(bp)) {
+		bp->max_ring_grps = BNXT_MAX_RSS_CTXTS_THOR;
+	} else if (bp->max_ring_grps < bp->rx_cp_nr_rings) {
+		/* 1 ring is for default completion ring */
+		PMD_DRV_LOG(ERR, "Insufficient resource: Ring Group\n");
+		return -ENOSPC;
+	}
+
+	if (BNXT_HAS_RING_GRPS(bp)) {
+		bp->grp_info = rte_zmalloc("bnxt_grp_info",
+					   sizeof(*bp->grp_info) *
+					   bp->max_ring_grps, 0);
+		if (!bp->grp_info) {
+			PMD_DRV_LOG(ERR,
+				    "Failed to alloc grp info tbl.\n");
+			return -ENOMEM;
+		}
+	}
+
+	return 0;
+}
+
 /*
  * Allocates a completion ring with vmem and stats optionally also allocating
  * a TX and/or RX ring.  Passing NULL as tx_ring_info and/or rx_ring_info
drivers/net/bnxt/bnxt_ring.h +1 -0
index 04c7b04b8..a31d59ea3 100644
@@ -67,6 +67,7 @@ struct bnxt_rx_ring_info;
 struct bnxt_cp_ring_info;
 void bnxt_free_ring(struct bnxt_ring *ring);
 int bnxt_init_ring_grps(struct bnxt *bp);
+int bnxt_alloc_ring_grps(struct bnxt *bp);
 int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
 			    struct bnxt_tx_queue *txq,
 			    struct bnxt_rx_queue *rxq,
drivers/net/bnxt/bnxt_rxq.c +25 -0
index 1d95f1139..d5fc5268d 100644
@@ -263,6 +263,9 @@ void bnxt_rx_queue_release_op(void *rx_queue)
 	struct bnxt_rx_queue *rxq = (struct bnxt_rx_queue *)rx_queue;
 
 	if (rxq) {
+		if (is_bnxt_in_error(rxq->bp))
+			return;
+
 		bnxt_rx_queue_release_mbufs(rxq);
 
 		/* Free RX ring hardware descriptors */
@@ -294,6 +297,10 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
 	int rc = 0;
 	uint8_t queue_state;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	if (queue_idx >= bp->max_rx_rings) {
 		PMD_DRV_LOG(ERR,
 			"Cannot create Rx ring %d. Only %d rings available\n",
@@ -363,10 +370,15 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
 int
 bnxt_rx_queue_intr_enable_op(struct rte_eth_dev *eth_dev, uint16_t queue_id)
 {
+	struct bnxt *bp = eth_dev->data->dev_private;
 	struct bnxt_rx_queue *rxq;
 	struct bnxt_cp_ring_info *cpr;
 	int rc = 0;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	if (eth_dev->data->rx_queues) {
 		rxq = eth_dev->data->rx_queues[queue_id];
 		if (!rxq) {
@@ -382,10 +394,15 @@ bnxt_rx_queue_intr_enable_op(struct rte_eth_dev *eth_dev, uint16_t queue_id)
 int
 bnxt_rx_queue_intr_disable_op(struct rte_eth_dev *eth_dev, uint16_t queue_id)
 {
+	struct bnxt *bp = eth_dev->data->dev_private;
 	struct bnxt_rx_queue *rxq;
 	struct bnxt_cp_ring_info *cpr;
 	int rc = 0;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	if (eth_dev->data->rx_queues) {
 		rxq = eth_dev->data->rx_queues[queue_id];
 		if (!rxq) {
@@ -406,6 +423,10 @@ int bnxt_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 	struct bnxt_vnic_info *vnic = NULL;
 	int rc = 0;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	if (rxq == NULL) {
 		PMD_DRV_LOG(ERR, "Invalid Rx queue %d\n", rx_queue_id);
 		return -EINVAL;
@@ -458,6 +479,10 @@ int bnxt_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 	struct bnxt_rx_queue *rxq = NULL;
 	int rc = 0;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	/* For the stingray platform and other platforms needing tighter
 	 * control of resource utilization, Rx CQ 0 also works as
 	 * Default CQ for async notifications
drivers/net/bnxt/bnxt_rxr.c +17 -0
index 185a0e376..12313dd53 100644
@@ -539,6 +539,9 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	int rc = 0;
 	bool evt = false;
 
+	if (unlikely(is_bnxt_in_error(rxq->bp)))
+		return 0;
+
 	/* If Rx Q was stopped return. RxQ0 cannot be stopped. */
 	if (unlikely(((rxq->rx_deferred_start ||
 		       !rte_spinlock_trylock(&rxq->lock)) &&
@@ -625,6 +628,20 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	return nb_rx_pkts;
 }
 
+/*
+ * Dummy DPDK callback for RX.
+ *
+ * This function is used to temporarily replace the real callback during
+ * unsafe control operations on the queue, or in case of error.
+ */
+uint16_t
+bnxt_dummy_recv_pkts(void *rx_queue __rte_unused,
+		     struct rte_mbuf **rx_pkts __rte_unused,
+		     uint16_t nb_pkts __rte_unused)
+{
+	return 0;
+}
+
 void bnxt_free_rx_rings(struct bnxt *bp)
 {
 	int i;
drivers/net/bnxt/bnxt_rxr.h +2 -0
index 6a80c37c8..493b75406 100644
@@ -185,6 +185,8 @@ struct bnxt_rx_ring_info {
 
 uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 			       uint16_t nb_pkts);
+uint16_t bnxt_dummy_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+			      uint16_t nb_pkts);
 void bnxt_free_rx_rings(struct bnxt *bp);
 int bnxt_init_rx_ring_struct(struct bnxt_rx_queue *rxq, unsigned int socket_id);
 int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq);
drivers/net/bnxt/bnxt_stats.c +33 -1
index 69ac2dd91..79f23746c 100644
@@ -353,6 +353,10 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev,
 	struct bnxt *bp = eth_dev->data->dev_private;
 	unsigned int num_q_stats;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	memset(bnxt_stats, 0, sizeof(*bnxt_stats));
 	if (!(bp->flags & BNXT_FLAG_INIT_DONE)) {
 		PMD_DRV_LOG(ERR, "Device Initialization not complete!\n");
@@ -397,6 +401,9 @@ void bnxt_stats_reset_op(struct rte_eth_dev *eth_dev)
 	struct bnxt *bp = eth_dev->data->dev_private;
 	unsigned int i;
 
+	if (is_bnxt_in_error(bp))
+		return;
+
 	if (!(bp->flags & BNXT_FLAG_INIT_DONE)) {
 		PMD_DRV_LOG(ERR, "Device Initialization not complete!\n");
 		return;
@@ -414,13 +421,17 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev,
 			   struct rte_eth_xstat *xstats, unsigned int n)
 {
 	struct bnxt *bp = eth_dev->data->dev_private;
-
 	unsigned int count, i;
 	uint64_t tx_drop_pkts;
 	unsigned int rx_port_stats_ext_cnt;
 	unsigned int tx_port_stats_ext_cnt;
 	unsigned int stat_size = sizeof(uint64_t);
 	unsigned int stat_count;
+	int rc;
+
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
 
 	memset(xstats, 0, sizeof(*xstats));
 
@@ -499,7 +510,13 @@ int bnxt_dev_xstats_get_names_op(__rte_unused struct rte_eth_dev *eth_dev,
 				RTE_DIM(bnxt_tx_stats_strings) + 1 +
 				RTE_DIM(bnxt_rx_ext_stats_strings) +
 				RTE_DIM(bnxt_tx_ext_stats_strings);
+	struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
 	unsigned int i, count;
+	int rc;
+
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
 
 	if (xstats_names != NULL) {
 		count = 0;
@@ -547,6 +564,9 @@ void bnxt_dev_xstats_reset_op(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt *bp = eth_dev->data->dev_private;
 
+	if (is_bnxt_in_error(bp))
+		return;
+
 	if (bp->flags & BNXT_FLAG_PORT_STATS && BNXT_SINGLE_PF(bp))
 		bnxt_hwrm_port_clr_stats(bp);
 
@@ -566,9 +586,15 @@ int bnxt_dev_xstats_get_by_id_op(struct rte_eth_dev *dev, const uint64_t *ids,
 				RTE_DIM(bnxt_tx_stats_strings) + 1 +
 				RTE_DIM(bnxt_rx_ext_stats_strings) +
 				RTE_DIM(bnxt_tx_ext_stats_strings);
+	struct bnxt *bp = dev->data->dev_private;
 	struct rte_eth_xstat xstats[stat_cnt];
 	uint64_t values_copy[stat_cnt];
 	uint16_t i;
+	int rc;
+
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
 
 	if (!ids)
 		return bnxt_dev_xstats_get_op(dev, xstats, stat_cnt);
@@ -594,7 +620,13 @@ int bnxt_dev_xstats_get_names_by_id_op(struct rte_eth_dev *dev,
 				RTE_DIM(bnxt_rx_ext_stats_strings) +
 				RTE_DIM(bnxt_tx_ext_stats_strings);
 	struct rte_eth_xstat_name xstats_names_copy[stat_cnt];
+	struct bnxt *bp = dev->data->dev_private;
 	uint16_t i;
+	int rc;
+
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
 
 	if (!ids)
 		return bnxt_dev_xstats_get_names_op(dev, xstats_names,
drivers/net/bnxt/bnxt_txq.c +7 -0
index 43b3496c1..090132479 100644
@@ -58,6 +58,9 @@ void bnxt_tx_queue_release_op(void *tx_queue)
 	struct bnxt_tx_queue *txq = (struct bnxt_tx_queue *)tx_queue;
 
 	if (txq) {
+		if (is_bnxt_in_error(txq->bp))
+			return;
+
 		/* Free TX ring hardware descriptors */
 		bnxt_tx_queue_release_mbufs(txq);
 		bnxt_free_ring(txq->tx_ring->tx_ring_struct);
@@ -84,6 +87,10 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
 	struct bnxt_tx_queue *txq;
 	int rc = 0;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	if (queue_idx >= bp->max_tx_rings) {
 		PMD_DRV_LOG(ERR,
 			"Cannot create Tx ring %d. Only %d rings available\n",
drivers/net/bnxt/bnxt_txr.c +27 -0
index c71e6f189..35e7166be 100644
@@ -148,6 +148,9 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
 		TX_BD_LONG_FLAGS_LHINT_LT2K
 	};
 
+	if (unlikely(is_bnxt_in_error(txq->bp)))
+		return -EIO;
+
 	if (tx_pkt->ol_flags & (PKT_TX_TCP_SEG | PKT_TX_TCP_CKSUM |
 				PKT_TX_UDP_CKSUM | PKT_TX_IP_CKSUM |
 				PKT_TX_VLAN_PKT | PKT_TX_OUTER_IP_CKSUM |
@@ -485,10 +488,29 @@ uint16_t bnxt_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 	return nb_tx_pkts;
 }
 
+/*
+ * Dummy DPDK callback for TX.
+ *
+ * This function is used to temporarily replace the real callback during
+ * unsafe control operations on the queue, or in case of error.
+ */
+uint16_t
+bnxt_dummy_xmit_pkts(void *tx_queue __rte_unused,
+		     struct rte_mbuf **tx_pkts __rte_unused,
+		     uint16_t nb_pkts __rte_unused)
+{
+	return 0;
+}
+
 int bnxt_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 {
 	struct bnxt *bp = dev->data->dev_private;
 	struct bnxt_tx_queue *txq = bp->tx_queues[tx_queue_id];
+	int rc = 0;
+
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
 
 	dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
 	txq->tx_deferred_start = false;
@@ -501,6 +523,11 @@ int bnxt_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 {
 	struct bnxt *bp = dev->data->dev_private;
 	struct bnxt_tx_queue *txq = bp->tx_queues[tx_queue_id];
+	int rc = 0;
+
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
 
 	/* Handle TX completions */
 	bnxt_handle_tx_cp(txq);
drivers/net/bnxt/bnxt_txr.h +2 -0
index 08fd2e014..e7f43f9d1 100644
@@ -57,6 +57,8 @@ int bnxt_init_one_tx_ring(struct bnxt_tx_queue *txq);
 int bnxt_init_tx_ring_struct(struct bnxt_tx_queue *txq, unsigned int socket_id);
 uint16_t bnxt_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			       uint16_t nb_pkts);
+uint16_t bnxt_dummy_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+			      uint16_t nb_pkts);
 #ifdef RTE_ARCH_X86
 uint16_t bnxt_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
 			    uint16_t nb_pkts);
Signature · 1 line
2.20.1 (Apple Git-117)
#6 lore raw

PATCH v2 3/13 net/bnxt: handle reset notify async event from FW

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

When the FW upgrade is initiated the current instance of FW issues a HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY async notification to the driver. On receiving this notification, the PMD shall quiesce itself and poll on the HWRM_VER_GET FW command at regular intervals.

Once the VER_GET command succeeds, the driver should go through the rediscovery process and re-initialize the device.

Also register with FW for the reset notify async event.

---
 drivers/net/bnxt/bnxt.h        |  13 ++++
 drivers/net/bnxt/bnxt_cpr.c    |  16 +++++
 drivers/net/bnxt/bnxt_cpr.h    |   1 +
 drivers/net/bnxt/bnxt_ethdev.c | 109 ++++++++++++++++++++++++++++-----
 drivers/net/bnxt/bnxt_hwrm.c   |  39 +++++++++---
 drivers/net/bnxt/bnxt_hwrm.h   |   2 +
 6 files changed, 157 insertions(+), 23 deletions(-)
drivers/net/bnxt/bnxt.h +13 -0
index 37b4c717d..8797b032e 100644
@@ -333,6 +333,16 @@ struct bnxt_ctx_mem_info {
 	struct bnxt_ctx_pg_info *tqm_mem[BNXT_MAX_TC_Q];
 };
 
+/* Maximum Firmware Reset bail out value in milliseconds */
+#define BNXT_MAX_FW_RESET_TIMEOUT	6000
+/* Minimum time required for the firmware readiness in milliseconds */
+#define BNXT_MIN_FW_READY_TIMEOUT	2000
+/* Frequency for the firmware readiness check in milliseconds */
+#define BNXT_FW_READY_WAIT_INTERVAL	100
+
+#define US_PER_MS			1000
+#define NS_PER_US			1000
+
 #define BNXT_HWRM_SHORT_REQ_LEN		sizeof(struct hwrm_short_input)
 struct bnxt {
 	void				*bar0;
@@ -463,6 +473,9 @@ struct bnxt {
 	struct bnxt_ptp_cfg     *ptp_cfg;
 	uint16_t		vf_resv_strategy;
 	struct bnxt_ctx_mem_info        *ctx;
+
+	uint16_t		fw_reset_min_msecs;
+	uint16_t		fw_reset_max_msecs;
 };
 
 int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete);
drivers/net/bnxt/bnxt_cpr.c +16 -0
index 655bcf1a8..62a16d2ed 100644
@@ -4,6 +4,7 @@
  */
 
 #include <rte_malloc.h>
+#include <rte_alarm.h>
 
 #include "bnxt.h"
 #include "bnxt_cpr.h"
@@ -40,6 +41,21 @@ void bnxt_handle_async_event(struct bnxt *bp,
 	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED:
 		PMD_DRV_LOG(INFO, "Port conn async event\n");
 		break;
+	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY:
+		/* timestamp_lo/hi values are in units of 100ms */
+		bp->fw_reset_max_msecs = async_cmp->timestamp_hi ?
+			rte_le_to_cpu_16(async_cmp->timestamp_hi) * 100 :
+			BNXT_MAX_FW_RESET_TIMEOUT;
+		bp->fw_reset_min_msecs = async_cmp->timestamp_lo ?
+			async_cmp->timestamp_lo * 100 :
+			BNXT_MIN_FW_READY_TIMEOUT;
+		PMD_DRV_LOG(INFO,
+			    "Firmware non-fatal reset event received\n");
+
+		bp->flags |= BNXT_FLAG_FW_RESET;
+		rte_eal_alarm_set(US_PER_MS, bnxt_dev_reset_and_resume,
+				  (void *)bp);
+		break;
 	default:
 		PMD_DRV_LOG(INFO, "handle_async_event id = 0x%x\n", event_id);
 		break;
drivers/net/bnxt/bnxt_cpr.h +1 -0
index 8c6a34b61..f48293b96 100644
@@ -106,5 +106,6 @@ struct bnxt;
 void bnxt_handle_async_event(struct bnxt *bp, struct cmpl_base *cmp);
 void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmp);
 int bnxt_event_hwrm_resp_handler(struct bnxt *bp, struct cmpl_base *cmp);
+void bnxt_dev_reset_and_resume(void *arg);
 
 #endif
drivers/net/bnxt/bnxt_ethdev.c +93 -16

192 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.c +32 -7
index 24a5a0914..b27dbe87e 100644
@@ -26,7 +26,7 @@
 
 #include <rte_io.h>
 
-#define HWRM_CMD_TIMEOUT		6000000
+#define HWRM_SHORT_CMD_TIMEOUT		50000
 #define HWRM_SPEC_CODE_1_8_3		0x10803
 #define HWRM_VERSION_1_9_1		0x10901
 #define HWRM_VERSION_1_9_2		0x10903
@@ -97,6 +97,14 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,
 		GRCPF_REG_KONG_CHANNEL_OFFSET : GRCPF_REG_CHIMP_CHANNEL_OFFSET;
 	uint16_t mb_trigger_offset = use_kong_mb ?
 		GRCPF_REG_KONG_COMM_TRIGGER : GRCPF_REG_CHIMP_COMM_TRIGGER;
+	uint32_t timeout;
+
+	/* Do not send HWRM commands to firmware in error state */
+	if (bp->flags & BNXT_FLAG_FATAL_ERROR)
+		return 0;
+
+	/* For VER_GET command, set timeout as 50ms */
+	timeout = HWRM_SHORT_CMD_TIMEOUT;
 
 	if (bp->flags & BNXT_FLAG_SHORT_CMD ||
 	    msg_len > bp->max_req_len) {
@@ -139,7 +147,7 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,
 	rte_write32(1, bar);
 
 	/* Poll for the valid bit */
-	for (i = 0; i < HWRM_CMD_TIMEOUT; i++) {
+	for (i = 0; i < timeout; i++) {
 		/* Sanity check on the resp->resp_len */
 		rte_rmb();
 		if (resp->resp_len && resp->resp_len <= bp->max_resp_len) {
@@ -151,7 +159,12 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,
 		rte_delay_us(1);
 	}
 
-	if (i >= HWRM_CMD_TIMEOUT) {
+	if (i >= timeout) {
+		/* Suppress VER_GET timeout messages during reset recovery */
+		if (bp->flags & BNXT_FLAG_FW_RESET &&
+		    rte_cpu_to_le_16(req->req_type) == HWRM_VER_GET)
+			return -ETIMEDOUT;
+
 		PMD_DRV_LOG(ERR, "Error(timeout) sending msg 0x%04x\n",
 			    req->req_type);
 		return -ETIMEDOUT;
@@ -657,12 +670,15 @@ int bnxt_hwrm_func_reset(struct bnxt *bp)
 int bnxt_hwrm_func_driver_register(struct bnxt *bp)
 {
 	int rc;
+	uint32_t flags = 0;
 	struct hwrm_func_drv_rgtr_input req = {.req_type = 0 };
 	struct hwrm_func_drv_rgtr_output *resp = bp->hwrm_cmd_resp_addr;
 
 	if (bp->flags & BNXT_FLAG_REGISTERED)
 		return 0;
 
+	flags = HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_HOT_RESET_SUPPORT;
+
 	HWRM_PREP(req, FUNC_DRV_RGTR, BNXT_USE_CHIMP_MB);
 	req.enables = rte_cpu_to_le_32(HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VER |
 			HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_ASYNC_EVENT_FWD);
@@ -683,14 +699,16 @@ int bnxt_hwrm_func_driver_register(struct bnxt *bp)
 		 * this HWRM sniffer list in FW because DPDK PF driver does
 		 * not support this.
 		 */
-		req.flags =
-		rte_cpu_to_le_32(HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_FWD_NONE_MODE);
+		flags |= HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_FWD_NONE_MODE;
 	}
 
+	req.flags = rte_cpu_to_le_32(flags);
+
 	req.async_event_fwd[0] |=
 		rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_LINK_STATUS_CHANGE |
 				 ASYNC_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED |
-				 ASYNC_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE);
+				 ASYNC_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE |
+				 ASYNC_CMPL_EVENT_ID_RESET_NOTIFY);
 	req.async_event_fwd[1] |=
 		rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_PF_DRVR_UNLOAD |
 				 ASYNC_CMPL_EVENT_ID_VF_CFG_CHANGE);
@@ -837,7 +855,10 @@ int bnxt_hwrm_ver_get(struct bnxt *bp)
 
 	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
 
-	HWRM_CHECK_RESULT();
+	if (bp->flags & BNXT_FLAG_FW_RESET)
+		HWRM_CHECK_RESULT_SILENT();
+	else
+		HWRM_CHECK_RESULT();
 
 	PMD_DRV_LOG(INFO, "%d.%d.%d:%d.%d.%d\n",
 		resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b,
@@ -2685,6 +2706,10 @@ int bnxt_hwrm_func_qcfg(struct bnxt *bp, uint16_t *mtu)
 	if (BNXT_VF(bp) && (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_TRUSTED_VF)) {
 		bp->flags |= BNXT_FLAG_TRUSTED_VF_EN;
 		PMD_DRV_LOG(INFO, "Trusted VF cap enabled\n");
+	} else if (BNXT_VF(bp) &&
+		   !(flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_TRUSTED_VF)) {
+		bp->flags &= ~BNXT_FLAG_TRUSTED_VF_EN;
+		PMD_DRV_LOG(INFO, "Trusted VF cap disabled\n");
 	}
 
 	if (mtu)
drivers/net/bnxt/bnxt_hwrm.h +2 -0
index c882fc2a1..a03620532 100644
@@ -21,6 +21,8 @@ struct bnxt_cp_ring_info;
 	(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED)
 #define ASYNC_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE	\
 	(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE)
+#define ASYNC_CMPL_EVENT_ID_RESET_NOTIFY \
+	(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY)
 #define ASYNC_CMPL_EVENT_ID_PF_DRVR_UNLOAD	\
 	(1 << (HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD - 32))
 #define ASYNC_CMPL_EVENT_ID_VF_CFG_CHANGE	\
Signature · 1 line
2.20.1 (Apple Git-117)
#7 lore raw

PATCH v2 4/13 net/bnxt: inform firmware about IF state changes

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

Use latest firmware API to inform firmware about IF state changes. Firmware has the option to clean up resources during IF down and to require the driver to reserve resources again during IF up.

---
 drivers/net/bnxt/bnxt.h        |  1 +
 drivers/net/bnxt/bnxt_ethdev.c |  4 ++++
 drivers/net/bnxt/bnxt_hwrm.c   | 35 ++++++++++++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.h   |  1 +
 4 files changed, 41 insertions(+)
drivers/net/bnxt/bnxt.h +1 -0
index 8797b032e..394a2a941 100644
@@ -370,6 +370,7 @@ struct bnxt {
 #define BNXT_FLAG_STINGRAY	(1 << 14)
 #define BNXT_FLAG_FW_RESET	(1 << 15)
 #define BNXT_FLAG_FATAL_ERROR	(1 << 16)
+#define BNXT_FLAG_FW_CAP_IF_CHANGE	(1 << 17)
 #define BNXT_FLAG_EXT_STATS_SUPPORTED	(1 << 29)
 #define BNXT_FLAG_NEW_RM	(1 << 30)
 #define BNXT_FLAG_INIT_DONE	(1U << 31)
drivers/net/bnxt/bnxt_ethdev.c +4 -0
index e545802ce..385492db5 100644
@@ -803,6 +803,8 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 			bp->rx_cp_nr_rings, RTE_ETHDEV_QUEUE_STAT_CNTRS);
 	}
 
+	bnxt_hwrm_if_change(bp, 1);
+
 	rc = bnxt_init_chip(bp);
 	if (rc)
 		goto error;
@@ -829,6 +831,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 	return 0;
 
 error:
+	bnxt_hwrm_if_change(bp, 0);
 	bnxt_shutdown_nic(bp);
 	bnxt_free_tx_mbufs(bp);
 	bnxt_free_rx_mbufs(bp);
@@ -895,6 +898,7 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
 	bnxt_free_tx_mbufs(bp);
 	bnxt_free_rx_mbufs(bp);
 	bnxt_shutdown_nic(bp);
+	bnxt_hwrm_if_change(bp, 0);
 	bp->dev_stopped = 1;
 }
 
drivers/net/bnxt/bnxt_hwrm.c +35 -0
index b27dbe87e..17c7b5e9e 100644
@@ -716,6 +716,11 @@ int bnxt_hwrm_func_driver_register(struct bnxt *bp)
 	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
 
 	HWRM_CHECK_RESULT();
+
+	flags = rte_le_to_cpu_32(resp->flags);
+	if (flags & HWRM_FUNC_DRV_RGTR_OUTPUT_FLAGS_IF_CHANGE_SUPPORTED)
+		bp->flags |= BNXT_FLAG_FW_CAP_IF_CHANGE;
+
 	HWRM_UNLOCK();
 
 	bp->flags |= BNXT_FLAG_REGISTERED;
@@ -4649,3 +4654,33 @@ int bnxt_hwrm_set_mac(struct bnxt *bp)
 
 	return rc;
 }
+
+int bnxt_hwrm_if_change(struct bnxt *bp, bool state)
+{
+	struct hwrm_func_drv_if_change_output *resp = bp->hwrm_cmd_resp_addr;
+	struct hwrm_func_drv_if_change_input req = {0};
+	int rc;
+
+	if (!(bp->flags & BNXT_FLAG_FW_CAP_IF_CHANGE))
+		return 0;
+
+	/* Do not issue FUNC_DRV_IF_CHANGE during reset recovery.
+	 * If we issue FUNC_DRV_IF_CHANGE with flags down before
+	 * FUNC_DRV_UNRGTR, FW resets before FUNC_DRV_UNRGTR
+	 */
+	if (!state && (bp->flags & BNXT_FLAG_FW_RESET))
+		return 0;
+
+	HWRM_PREP(req, FUNC_DRV_IF_CHANGE, BNXT_USE_CHIMP_MB);
+
+	if (state)
+		req.flags =
+		rte_cpu_to_le_32(HWRM_FUNC_DRV_IF_CHANGE_INPUT_FLAGS_UP);
+
+	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+
+	HWRM_CHECK_RESULT();
+	HWRM_UNLOCK();
+
+	return rc;
+}
drivers/net/bnxt/bnxt_hwrm.h +1 -0
index a03620532..2f57e950b 100644
@@ -201,4 +201,5 @@ int bnxt_hwrm_tunnel_redirect_query(struct bnxt *bp, uint32_t *type);
 int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
 				   uint16_t *dst_fid);
 int bnxt_hwrm_set_mac(struct bnxt *bp);
+int bnxt_hwrm_if_change(struct bnxt *bp, bool state);
 #endif
Signature · 1 line
2.20.1 (Apple Git-117)
#8 lore raw

PATCH v2 5/13 net/bnxt: handle fatal event from FW under error conditions

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

When firmware hit some unrecoverable error conditions, firmware initiate the recovery by sending an async event EVENT_CMPL_EVENT_ID_RESET_NOTIFY with data1 set to RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL to all host drivers and will reset the chip.

The recovery procedure is same sequence as the one for hot FW upgrade.

---
 drivers/net/bnxt/bnxt_cpr.c    | 13 +++++++++++--
 drivers/net/bnxt/bnxt_cpr.h    |  5 +++++
 drivers/net/bnxt/bnxt_ethdev.c |  3 +++
 3 files changed, 19 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt_cpr.c +11 -2
index 62a16d2ed..0b2eeef8f 100644
@@ -21,6 +21,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
 	struct hwrm_async_event_cmpl *async_cmp =
 				(struct hwrm_async_event_cmpl *)cmp;
 	uint16_t event_id = rte_le_to_cpu_16(async_cmp->event_id);
+	uint32_t event_data;
 
 	/* TODO: HWRM async events are not defined yet */
 	/* Needs to handle: link events, error events, etc. */
@@ -42,6 +43,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
 		PMD_DRV_LOG(INFO, "Port conn async event\n");
 		break;
 	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY:
+		event_data = rte_le_to_cpu_32(async_cmp->event_data1);
 		/* timestamp_lo/hi values are in units of 100ms */
 		bp->fw_reset_max_msecs = async_cmp->timestamp_hi ?
 			rte_le_to_cpu_16(async_cmp->timestamp_hi) * 100 :
@@ -49,8 +51,15 @@ void bnxt_handle_async_event(struct bnxt *bp,
 		bp->fw_reset_min_msecs = async_cmp->timestamp_lo ?
 			async_cmp->timestamp_lo * 100 :
 			BNXT_MIN_FW_READY_TIMEOUT;
-		PMD_DRV_LOG(INFO,
-			    "Firmware non-fatal reset event received\n");
+		if ((event_data & EVENT_DATA1_REASON_CODE_MASK) ==
+		    EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL) {
+			PMD_DRV_LOG(INFO,
+				    "Firmware fatal reset event received\n");
+			bp->flags |= BNXT_FLAG_FATAL_ERROR;
+		} else {
+			PMD_DRV_LOG(INFO,
+				    "Firmware non-fatal reset event received\n");
+		}
 
 		bp->flags |= BNXT_FLAG_FW_RESET;
 		rte_eal_alarm_set(US_PER_MS, bnxt_dev_reset_and_resume,
drivers/net/bnxt/bnxt_cpr.h +5 -0
index f48293b96..b61bafa0e 100644
@@ -108,4 +108,9 @@ void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmp);
 int bnxt_event_hwrm_resp_handler(struct bnxt *bp, struct cmpl_base *cmp);
 void bnxt_dev_reset_and_resume(void *arg);
 
+#define EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL     \
+	HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL
+#define EVENT_DATA1_REASON_CODE_MASK                   \
+	HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MASK
+
 #endif
drivers/net/bnxt/bnxt_ethdev.c +3 -0
index 385492db5..a917e0440 100644
@@ -3512,6 +3512,9 @@ static void bnxt_dev_recover(void *arg)
 	int timeout = bp->fw_reset_max_msecs;
 	int rc = 0;
 
+	/* Clear Error flag so that device re-init should happen */
+	bp->flags &= ~BNXT_FLAG_FATAL_ERROR;
+
 	do {
 		rc = bnxt_hwrm_ver_get(bp);
 		if (rc == 0)
Signature · 1 line
2.20.1 (Apple Git-117)
#9 lore raw

PATCH v2 6/13 net/bnxt: query firmware error recovery capabilities

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

In Driver initiated error recovery process, driver has to know about the registers offset and values to initiate FW reset. The HWRM command HWRM_ERROR_RECOVERY_QCFG is used to obtain all the registers and values required to initiate FW reset. This command response includes FW heart_beat register, health status register, Error counter register, register offsets and values to do chip reset if firmware crashes and becomes unresponsive.

---
 drivers/net/bnxt/bnxt.h        | 27 +++++++++++
 drivers/net/bnxt/bnxt_ethdev.c | 10 ++++
 drivers/net/bnxt/bnxt_hwrm.c   | 89 ++++++++++++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.h   |  1 +
 4 files changed, 127 insertions(+)
drivers/net/bnxt/bnxt.h +27 -0
index 394a2a941..19bd13a7f 100644
@@ -343,6 +343,29 @@ struct bnxt_ctx_mem_info {
 #define US_PER_MS			1000
 #define NS_PER_US			1000
 
+struct bnxt_error_recovery_info {
+	/* All units in milliseconds */
+	uint32_t	driver_polling_freq;
+	uint32_t	master_func_wait_period;
+	uint32_t	normal_func_wait_period;
+	uint32_t	master_func_wait_period_after_reset;
+	uint32_t	max_bailout_time_after_reset;
+#define BNXT_FW_STATUS_REG		0
+#define BNXT_FW_HEARTBEAT_CNT_REG	1
+#define BNXT_FW_RECOVERY_CNT_REG	2
+#define BNXT_FW_RESET_INPROG_REG	3
+	uint32_t	status_regs[4];
+	uint32_t	reset_inprogress_reg_mask;
+#define BNXT_NUM_RESET_REG	16
+	uint8_t		reg_array_cnt;
+	uint32_t	reset_reg[BNXT_NUM_RESET_REG];
+	uint32_t	reset_reg_val[BNXT_NUM_RESET_REG];
+	uint8_t		delay_after_reset[BNXT_NUM_RESET_REG];
+#define BNXT_FLAG_ERROR_RECOVERY_HOST	(1 << 0)
+#define BNXT_FLAG_ERROR_RECOVERY_CO_CPU	(1 << 1)
+	uint32_t	flags;
+};
+
 #define BNXT_HWRM_SHORT_REQ_LEN		sizeof(struct hwrm_short_input)
 struct bnxt {
 	void				*bar0;
@@ -371,6 +394,7 @@ struct bnxt {
 #define BNXT_FLAG_FW_RESET	(1 << 15)
 #define BNXT_FLAG_FATAL_ERROR	(1 << 16)
 #define BNXT_FLAG_FW_CAP_IF_CHANGE	(1 << 17)
+#define BNXT_FLAG_FW_CAP_ERROR_RECOVERY	(1 << 18)
 #define BNXT_FLAG_EXT_STATS_SUPPORTED	(1 << 29)
 #define BNXT_FLAG_NEW_RM	(1 << 30)
 #define BNXT_FLAG_INIT_DONE	(1U << 31)
@@ -477,6 +501,9 @@ struct bnxt {
 
 	uint16_t		fw_reset_min_msecs;
 	uint16_t		fw_reset_max_msecs;
+
+	/* Struct to hold adapter error recovery related info */
+	struct bnxt_error_recovery_info *recovery_info;
 };
 
 int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete);
drivers/net/bnxt/bnxt_ethdev.c +10 -0
index a917e0440..7a1142947 100644
@@ -4070,6 +4070,11 @@ static int bnxt_init_fw(struct bnxt *bp)
 	if (rc)
 		return rc;
 
+	/* Get the adapter error recovery support info */
+	rc = bnxt_hwrm_error_recovery_qcfg(bp);
+	if (rc)
+		bp->flags &= ~BNXT_FLAG_FW_CAP_ERROR_RECOVERY;
+
 	if (mtu >= RTE_ETHER_MIN_MTU && mtu <= BNXT_MAX_MTU &&
 	    mtu != bp->eth_dev->data->mtu)
 		bp->eth_dev->data->mtu = mtu;
@@ -4227,6 +4232,11 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev)
 	if (!reconfig_dev)
 		bnxt_free_hwrm_resources(bp);
 
+	if (bp->recovery_info != NULL) {
+		rte_free(bp->recovery_info);
+		bp->recovery_info = NULL;
+	}
+
 	return rc;
 }
 
drivers/net/bnxt/bnxt_hwrm.c +89 -0

98 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.h +1 -0
index 2f57e950b..c332c129d 100644
@@ -202,4 +202,5 @@ int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
 				   uint16_t *dst_fid);
 int bnxt_hwrm_set_mac(struct bnxt *bp);
 int bnxt_hwrm_if_change(struct bnxt *bp, bool state);
+int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp);
 #endif
Signature · 1 line
2.20.1 (Apple Git-117)
#10 lore raw

PATCH v2 7/13 net/bnxt: map status registers for FW health monitoring

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

HWRM_ERROR_RECOVERY_QCFG command returns the FW status registers offset for periodic firmware health check monitoring. Map them to GRC window 2.

---
 drivers/net/bnxt/bnxt.h        | 22 ++++++++++++++++-
 drivers/net/bnxt/bnxt_ethdev.c | 44 ++++++++++++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.c   |  4 ++++
 3 files changed, 69 insertions(+), 1 deletion(-)
drivers/net/bnxt/bnxt.h +21 -1
index 19bd13a7f..1da09569d 100644
@@ -354,7 +354,9 @@ struct bnxt_error_recovery_info {
 #define BNXT_FW_HEARTBEAT_CNT_REG	1
 #define BNXT_FW_RECOVERY_CNT_REG	2
 #define BNXT_FW_RESET_INPROG_REG	3
-	uint32_t	status_regs[4];
+#define BNXT_FW_STATUS_REG_CNT		4
+	uint32_t	status_regs[BNXT_FW_STATUS_REG_CNT];
+	uint32_t	mapped_status_regs[BNXT_FW_STATUS_REG_CNT];
 	uint32_t	reset_inprogress_reg_mask;
 #define BNXT_NUM_RESET_REG	16
 	uint8_t		reg_array_cnt;
@@ -366,6 +368,22 @@ struct bnxt_error_recovery_info {
 	uint32_t	flags;
 };
 
+/* address space location of register */
+#define BNXT_FW_STATUS_REG_TYPE_MASK	3
+/* register is located in PCIe config space */
+#define BNXT_FW_STATUS_REG_TYPE_CFG	0
+/* register is located in GRC address space */
+#define BNXT_FW_STATUS_REG_TYPE_GRC	1
+/* register is located in BAR0  */
+#define BNXT_FW_STATUS_REG_TYPE_BAR0	2
+/* register is located in BAR1  */
+#define BNXT_FW_STATUS_REG_TYPE_BAR1	3
+
+#define BNXT_FW_STATUS_REG_TYPE(reg)	((reg) & BNXT_FW_STATUS_REG_TYPE_MASK)
+#define BNXT_FW_STATUS_REG_OFF(reg)	((reg) & ~BNXT_FW_STATUS_REG_TYPE_MASK)
+
+#define BNXT_GRCP_WINDOW_2_BASE		0x2000
+
 #define BNXT_HWRM_SHORT_REQ_LEN		sizeof(struct hwrm_short_input)
 struct bnxt {
 	void				*bar0;
@@ -510,6 +528,8 @@ int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete);
 int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id, void *msg);
 int is_bnxt_in_error(struct bnxt *bp);
 
+int bnxt_map_fw_health_status_regs(struct bnxt *bp);
+
 bool is_bnxt_supported(struct rte_eth_dev *dev);
 bool bnxt_stratus_device(struct bnxt *bp);
 extern const struct rte_flow_ops bnxt_flow_ops;
drivers/net/bnxt/bnxt_ethdev.c +44 -0

56 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.c +4 -0
index e2c993936..2d9c43c98 100644
@@ -4767,6 +4767,10 @@ int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp)
 err:
 	HWRM_UNLOCK();
 
+	/* Map the FW status registers */
+	if (!rc)
+		rc = bnxt_map_fw_health_status_regs(bp);
+
 	if (rc) {
 		rte_free(bp->recovery_info);
 		bp->recovery_info = NULL;
Signature · 1 line
2.20.1 (Apple Git-117)
#11 lore raw

PATCH v2 8/13 net/bnxt: advertise error recovery capability and handle async event

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

1. Advertise HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_ERROR_RECOVERY_SUPPORT flag in the FUNC_DRV_RGTR command.
2. request for the async event ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY in the FUNC_DRV_RGTR command.
3. handle the async event EVENT_ID_ERROR_RECOVERY from FW.

Error recovery support will be used by firmware only if all the driver instances support error recovery process.

---
 drivers/net/bnxt/bnxt.h      |  2 ++
 drivers/net/bnxt/bnxt_cpr.c  | 45 ++++++++++++++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_cpr.h  | 12 ++++++++++
 drivers/net/bnxt/bnxt_hwrm.c |  5 ++++
 drivers/net/bnxt/bnxt_hwrm.h |  2 ++
 5 files changed, 66 insertions(+)
drivers/net/bnxt/bnxt.h +2 -0
index 1da09569d..f9147a9a8 100644
@@ -365,6 +365,8 @@ struct bnxt_error_recovery_info {
 	uint8_t		delay_after_reset[BNXT_NUM_RESET_REG];
 #define BNXT_FLAG_ERROR_RECOVERY_HOST	(1 << 0)
 #define BNXT_FLAG_ERROR_RECOVERY_CO_CPU	(1 << 1)
+#define BNXT_FLAG_MASTER_FUNC		(1 << 2)
+#define BNXT_FLAG_RECOVERY_ENABLED	(1 << 3)
 	uint32_t	flags;
 };
 
drivers/net/bnxt/bnxt_cpr.c +45 -0

60 lines not on this page · raw message

drivers/net/bnxt/bnxt_cpr.h +12 -0
index b61bafa0e..f118bda36 100644
@@ -113,4 +113,16 @@ void bnxt_dev_reset_and_resume(void *arg);
 #define EVENT_DATA1_REASON_CODE_MASK                   \
 	HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MASK
 
+#define EVENT_DATA1_FLAGS_MASK                         \
+	HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_MASK
+
+#define EVENT_DATA1_FLAGS_MASTER_FUNC                  \
+	HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_MASTER_FUNC
+
+#define EVENT_DATA1_FLAGS_RECOVERY_ENABLED             \
+	HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_RECOVERY_ENABLED
+
+bool bnxt_is_recovery_enabled(struct bnxt *bp);
+bool bnxt_is_master_func(struct bnxt *bp);
+
 #endif
drivers/net/bnxt/bnxt_hwrm.c +5 -0
index 2d9c43c98..350e867bf 100644
@@ -685,6 +685,8 @@ int bnxt_hwrm_func_driver_register(struct bnxt *bp)
 		return 0;
 
 	flags = HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_HOT_RESET_SUPPORT;
+	if (bp->flags & BNXT_FLAG_FW_CAP_ERROR_RECOVERY)
+		flags |= HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_ERROR_RECOVERY_SUPPORT;
 
 	HWRM_PREP(req, FUNC_DRV_RGTR, BNXT_USE_CHIMP_MB);
 	req.enables = rte_cpu_to_le_32(HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VER |
@@ -716,6 +718,9 @@ int bnxt_hwrm_func_driver_register(struct bnxt *bp)
 				 ASYNC_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED |
 				 ASYNC_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE |
 				 ASYNC_CMPL_EVENT_ID_RESET_NOTIFY);
+	if (bp->flags & BNXT_FLAG_FW_CAP_ERROR_RECOVERY)
+		req.async_event_fwd[0] |=
+			rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_ERROR_RECOVERY);
 	req.async_event_fwd[1] |=
 		rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_PF_DRVR_UNLOAD |
 				 ASYNC_CMPL_EVENT_ID_VF_CFG_CHANGE);
drivers/net/bnxt/bnxt_hwrm.h +2 -0
index c332c129d..44e335507 100644
@@ -23,6 +23,8 @@ struct bnxt_cp_ring_info;
 	(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE)
 #define ASYNC_CMPL_EVENT_ID_RESET_NOTIFY \
 	(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY)
+#define ASYNC_CMPL_EVENT_ID_ERROR_RECOVERY \
+	(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY)
 #define ASYNC_CMPL_EVENT_ID_PF_DRVR_UNLOAD	\
 	(1 << (HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD - 32))
 #define ASYNC_CMPL_EVENT_ID_VF_CFG_CHANGE	\
Signature · 1 line
2.20.1 (Apple Git-117)
#12 lore raw

PATCH v2 9/13 net/bnxt: add code for periodic FW health monitoring

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

Periodically poll the FW heartbeat register and FW recovery counter registers to check the FW health. Polling frequency will be advertised by the FW in HWRM_ERROR_RECOVERY_QCFG response. Schedule the task upon receiving the async event from FW.

---
 drivers/net/bnxt/bnxt.h        |  6 +++
 drivers/net/bnxt/bnxt_cpr.c    | 10 ++++
 drivers/net/bnxt/bnxt_ethdev.c | 89 ++++++++++++++++++++++++++++++++++
 3 files changed, 105 insertions(+)
drivers/net/bnxt/bnxt.h +6 -0
index f9147a9a8..5579e127c 100644
@@ -368,6 +368,9 @@ struct bnxt_error_recovery_info {
 #define BNXT_FLAG_MASTER_FUNC		(1 << 2)
 #define BNXT_FLAG_RECOVERY_ENABLED	(1 << 3)
 	uint32_t	flags;
+
+	uint32_t        last_heart_beat;
+	uint32_t        last_reset_counter;
 };
 
 /* address space location of register */
@@ -415,6 +418,7 @@ struct bnxt {
 #define BNXT_FLAG_FATAL_ERROR	(1 << 16)
 #define BNXT_FLAG_FW_CAP_IF_CHANGE	(1 << 17)
 #define BNXT_FLAG_FW_CAP_ERROR_RECOVERY	(1 << 18)
+#define BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED	(1 << 19)
 #define BNXT_FLAG_EXT_STATS_SUPPORTED	(1 << 29)
 #define BNXT_FLAG_NEW_RM	(1 << 30)
 #define BNXT_FLAG_INIT_DONE	(1U << 31)
@@ -531,6 +535,8 @@ int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id, void *msg);
 int is_bnxt_in_error(struct bnxt *bp);
 
 int bnxt_map_fw_health_status_regs(struct bnxt *bp);
+uint32_t bnxt_read_fw_status_reg(struct bnxt *bp, uint32_t index);
+void bnxt_schedule_fw_health_check(struct bnxt *bp);
 
 bool is_bnxt_supported(struct rte_eth_dev *dev);
 bool bnxt_stratus_device(struct bnxt *bp);
drivers/net/bnxt/bnxt_cpr.c +10 -0
index a70301adc..3cedb891e 100644
@@ -90,6 +90,16 @@ void bnxt_handle_async_event(struct bnxt *bp,
 		PMD_DRV_LOG(INFO, "recovery enabled(%d), master function(%d)\n",
 			    bnxt_is_recovery_enabled(bp),
 			    bnxt_is_master_func(bp));
+
+		if (bp->flags & BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED)
+			return;
+
+		info->last_heart_beat =
+			bnxt_read_fw_status_reg(bp, BNXT_FW_HEARTBEAT_CNT_REG);
+		info->last_reset_counter =
+			bnxt_read_fw_status_reg(bp, BNXT_FW_RECOVERY_CNT_REG);
+
+		bnxt_schedule_fw_health_check(bp);
 		break;
 	default:
 		PMD_DRV_LOG(INFO, "handle_async_event id = 0x%x\n", event_id);
drivers/net/bnxt/bnxt_ethdev.c +89 -0

101 lines not on this page · raw message

Signature · 1 line
2.20.1 (Apple Git-117)
#13 lore raw

PATCH v2 10/13 net/bnxt: add support for FW reset

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

Added code to perform FW_RESET. When the driver detects error in FW, it has to initiate the recovery by resetting the cores. FW advertise the method to do a core reset, reset register offsets and values to perform reset in response of HWRM_ERROR_RECOVERY_QCFG command.

There are 2 ways to recover from the error.
1. Master function issues core resets to recover from error.
2. Master function detects chimp dead condition and notify the Kong processor about the chimp dead case through FW_RESET HWRM command. Kong Processor send an RESET_NOTIFY async event with REASON_CODE_FW_EXCEPTION_FATAL to all the PF’s/VF’s that chimp is dead and it is going to reset the chimp.

---
 drivers/net/bnxt/bnxt.h        |   1 +
 drivers/net/bnxt/bnxt_ethdev.c | 104 ++++++++++++++++++++++++++++++++-
 drivers/net/bnxt/bnxt_hwrm.c   |  26 +++++++++
 drivers/net/bnxt/bnxt_hwrm.h   |   1 +
 4 files changed, 131 insertions(+), 1 deletion(-)
drivers/net/bnxt/bnxt.h +1 -0
index 5579e127c..a1a8cd534 100644
@@ -388,6 +388,7 @@ struct bnxt_error_recovery_info {
 #define BNXT_FW_STATUS_REG_OFF(reg)	((reg) & ~BNXT_FW_STATUS_REG_TYPE_MASK)
 
 #define BNXT_GRCP_WINDOW_2_BASE		0x2000
+#define BNXT_GRCP_WINDOW_3_BASE		0x3000
 
 #define BNXT_HWRM_SHORT_REQ_LEN		sizeof(struct hwrm_short_input)
 struct bnxt {
drivers/net/bnxt/bnxt_ethdev.c +103 -1

134 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.c +26 -0
index 350e867bf..bd2cc01e1 100644
@@ -4782,3 +4782,29 @@ int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp)
 	}
 	return rc;
 }
+
+int bnxt_hwrm_fw_reset(struct bnxt *bp)
+{
+	struct hwrm_fw_reset_output *resp = bp->hwrm_cmd_resp_addr;
+	struct hwrm_fw_reset_input req = {0};
+	int rc;
+
+	if (!BNXT_PF(bp))
+		return -EOPNOTSUPP;
+
+	HWRM_PREP(req, FW_RESET, BNXT_USE_KONG(bp));
+
+	req.embedded_proc_type =
+		HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_CHIP;
+	req.selfrst_status =
+		HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTASAP;
+	req.flags = HWRM_FW_RESET_INPUT_FLAGS_RESET_GRACEFUL;
+
+	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req),
+				    BNXT_USE_KONG(bp));
+
+	HWRM_CHECK_RESULT();
+	HWRM_UNLOCK();
+
+	return rc;
+}
drivers/net/bnxt/bnxt_hwrm.h +1 -0
index 44e335507..db25ad591 100644
@@ -205,4 +205,5 @@ int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
 int bnxt_hwrm_set_mac(struct bnxt *bp);
 int bnxt_hwrm_if_change(struct bnxt *bp, bool state);
 int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp);
+int bnxt_hwrm_fw_reset(struct bnxt *bp);
 #endif
Signature · 1 line
2.20.1 (Apple Git-117)
#14 lore raw

PATCH v2 11/13 net/bnxt: reduce verbosity of logs

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

When IOMMU is available, EAL picks IOVA as VA as the default IOVA mode. This causes the bnxt driver to log warning messages saying "Memzone physical address same as virtual." and "Using rte_mem_virt2iova()" during load.

Reduce the verbosity of logs to DEBUG.

---
 drivers/net/bnxt/bnxt_ethdev.c | 21 +++++++++------------
 drivers/net/bnxt/bnxt_ring.c   |  7 +++----
 drivers/net/bnxt/bnxt_vnic.c   |  7 +++----
 3 files changed, 15 insertions(+), 20 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +9 -12
index 76f9e197f..b94c9a122 100644
@@ -3890,10 +3890,9 @@ static int bnxt_alloc_ctx_mem_blk(__rte_unused struct bnxt *bp,
 		memset(mz->addr, 0, mz->len);
 		mz_phys_addr = mz->iova;
 		if ((unsigned long)mz->addr == mz_phys_addr) {
-			PMD_DRV_LOG(WARNING,
-				"Memzone physical address same as virtual.\n");
-			PMD_DRV_LOG(WARNING,
-				    "Using rte_mem_virt2iova()\n");
+			PMD_DRV_LOG(DEBUG,
+				    "physical address same as virtual\n");
+			PMD_DRV_LOG(DEBUG, "Using rte_mem_virt2iova()\n");
 			mz_phys_addr = rte_mem_virt2iova(mz->addr);
 			if (mz_phys_addr == RTE_BAD_IOVA) {
 				PMD_DRV_LOG(ERR,
@@ -3926,10 +3925,9 @@ static int bnxt_alloc_ctx_mem_blk(__rte_unused struct bnxt *bp,
 	memset(mz->addr, 0, mz->len);
 	mz_phys_addr = mz->iova;
 	if ((unsigned long)mz->addr == mz_phys_addr) {
-		PMD_DRV_LOG(WARNING,
+		PMD_DRV_LOG(DEBUG,
 			    "Memzone physical address same as virtual.\n");
-		PMD_DRV_LOG(WARNING,
-			    "Using rte_mem_virt2iova()\n");
+		PMD_DRV_LOG(DEBUG, "Using rte_mem_virt2iova()\n");
 		for (sz = 0; sz < mem_size; sz += BNXT_PAGE_SIZE)
 			rte_mem_lock_page(((char *)mz->addr) + sz);
 		mz_phys_addr = rte_mem_virt2iova(mz->addr);
@@ -4117,9 +4115,9 @@ static int bnxt_alloc_stats_mem(struct bnxt *bp)
 	memset(mz->addr, 0, mz->len);
 	mz_phys_addr = mz->iova;
 	if ((unsigned long)mz->addr == mz_phys_addr) {
-		PMD_DRV_LOG(WARNING,
+		PMD_DRV_LOG(DEBUG,
 			    "Memzone physical address same as virtual.\n");
-		PMD_DRV_LOG(WARNING,
+		PMD_DRV_LOG(DEBUG,
 			    "Using rte_mem_virt2iova()\n");
 		mz_phys_addr = rte_mem_virt2iova(mz->addr);
 		if (mz_phys_addr == RTE_BAD_IOVA) {
@@ -4155,10 +4153,9 @@ static int bnxt_alloc_stats_mem(struct bnxt *bp)
 	memset(mz->addr, 0, mz->len);
 	mz_phys_addr = mz->iova;
 	if ((unsigned long)mz->addr == mz_phys_addr) {
-		PMD_DRV_LOG(WARNING,
+		PMD_DRV_LOG(DEBUG,
 			    "Memzone physical address same as virtual\n");
-		PMD_DRV_LOG(WARNING,
-			    "Using rte_mem_virt2iova()\n");
+		PMD_DRV_LOG(DEBUG, "Using rte_mem_virt2iova()\n");
 		mz_phys_addr = rte_mem_virt2iova(mz->addr);
 		if (mz_phys_addr == RTE_BAD_IOVA) {
 			PMD_DRV_LOG(ERR,
drivers/net/bnxt/bnxt_ring.c +3 -4
index f19865c83..2f57e038a 100644
@@ -212,10 +212,9 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
 	mz_phys_addr_base = mz->iova;
 	mz_phys_addr = mz->iova;
 	if ((unsigned long)mz->addr == mz_phys_addr_base) {
-		PMD_DRV_LOG(WARNING,
-			"Memzone physical address same as virtual.\n");
-		PMD_DRV_LOG(WARNING,
-			"Using rte_mem_virt2iova()\n");
+		PMD_DRV_LOG(DEBUG,
+			    "Memzone physical address same as virtual.\n");
+		PMD_DRV_LOG(DEBUG, "Using rte_mem_virt2iova()\n");
 		for (sz = 0; sz < total_alloc_len; sz += getpagesize())
 			rte_mem_lock_page(((char *)mz->addr) + sz);
 		mz_phys_addr_base = rte_mem_virt2iova(mz->addr);
drivers/net/bnxt/bnxt_vnic.c +3 -4
index 98415633e..9ea99388b 100644
@@ -150,10 +150,9 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp)
 	}
 	mz_phys_addr = mz->iova;
 	if ((unsigned long)mz->addr == mz_phys_addr) {
-		PMD_DRV_LOG(WARNING,
-			"Memzone physical address same as virtual.\n");
-		PMD_DRV_LOG(WARNING,
-			"Using rte_mem_virt2iova()\n");
+		PMD_DRV_LOG(DEBUG,
+			    "Memzone physical address same as virtual.\n");
+		PMD_DRV_LOG(DEBUG, "Using rte_mem_virt2iova()\n");
 		mz_phys_addr = rte_mem_virt2iova(mz->addr);
 		if (mz_phys_addr == RTE_BAD_IOVA) {
 			PMD_DRV_LOG(ERR,
Signature · 1 line
2.20.1 (Apple Git-117)
#15 lore raw

PATCH v2 12/13 net/bnxt: use BIT macro instead of bit fields

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

use BIT macro instead of bit fields.

---
 drivers/net/bnxt/bnxt.h      | 75 ++++++++++++++++++------------------
 drivers/net/bnxt/bnxt_util.h |  4 ++
 2 files changed, 42 insertions(+), 37 deletions(-)
drivers/net/bnxt/bnxt.h +38 -37
index a1a8cd534..ac602fe52 100644
@@ -19,6 +19,7 @@
 #include <rte_time.h>
 
 #include "bnxt_cpr.h"
+#include "bnxt_util.h"
 
 #define BNXT_MAX_MTU		9574
 #define VLAN_TAG_SIZE		4
@@ -198,16 +199,16 @@ struct bnxt_ptp_cfg {
 	struct bnxt		*bp;
 #define BNXT_MAX_TX_TS	1
 	uint16_t			rxctl;
-#define BNXT_PTP_MSG_SYNC			(1 << 0)
-#define BNXT_PTP_MSG_DELAY_REQ			(1 << 1)
-#define BNXT_PTP_MSG_PDELAY_REQ			(1 << 2)
-#define BNXT_PTP_MSG_PDELAY_RESP		(1 << 3)
-#define BNXT_PTP_MSG_FOLLOW_UP			(1 << 8)
-#define BNXT_PTP_MSG_DELAY_RESP			(1 << 9)
-#define BNXT_PTP_MSG_PDELAY_RESP_FOLLOW_UP	(1 << 10)
-#define BNXT_PTP_MSG_ANNOUNCE			(1 << 11)
-#define BNXT_PTP_MSG_SIGNALING			(1 << 12)
-#define BNXT_PTP_MSG_MANAGEMENT			(1 << 13)
+#define BNXT_PTP_MSG_SYNC			BIT(0)
+#define BNXT_PTP_MSG_DELAY_REQ			BIT(1)
+#define BNXT_PTP_MSG_PDELAY_REQ			BIT(2)
+#define BNXT_PTP_MSG_PDELAY_RESP		BIT(3)
+#define BNXT_PTP_MSG_FOLLOW_UP			BIT(8)
+#define BNXT_PTP_MSG_DELAY_RESP			BIT(9)
+#define BNXT_PTP_MSG_PDELAY_RESP_FOLLOW_UP	BIT(10)
+#define BNXT_PTP_MSG_ANNOUNCE			BIT(11)
+#define BNXT_PTP_MSG_SIGNALING			BIT(12)
+#define BNXT_PTP_MSG_MANAGEMENT			BIT(13)
 #define BNXT_PTP_MSG_EVENTS		(BNXT_PTP_MSG_SYNC |		\
 					 BNXT_PTP_MSG_DELAY_REQ |	\
 					 BNXT_PTP_MSG_PDELAY_REQ |	\
@@ -363,10 +364,10 @@ struct bnxt_error_recovery_info {
 	uint32_t	reset_reg[BNXT_NUM_RESET_REG];
 	uint32_t	reset_reg_val[BNXT_NUM_RESET_REG];
 	uint8_t		delay_after_reset[BNXT_NUM_RESET_REG];
-#define BNXT_FLAG_ERROR_RECOVERY_HOST	(1 << 0)
-#define BNXT_FLAG_ERROR_RECOVERY_CO_CPU	(1 << 1)
-#define BNXT_FLAG_MASTER_FUNC		(1 << 2)
-#define BNXT_FLAG_RECOVERY_ENABLED	(1 << 3)
+#define BNXT_FLAG_ERROR_RECOVERY_HOST	BIT(0)
+#define BNXT_FLAG_ERROR_RECOVERY_CO_CPU	BIT(1)
+#define BNXT_FLAG_MASTER_FUNC		BIT(2)
+#define BNXT_FLAG_RECOVERY_ENABLED	BIT(3)
 	uint32_t	flags;
 
 	uint32_t        last_heart_beat;
@@ -400,29 +401,29 @@ struct bnxt {
 	void				*doorbell_base;
 
 	uint32_t		flags;
-#define BNXT_FLAG_REGISTERED	(1 << 0)
-#define BNXT_FLAG_VF		(1 << 1)
-#define BNXT_FLAG_PORT_STATS	(1 << 2)
-#define BNXT_FLAG_JUMBO		(1 << 3)
-#define BNXT_FLAG_SHORT_CMD	(1 << 4)
-#define BNXT_FLAG_UPDATE_HASH	(1 << 5)
-#define BNXT_FLAG_PTP_SUPPORTED	(1 << 6)
-#define BNXT_FLAG_MULTI_HOST    (1 << 7)
-#define BNXT_FLAG_EXT_RX_PORT_STATS	(1 << 8)
-#define BNXT_FLAG_EXT_TX_PORT_STATS	(1 << 9)
-#define BNXT_FLAG_KONG_MB_EN	(1 << 10)
-#define BNXT_FLAG_TRUSTED_VF_EN	(1 << 11)
-#define BNXT_FLAG_DFLT_VNIC_SET	(1 << 12)
-#define BNXT_FLAG_THOR_CHIP	(1 << 13)
-#define BNXT_FLAG_STINGRAY	(1 << 14)
-#define BNXT_FLAG_FW_RESET	(1 << 15)
-#define BNXT_FLAG_FATAL_ERROR	(1 << 16)
-#define BNXT_FLAG_FW_CAP_IF_CHANGE	(1 << 17)
-#define BNXT_FLAG_FW_CAP_ERROR_RECOVERY	(1 << 18)
-#define BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED	(1 << 19)
-#define BNXT_FLAG_EXT_STATS_SUPPORTED	(1 << 29)
-#define BNXT_FLAG_NEW_RM	(1 << 30)
-#define BNXT_FLAG_INIT_DONE	(1U << 31)
+#define BNXT_FLAG_REGISTERED			BIT(0)
+#define BNXT_FLAG_VF				BIT(1)
+#define BNXT_FLAG_PORT_STATS			BIT(2)
+#define BNXT_FLAG_JUMBO				BIT(3)
+#define BNXT_FLAG_SHORT_CMD			BIT(4)
+#define BNXT_FLAG_UPDATE_HASH			BIT(5)
+#define BNXT_FLAG_PTP_SUPPORTED			BIT(6)
+#define BNXT_FLAG_MULTI_HOST    		BIT(7)
+#define BNXT_FLAG_EXT_RX_PORT_STATS		BIT(8)
+#define BNXT_FLAG_EXT_TX_PORT_STATS		BIT(9)
+#define BNXT_FLAG_KONG_MB_EN			BIT(10)
+#define BNXT_FLAG_TRUSTED_VF_EN			BIT(11)
+#define BNXT_FLAG_DFLT_VNIC_SET			BIT(12)
+#define BNXT_FLAG_THOR_CHIP			BIT(13)
+#define BNXT_FLAG_STINGRAY			BIT(14)
+#define BNXT_FLAG_FW_RESET			BIT(15)
+#define BNXT_FLAG_FATAL_ERROR			BIT(16)
+#define BNXT_FLAG_FW_CAP_IF_CHANGE		BIT(17)
+#define BNXT_FLAG_FW_CAP_ERROR_RECOVERY		BIT(18)
+#define BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED	BIT(19)
+#define BNXT_FLAG_EXT_STATS_SUPPORTED		BIT(20)
+#define BNXT_FLAG_NEW_RM			BIT(21)
+#define BNXT_FLAG_INIT_DONE			BIT(22)
 #define BNXT_PF(bp)		(!((bp)->flags & BNXT_FLAG_VF))
 #define BNXT_VF(bp)		((bp)->flags & BNXT_FLAG_VF)
 #define BNXT_NPAR(bp)		((bp)->port_partition_type)
drivers/net/bnxt/bnxt_util.h +4 -0
index 9f1868a78..a15b3a1a9 100644
@@ -6,6 +6,10 @@
 #ifndef _BNXT_UTIL_H_
 #define _BNXT_UTIL_H_
 
+#ifndef BIT
+#define BIT(n)	(1UL << (n))
+#endif /* BIT */
+
 int bnxt_check_zero_bytes(const uint8_t *bytes, int len);
 void bnxt_eth_hw_addr_random(uint8_t *mac_addr);
 
Signature · 1 line
2.20.1 (Apple Git-117)
#16 lore raw

PATCH v2 13/13 net/bnxt: avoid null pointer dereference

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

Commit "bd0a14c99f65" enables the creation of a dedicated completion ring for asynchronous event handling instead of handling these events on a receive completion ring on non Stingray Platforms.

This causes a segfault due to NULL pointer defreference in bnxt_alloc_async_cp_ring() on stingray. Fix this by checking the pointer validity before accessing it.

Fixes bd0a14c99f65 ("net/bnxt: use dedicated CPR for async events")
---
 drivers/net/bnxt/bnxt_ring.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt_ring.c +4 -2
index 2f57e038a..ec17783cf 100644
@@ -694,13 +694,15 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 int bnxt_alloc_async_cp_ring(struct bnxt *bp)
 {
 	struct bnxt_cp_ring_info *cpr = bp->async_cp_ring;
-	struct bnxt_ring *cp_ring = cpr->cp_ring_struct;
+	struct bnxt_ring *cp_ring;
 	uint8_t ring_type;
 	int rc;
 
-	if (BNXT_NUM_ASYNC_CPR(bp) == 0)
+	if (BNXT_NUM_ASYNC_CPR(bp) == 0 || cpr == NULL)
 		return 0;
 
+	cp_ring = cpr->cp_ring_struct;
+
 	if (BNXT_HAS_NQ(bp))
 		ring_type = HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ;
 	else
Signature · 1 line
2.20.1 (Apple Git-117)
#17 lore raw
In reply to Ajit Khaparde
Quoted 7 lines · Ajit Khaparde

This patchset adds support to monitor the health of the firmware and the underlying device and recover to an operational state in case of error. We can also detect if a FW upgrade is in progress and quiesce all access to the device and recover once FW indicates everything is ready.

Patchset against dpdk-next-net. Please apply.

Quoted 14 lines

Kalesh AP (13):
net/bnxt: add FW reset HWRM command
net/bnxt: prevent device access when device is in reset net/bnxt: handle reset notify async event from FW net/bnxt: inform firmware about IF state changes net/bnxt: handle fatal event from FW under error conditions net/bnxt: query firmware error recovery capabilities net/bnxt: map status registers for FW health monitoring net/bnxt: advertise error recovery capability and handle async event net/bnxt: add code for periodic FW health monitoring net/bnxt: add support for FW reset
net/bnxt: reduce verbosity of logs
net/bnxt: use BIT macro instead of bit fields
net/bnxt: avoid null pointer dereference

Hi Ajit, Kalesh,

Some APIs and dev_ops return types has been changed in the next-net, and the patch conflict because of those changes, can you please send a new version on top of latest next-net?

Thanks,
ferruh

#18 lore raw

v3 cover bnxt patchset to support device error recovery

This patchset adds support to monitor the health of the firmware and the underlying device and recover to an operational state in case of error. We can also detect if a FW upgrade is in progress and quiesce all access to the device and recover once FW indicates everything is ready.

Patchset against dpdk-next-net. Please apply.

v2->v3: Some APIs and dev_ops return types has been updated since
v2 was submitted. This version addresses the conflicts on account of that.

Kalesh AP (15):
net/bnxt: add FW reset HWRM command
net/bnxt: prevent device access when device is in reset net/bnxt: handle reset notify async event from FW net/bnxt: inform firmware about IF state changes net/bnxt: handle fatal event from FW under error conditions net/bnxt: query firmware error recovery capabilities net/bnxt: map status registers for FW health monitoring net/bnxt: advertise error recovery capability and handle async event net/bnxt: add code for periodic FW health monitoring net/bnxt: add support for FW reset
net/bnxt: add hot firmware upgrade support for Stingray net/bnxt: reduce verbosity of logs
net/bnxt: avoid null pointer dereference
net/bnxt: use BIT macro instead of bit fields
net/bnxt: add PTP support for Thor

 drivers/net/bnxt/bnxt.h                |  142 +++-
 drivers/net/bnxt/bnxt_cpr.c            |  122 ++-
 drivers/net/bnxt/bnxt_cpr.h            |   19 +
 drivers/net/bnxt/bnxt_ethdev.c         | 1066 ++++++++++++++++++------
 drivers/net/bnxt/bnxt_filter.c         |    2 +-
 drivers/net/bnxt/bnxt_hwrm.c           |  310 ++++++-
 drivers/net/bnxt/bnxt_hwrm.h           |    9 +
 drivers/net/bnxt/bnxt_ring.c           |   45 +-
 drivers/net/bnxt/bnxt_ring.h           |    1 +
 drivers/net/bnxt/bnxt_rxq.c            |   25 +
 drivers/net/bnxt/bnxt_rxr.c            |   59 +-
 drivers/net/bnxt/bnxt_rxr.h            |    2 +
 drivers/net/bnxt/bnxt_stats.c          |   36 +-
 drivers/net/bnxt/bnxt_txq.c            |    7 +
 drivers/net/bnxt/bnxt_txr.c            |   34 +-
 drivers/net/bnxt/bnxt_txr.h            |    2 +
 drivers/net/bnxt/bnxt_util.h           |    4 +
 drivers/net/bnxt/bnxt_vnic.c           |    7 +-
 drivers/net/bnxt/hsi_struct_def_dpdk.h |  242 ++++++
 19 files changed, 1816 insertions(+), 318 deletions(-)
Signature · 1 line
2.20.1 (Apple Git-117)
#19 lore raw

PATCH v3 1/15 net/bnxt: add FW reset HWRM command

From: Kalesh AP <[email protected]>

This patch adds new FW reset HWRM command. Code using this command will be added in future patch.

---
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 137 +++++++++++++++++++++++++
 1 file changed, 137 insertions(+)
drivers/net/bnxt/hsi_struct_def_dpdk.h +137 -0
index 6c98c1d6dd..0095717254 100644
@@ -33621,4 +33621,141 @@ struct hwrm_nvm_validate_option_cmd_err {
 	uint8_t	unused_0[7];
 } __attribute__((packed));
 
+/*****************
+ * hwrm_fw_reset *
+ ******************/
+
+
+/* hwrm_fw_reset_input (size:192b/24B) */
+struct hwrm_fw_reset_input {
+	/* The HWRM command request type. */
+	uint16_t        req_type;
+	/*
+	 * The completion ring to send the completion event on. This should
+	 * be the NQ ID returned from the `nq_alloc` HWRM command.
+	 */
+	uint16_t        cmpl_ring;
+	/*
+	 * The sequence ID is used by the driver for tracking multiple
+	 * commands. This ID is treated as opaque data by the firmware and
+	 * the value is returned in the `hwrm_resp_hdr` upon completion.
+	 */
+	uint16_t        seq_id;
+	/*
+	 * The target ID of the command:
+	 * * 0x0-0xFFF8 - The function ID
+	 * * 0xFFF8-0xFFFE - Reserved for internal processors
+	 * * 0xFFFF - HWRM
+	 */
+	uint16_t        target_id;
+	/*
+	 * A physical address pointer pointing to a host buffer that the
+	 * command's response data will be written. This can be either a host
+	 * physical address (HPA) or a guest physical address (GPA) and must
+	 * point to a physically contiguous block of memory.
+	 */
+	uint64_t        resp_addr;
+	/* Type of embedded processor. */
+	uint8_t embedded_proc_type;
+	/* Boot Processor */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_BOOT \
+		UINT32_C(0x0)
+	/* Management Processor */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_MGMT \
+		UINT32_C(0x1)
+	/* Network control processor */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_NETCTRL \
+		UINT32_C(0x2)
+	/* RoCE control processor */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_ROCE \
+		UINT32_C(0x3)
+	/*
+	 * Host (in multi-host environment): This is only valid if requester is IPC.
+	 * Reinit host hardware resources and PCIe.
+	 */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_HOST \
+		UINT32_C(0x4)
+	/* AP processor complex (in multi-host environment). Use host_idx to control which core is reset */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_AP \
+		UINT32_C(0x5)
+	/* Reset all blocks of the chip (including all processors) */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_CHIP \
+		UINT32_C(0x6)
+	/*
+	 * Host (in multi-host environment): This is only valid if requester is IPC.
+	 * Reinit host hardware resources.
+	 */
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_HOST_RESOURCE_REINIT \
+		UINT32_C(0x7)
+	#define HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_LAST \
+		HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_HOST_RESOURCE_REINIT
+	/* Type of self reset. */
+	uint8_t selfrst_status;
+	/* No Self Reset */
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTNONE \
+		UINT32_C(0x0)
+	/* Self Reset as soon as possible to do so safely */
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTASAP \
+		UINT32_C(0x1)
+	/* Self Reset on PCIe Reset */
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTPCIERST \
+		UINT32_C(0x2)
+	/* Self Reset immediately after notification to all clients. */
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTIMMEDIATE \
+		UINT32_C(0x3)
+	#define HWRM_FW_RESET_INPUT_SELFRST_STATUS_LAST \
+		HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTIMMEDIATE
+	/*
+	 * Indicate which host is being reset. 0 means first host.
+	 * Only valid when embedded_proc_type is host in multihost
+	 * environment
+	 */
+	uint8_t host_idx;
+	uint8_t flags;
+	/*
+	 * When this bit is '1', then the core firmware initiates
+	 * the reset only after graceful shut down of all registered instances.
+	 * If not, the device will continue with the existing firmware.
+	 */
+	#define HWRM_FW_RESET_INPUT_FLAGS_RESET_GRACEFUL     UINT32_C(0x1)
+	uint8_t unused_0[4];
+} __attribute__((packed));
+
+/* hwrm_fw_reset_output (size:128b/16B) */
+struct hwrm_fw_reset_output {
+	/* The specific error status for the command. */
+	uint16_t        error_code;
+	/* The HWRM command request type. */
+	uint16_t        req_type;
+	/* The sequence ID from the original command. */
+	uint16_t        seq_id;
+	/* The length of the response data in number of bytes. */
+	uint16_t        resp_len;
+	/* Type of self reset. */
+	uint8_t selfrst_status;
+	/* No Self Reset */
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTNONE \
+		UINT32_C(0x0)
+	/* Self Reset as soon as possible to do so safely */
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTASAP \
+		UINT32_C(0x1)
+	/* Self Reset on PCIe Reset */
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTPCIERST \
+		UINT32_C(0x2)
+	/* Self Reset immediately after notification to all clients. */
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTIMMEDIATE \
+		UINT32_C(0x3)
+	#define HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_LAST \
+		HWRM_FW_RESET_OUTPUT_SELFRST_STATUS_SELFRSTIMMEDIATE
+	uint8_t unused_0[6];
+	/*
+	 * This field is used in Output records to indicate that the output
+	 * is completely written to RAM.  This field should be read as '1'
+	 * to indicate that the output has been completely written.
+	 * When writing a command completion or response to an internal processor,
+	 * the order of writes has to be such that this field is written last.
+	 */
+	uint8_t valid;
+} __attribute__((packed));
+
 #endif /* _HSI_STRUCT_DEF_DPDK_H_ */
Signature · 1 line
2.20.1 (Apple Git-117)
#20 lore raw

PATCH v3 2/15 net/bnxt: prevent device access when device is in reset

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

Refactor init and uninit functions so that the driver can fail the eth_dev_ops callbacks and accessing Tx and Rx queues when device is in reset or in error state.

Transmit and receive queues are freed during reset cleanup and reallocated during recovery. So we block all data path handling in this state. The eth_dev dev_started field is updated depending on the status of the device.

---
 drivers/net/bnxt/bnxt.h        |   3 +
 drivers/net/bnxt/bnxt_cpr.c    |   3 +
 drivers/net/bnxt/bnxt_ethdev.c | 461 ++++++++++++++++++++++-----------
 drivers/net/bnxt/bnxt_hwrm.c   |   2 -
 drivers/net/bnxt/bnxt_ring.c   |  32 +++
 drivers/net/bnxt/bnxt_ring.h   |   1 +
 drivers/net/bnxt/bnxt_rxq.c    |  25 ++
 drivers/net/bnxt/bnxt_rxr.c    |  17 ++
 drivers/net/bnxt/bnxt_rxr.h    |   2 +
 drivers/net/bnxt/bnxt_stats.c  |  36 ++-
 drivers/net/bnxt/bnxt_txq.c    |   7 +
 drivers/net/bnxt/bnxt_txr.c    |  27 ++
 drivers/net/bnxt/bnxt_txr.h    |   2 +
 13 files changed, 465 insertions(+), 153 deletions(-)
drivers/net/bnxt/bnxt.h +3 -0
index 0c9f994eaa..37b4c717d6 100644
@@ -358,6 +358,8 @@ struct bnxt {
 #define BNXT_FLAG_DFLT_VNIC_SET	(1 << 12)
 #define BNXT_FLAG_THOR_CHIP	(1 << 13)
 #define BNXT_FLAG_STINGRAY	(1 << 14)
+#define BNXT_FLAG_FW_RESET	(1 << 15)
+#define BNXT_FLAG_FATAL_ERROR	(1 << 16)
 #define BNXT_FLAG_EXT_STATS_SUPPORTED	(1 << 29)
 #define BNXT_FLAG_NEW_RM	(1 << 30)
 #define BNXT_FLAG_INIT_DONE	(1U << 31)
@@ -465,6 +467,7 @@ struct bnxt {
 
 int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete);
 int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id, void *msg);
+int is_bnxt_in_error(struct bnxt *bp);
 
 bool is_bnxt_supported(struct rte_eth_dev *dev);
 bool bnxt_stratus_device(struct bnxt *bp);
drivers/net/bnxt/bnxt_cpr.c +3 -0
index 655bcf1a8d..bbcdb42f10 100644
@@ -142,6 +142,9 @@ int bnxt_event_hwrm_resp_handler(struct bnxt *bp, struct cmpl_base *cmp)
 		return evt;
 	}
 
+	if (unlikely(is_bnxt_in_error(bp)))
+		return 0;
+
 	switch (CMP_TYPE(cmp)) {
 	case CMPL_BASE_TYPE_HWRM_ASYNC_EVENT:
 		/* Handle any async event */
drivers/net/bnxt/bnxt_ethdev.c +311 -150

757 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.c +0 -2
index 9883fb5063..24a5a09147 100644
@@ -964,8 +964,6 @@ int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, uint32_t flags)
 	HWRM_CHECK_RESULT();
 	HWRM_UNLOCK();
 
-	bp->flags &= ~BNXT_FLAG_REGISTERED;
-
 	return rc;
 }
 
drivers/net/bnxt/bnxt_ring.c +32 -0
index be15b4bd14..f19865c832 100644
@@ -50,6 +50,38 @@ int bnxt_init_ring_grps(struct bnxt *bp)
 	return 0;
 }
 
+int bnxt_alloc_ring_grps(struct bnxt *bp)
+{
+	if (bp->max_tx_rings == 0) {
+		PMD_DRV_LOG(ERR, "No TX rings available!\n");
+		return -EBUSY;
+	}
+
+	/* THOR does not support ring groups.
+	 * But we will use the array to save RSS context IDs.
+	 */
+	if (BNXT_CHIP_THOR(bp)) {
+		bp->max_ring_grps = BNXT_MAX_RSS_CTXTS_THOR;
+	} else if (bp->max_ring_grps < bp->rx_cp_nr_rings) {
+		/* 1 ring is for default completion ring */
+		PMD_DRV_LOG(ERR, "Insufficient resource: Ring Group\n");
+		return -ENOSPC;
+	}
+
+	if (BNXT_HAS_RING_GRPS(bp)) {
+		bp->grp_info = rte_zmalloc("bnxt_grp_info",
+					   sizeof(*bp->grp_info) *
+					   bp->max_ring_grps, 0);
+		if (!bp->grp_info) {
+			PMD_DRV_LOG(ERR,
+				    "Failed to alloc grp info tbl.\n");
+			return -ENOMEM;
+		}
+	}
+
+	return 0;
+}
+
 /*
  * Allocates a completion ring with vmem and stats optionally also allocating
  * a TX and/or RX ring.  Passing NULL as tx_ring_info and/or rx_ring_info
drivers/net/bnxt/bnxt_ring.h +1 -0
index 04c7b04b82..a31d59ea39 100644
@@ -67,6 +67,7 @@ struct bnxt_rx_ring_info;
 struct bnxt_cp_ring_info;
 void bnxt_free_ring(struct bnxt_ring *ring);
 int bnxt_init_ring_grps(struct bnxt *bp);
+int bnxt_alloc_ring_grps(struct bnxt *bp);
 int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
 			    struct bnxt_tx_queue *txq,
 			    struct bnxt_rx_queue *rxq,
drivers/net/bnxt/bnxt_rxq.c +25 -0
index 1d95f11394..d5fc5268db 100644
@@ -263,6 +263,9 @@ void bnxt_rx_queue_release_op(void *rx_queue)
 	struct bnxt_rx_queue *rxq = (struct bnxt_rx_queue *)rx_queue;
 
 	if (rxq) {
+		if (is_bnxt_in_error(rxq->bp))
+			return;
+
 		bnxt_rx_queue_release_mbufs(rxq);
 
 		/* Free RX ring hardware descriptors */
@@ -294,6 +297,10 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
 	int rc = 0;
 	uint8_t queue_state;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	if (queue_idx >= bp->max_rx_rings) {
 		PMD_DRV_LOG(ERR,
 			"Cannot create Rx ring %d. Only %d rings available\n",
@@ -363,10 +370,15 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
 int
 bnxt_rx_queue_intr_enable_op(struct rte_eth_dev *eth_dev, uint16_t queue_id)
 {
+	struct bnxt *bp = eth_dev->data->dev_private;
 	struct bnxt_rx_queue *rxq;
 	struct bnxt_cp_ring_info *cpr;
 	int rc = 0;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	if (eth_dev->data->rx_queues) {
 		rxq = eth_dev->data->rx_queues[queue_id];
 		if (!rxq) {
@@ -382,10 +394,15 @@ bnxt_rx_queue_intr_enable_op(struct rte_eth_dev *eth_dev, uint16_t queue_id)
 int
 bnxt_rx_queue_intr_disable_op(struct rte_eth_dev *eth_dev, uint16_t queue_id)
 {
+	struct bnxt *bp = eth_dev->data->dev_private;
 	struct bnxt_rx_queue *rxq;
 	struct bnxt_cp_ring_info *cpr;
 	int rc = 0;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	if (eth_dev->data->rx_queues) {
 		rxq = eth_dev->data->rx_queues[queue_id];
 		if (!rxq) {
@@ -406,6 +423,10 @@ int bnxt_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 	struct bnxt_vnic_info *vnic = NULL;
 	int rc = 0;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	if (rxq == NULL) {
 		PMD_DRV_LOG(ERR, "Invalid Rx queue %d\n", rx_queue_id);
 		return -EINVAL;
@@ -458,6 +479,10 @@ int bnxt_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 	struct bnxt_rx_queue *rxq = NULL;
 	int rc = 0;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	/* For the stingray platform and other platforms needing tighter
 	 * control of resource utilization, Rx CQ 0 also works as
 	 * Default CQ for async notifications
drivers/net/bnxt/bnxt_rxr.c +17 -0
index 185a0e376b..12313dd53c 100644
@@ -539,6 +539,9 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	int rc = 0;
 	bool evt = false;
 
+	if (unlikely(is_bnxt_in_error(rxq->bp)))
+		return 0;
+
 	/* If Rx Q was stopped return. RxQ0 cannot be stopped. */
 	if (unlikely(((rxq->rx_deferred_start ||
 		       !rte_spinlock_trylock(&rxq->lock)) &&
@@ -625,6 +628,20 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	return nb_rx_pkts;
 }
 
+/*
+ * Dummy DPDK callback for RX.
+ *
+ * This function is used to temporarily replace the real callback during
+ * unsafe control operations on the queue, or in case of error.
+ */
+uint16_t
+bnxt_dummy_recv_pkts(void *rx_queue __rte_unused,
+		     struct rte_mbuf **rx_pkts __rte_unused,
+		     uint16_t nb_pkts __rte_unused)
+{
+	return 0;
+}
+
 void bnxt_free_rx_rings(struct bnxt *bp)
 {
 	int i;
drivers/net/bnxt/bnxt_rxr.h +2 -0
index 6a80c37c81..493b754066 100644
@@ -185,6 +185,8 @@ struct bnxt_rx_ring_info {
 
 uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 			       uint16_t nb_pkts);
+uint16_t bnxt_dummy_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+			      uint16_t nb_pkts);
 void bnxt_free_rx_rings(struct bnxt *bp);
 int bnxt_init_rx_ring_struct(struct bnxt_rx_queue *rxq, unsigned int socket_id);
 int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq);
drivers/net/bnxt/bnxt_stats.c +35 -1
index 049ad9e398..21012e1fee 100644
@@ -353,6 +353,10 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev,
 	struct bnxt *bp = eth_dev->data->dev_private;
 	unsigned int num_q_stats;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	memset(bnxt_stats, 0, sizeof(*bnxt_stats));
 	if (!(bp->flags & BNXT_FLAG_INIT_DONE)) {
 		PMD_DRV_LOG(ERR, "Device Initialization not complete!\n");
@@ -398,6 +402,10 @@ int bnxt_stats_reset_op(struct rte_eth_dev *eth_dev)
 	unsigned int i;
 	int ret;
 
+	ret = is_bnxt_in_error(bp);
+	if (ret)
+		return ret;
+
 	if (!(bp->flags & BNXT_FLAG_INIT_DONE)) {
 		PMD_DRV_LOG(ERR, "Device Initialization not complete!\n");
 		return -EINVAL;
@@ -417,13 +425,17 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev,
 			   struct rte_eth_xstat *xstats, unsigned int n)
 {
 	struct bnxt *bp = eth_dev->data->dev_private;
-
 	unsigned int count, i;
 	uint64_t tx_drop_pkts;
 	unsigned int rx_port_stats_ext_cnt;
 	unsigned int tx_port_stats_ext_cnt;
 	unsigned int stat_size = sizeof(uint64_t);
 	unsigned int stat_count;
+	int rc;
+
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
 
 	memset(xstats, 0, sizeof(*xstats));
 
@@ -502,7 +514,13 @@ int bnxt_dev_xstats_get_names_op(__rte_unused struct rte_eth_dev *eth_dev,
 				RTE_DIM(bnxt_tx_stats_strings) + 1 +
 				RTE_DIM(bnxt_rx_ext_stats_strings) +
 				RTE_DIM(bnxt_tx_ext_stats_strings);
+	struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
 	unsigned int i, count;
+	int rc;
+
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
 
 	if (xstats_names != NULL) {
 		count = 0;
@@ -551,6 +569,10 @@ int bnxt_dev_xstats_reset_op(struct rte_eth_dev *eth_dev)
 	struct bnxt *bp = eth_dev->data->dev_private;
 	int ret;
 
+	ret = is_bnxt_in_error(bp);
+	if (ret)
+		return ret;
+
 	if (bp->flags & BNXT_FLAG_PORT_STATS && BNXT_SINGLE_PF(bp)) {
 		ret = bnxt_hwrm_port_clr_stats(bp);
 		if (ret != 0) {
@@ -586,9 +608,15 @@ int bnxt_dev_xstats_get_by_id_op(struct rte_eth_dev *dev, const uint64_t *ids,
 				RTE_DIM(bnxt_tx_stats_strings) + 1 +
 				RTE_DIM(bnxt_rx_ext_stats_strings) +
 				RTE_DIM(bnxt_tx_ext_stats_strings);
+	struct bnxt *bp = dev->data->dev_private;
 	struct rte_eth_xstat xstats[stat_cnt];
 	uint64_t values_copy[stat_cnt];
 	uint16_t i;
+	int rc;
+
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
 
 	if (!ids)
 		return bnxt_dev_xstats_get_op(dev, xstats, stat_cnt);
@@ -614,7 +642,13 @@ int bnxt_dev_xstats_get_names_by_id_op(struct rte_eth_dev *dev,
 				RTE_DIM(bnxt_rx_ext_stats_strings) +
 				RTE_DIM(bnxt_tx_ext_stats_strings);
 	struct rte_eth_xstat_name xstats_names_copy[stat_cnt];
+	struct bnxt *bp = dev->data->dev_private;
 	uint16_t i;
+	int rc;
+
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
 
 	if (!ids)
 		return bnxt_dev_xstats_get_names_op(dev, xstats_names,
drivers/net/bnxt/bnxt_txq.c +7 -0
index 43b3496c1e..0901324793 100644
@@ -58,6 +58,9 @@ void bnxt_tx_queue_release_op(void *tx_queue)
 	struct bnxt_tx_queue *txq = (struct bnxt_tx_queue *)tx_queue;
 
 	if (txq) {
+		if (is_bnxt_in_error(txq->bp))
+			return;
+
 		/* Free TX ring hardware descriptors */
 		bnxt_tx_queue_release_mbufs(txq);
 		bnxt_free_ring(txq->tx_ring->tx_ring_struct);
@@ -84,6 +87,10 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
 	struct bnxt_tx_queue *txq;
 	int rc = 0;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	if (queue_idx >= bp->max_tx_rings) {
 		PMD_DRV_LOG(ERR,
 			"Cannot create Tx ring %d. Only %d rings available\n",
drivers/net/bnxt/bnxt_txr.c +27 -0
index c71e6f1892..35e7166bed 100644
@@ -148,6 +148,9 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
 		TX_BD_LONG_FLAGS_LHINT_LT2K
 	};
 
+	if (unlikely(is_bnxt_in_error(txq->bp)))
+		return -EIO;
+
 	if (tx_pkt->ol_flags & (PKT_TX_TCP_SEG | PKT_TX_TCP_CKSUM |
 				PKT_TX_UDP_CKSUM | PKT_TX_IP_CKSUM |
 				PKT_TX_VLAN_PKT | PKT_TX_OUTER_IP_CKSUM |
@@ -485,10 +488,29 @@ uint16_t bnxt_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 	return nb_tx_pkts;
 }
 
+/*
+ * Dummy DPDK callback for TX.
+ *
+ * This function is used to temporarily replace the real callback during
+ * unsafe control operations on the queue, or in case of error.
+ */
+uint16_t
+bnxt_dummy_xmit_pkts(void *tx_queue __rte_unused,
+		     struct rte_mbuf **tx_pkts __rte_unused,
+		     uint16_t nb_pkts __rte_unused)
+{
+	return 0;
+}
+
 int bnxt_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 {
 	struct bnxt *bp = dev->data->dev_private;
 	struct bnxt_tx_queue *txq = bp->tx_queues[tx_queue_id];
+	int rc = 0;
+
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
 
 	dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
 	txq->tx_deferred_start = false;
@@ -501,6 +523,11 @@ int bnxt_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 {
 	struct bnxt *bp = dev->data->dev_private;
 	struct bnxt_tx_queue *txq = bp->tx_queues[tx_queue_id];
+	int rc = 0;
+
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
 
 	/* Handle TX completions */
 	bnxt_handle_tx_cp(txq);
drivers/net/bnxt/bnxt_txr.h +2 -0
index 08fd2e0142..e7f43f9d1d 100644
@@ -57,6 +57,8 @@ int bnxt_init_one_tx_ring(struct bnxt_tx_queue *txq);
 int bnxt_init_tx_ring_struct(struct bnxt_tx_queue *txq, unsigned int socket_id);
 uint16_t bnxt_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			       uint16_t nb_pkts);
+uint16_t bnxt_dummy_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+			      uint16_t nb_pkts);
 #ifdef RTE_ARCH_X86
 uint16_t bnxt_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
 			    uint16_t nb_pkts);
Signature · 1 line
2.20.1 (Apple Git-117)
#21 lore raw

PATCH v3 3/15 net/bnxt: handle reset notify async event from FW

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

When the FW upgrade is initiated the current instance of FW issues a HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY async notification to the driver. On receiving this notification, the PMD shall quiesce itself and poll on the HWRM_VER_GET FW command at regular intervals.

Once the VER_GET command succeeds, the driver should go through the rediscovery process and re-initialize the device.

Also register with FW for the reset notify async event.

---
 drivers/net/bnxt/bnxt.h                |  13 +++
 drivers/net/bnxt/bnxt_cpr.c            |  16 +++
 drivers/net/bnxt/bnxt_cpr.h            |   1 +
 drivers/net/bnxt/bnxt_ethdev.c         | 147 ++++++++++++++++++++++---
 drivers/net/bnxt/bnxt_hwrm.c           |  47 +++++++-
 drivers/net/bnxt/bnxt_hwrm.h           |   2 +
 drivers/net/bnxt/hsi_struct_def_dpdk.h |  11 ++
 7 files changed, 215 insertions(+), 22 deletions(-)
drivers/net/bnxt/bnxt.h +13 -0
index 37b4c717d6..8797b032ee 100644
@@ -333,6 +333,16 @@ struct bnxt_ctx_mem_info {
 	struct bnxt_ctx_pg_info *tqm_mem[BNXT_MAX_TC_Q];
 };
 
+/* Maximum Firmware Reset bail out value in milliseconds */
+#define BNXT_MAX_FW_RESET_TIMEOUT	6000
+/* Minimum time required for the firmware readiness in milliseconds */
+#define BNXT_MIN_FW_READY_TIMEOUT	2000
+/* Frequency for the firmware readiness check in milliseconds */
+#define BNXT_FW_READY_WAIT_INTERVAL	100
+
+#define US_PER_MS			1000
+#define NS_PER_US			1000
+
 #define BNXT_HWRM_SHORT_REQ_LEN		sizeof(struct hwrm_short_input)
 struct bnxt {
 	void				*bar0;
@@ -463,6 +473,9 @@ struct bnxt {
 	struct bnxt_ptp_cfg     *ptp_cfg;
 	uint16_t		vf_resv_strategy;
 	struct bnxt_ctx_mem_info        *ctx;
+
+	uint16_t		fw_reset_min_msecs;
+	uint16_t		fw_reset_max_msecs;
 };
 
 int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete);
drivers/net/bnxt/bnxt_cpr.c +16 -0
index bbcdb42f10..1a23649b05 100644
@@ -4,6 +4,7 @@
  */
 
 #include <rte_malloc.h>
+#include <rte_alarm.h>
 
 #include "bnxt.h"
 #include "bnxt_cpr.h"
@@ -40,6 +41,21 @@ void bnxt_handle_async_event(struct bnxt *bp,
 	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED:
 		PMD_DRV_LOG(INFO, "Port conn async event\n");
 		break;
+	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY:
+		/* timestamp_lo/hi values are in units of 100ms */
+		bp->fw_reset_max_msecs = async_cmp->timestamp_hi ?
+			rte_le_to_cpu_16(async_cmp->timestamp_hi) * 100 :
+			BNXT_MAX_FW_RESET_TIMEOUT;
+		bp->fw_reset_min_msecs = async_cmp->timestamp_lo ?
+			async_cmp->timestamp_lo * 100 :
+			BNXT_MIN_FW_READY_TIMEOUT;
+		PMD_DRV_LOG(INFO,
+			    "Firmware non-fatal reset event received\n");
+
+		bp->flags |= BNXT_FLAG_FW_RESET;
+		rte_eal_alarm_set(US_PER_MS, bnxt_dev_reset_and_resume,
+				  (void *)bp);
+		break;
 	default:
 		PMD_DRV_LOG(INFO, "handle_async_event id = 0x%x\n", event_id);
 		break;
drivers/net/bnxt/bnxt_cpr.h +1 -0
index 8c6a34b611..f48293b963 100644
@@ -106,5 +106,6 @@ struct bnxt;
 void bnxt_handle_async_event(struct bnxt *bp, struct cmpl_base *cmp);
 void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmp);
 int bnxt_event_hwrm_resp_handler(struct bnxt *bp, struct cmpl_base *cmp);
+void bnxt_dev_reset_and_resume(void *arg);
 
 #endif
drivers/net/bnxt/bnxt_ethdev.c +131 -16

236 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.c +41 -6

106 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.h +2 -0
index c882fc2a15..a036205329 100644
@@ -21,6 +21,8 @@ struct bnxt_cp_ring_info;
 	(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED)
 #define ASYNC_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE	\
 	(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE)
+#define ASYNC_CMPL_EVENT_ID_RESET_NOTIFY \
+	(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY)
 #define ASYNC_CMPL_EVENT_ID_PF_DRVR_UNLOAD	\
 	(1 << (HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD - 32))
 #define ASYNC_CMPL_EVENT_ID_VF_CFG_CHANGE	\
drivers/net/bnxt/hsi_struct_def_dpdk.h +11 -0
index 0095717254..809ea48736 100644
@@ -8918,6 +8918,17 @@ struct hwrm_func_drv_rgtr_input {
 	 */
 	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_ERROR_RECOVERY_SUPPORT \
 		UINT32_C(0x20)
+	/*
+	 * When this bit is 1, the function is indicating the support of the
+	 * Master capability. The Firmware will use this capability to select
+	 * the Master function. The master function will be used to initiate
+	 * designated functionality like error recovery etc. If none of the
+	 * registered PFs or trusted VFs indicate this support, then
+	 * firmware will select the 1st registered PF as Master capable
+	 * instance.
+	 */
+	#define HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_MASTER_SUPPORT \
+		UINT32_C(0x40)
 	uint32_t	enables;
 	/*
 	 * This bit must be '1' for the os_type field to be
Signature · 1 line
2.20.1 (Apple Git-117)
#22 lore raw

PATCH v3 4/15 net/bnxt: inform firmware about IF state changes

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

Use latest firmware API to inform firmware about IF state changes. Firmware has the option to clean up resources during IF down and to require the driver to reserve resources again during IF up.

During port start, HWRM_FUNC_DRV_IF_CHANGE command response flags indicates that firmware has reset. Add logic to re-probe the firmware and re-setup resources.

---
 drivers/net/bnxt/bnxt.h        |  2 ++
 drivers/net/bnxt/bnxt_ethdev.c | 30 ++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.c   | 42 ++++++++++++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.h   |  1 +
 4 files changed, 75 insertions(+)
drivers/net/bnxt/bnxt.h +2 -0
index 8797b032ee..040cae3b19 100644
@@ -370,6 +370,8 @@ struct bnxt {
 #define BNXT_FLAG_STINGRAY	(1 << 14)
 #define BNXT_FLAG_FW_RESET	(1 << 15)
 #define BNXT_FLAG_FATAL_ERROR	(1 << 16)
+#define BNXT_FLAG_FW_CAP_IF_CHANGE	(1 << 17)
+#define BNXT_FLAG_IF_CHANGE_HOT_FW_RESET_DONE	(1 << 18)
 #define BNXT_FLAG_EXT_STATS_SUPPORTED	(1 << 29)
 #define BNXT_FLAG_NEW_RM	(1 << 30)
 #define BNXT_FLAG_INIT_DONE	(1U << 31)
drivers/net/bnxt/bnxt_ethdev.c +30 -0
index 6bc006a719..1bb84eacd9 100644
@@ -794,6 +794,25 @@ bnxt_transmit_function(__rte_unused struct rte_eth_dev *eth_dev)
 	return bnxt_xmit_pkts;
 }
 
+static int bnxt_handle_if_change_status(struct bnxt *bp)
+{
+	int rc;
+
+	/* Since fw has undergone a reset and lost all contexts,
+	 * set fatal flag to not issue hwrm during cleanup
+	 */
+	bp->flags |= BNXT_FLAG_FATAL_ERROR;
+	bnxt_uninit_resources(bp, true);
+
+	/* clear fatal flag so that re-init happens */
+	bp->flags &= ~BNXT_FLAG_FATAL_ERROR;
+	rc = bnxt_init_resources(bp, true);
+
+	bp->flags &= ~BNXT_FLAG_IF_CHANGE_HOT_FW_RESET_DONE;
+
+	return rc;
+}
+
 static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt *bp = eth_dev->data->dev_private;
@@ -807,6 +826,15 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 			bp->rx_cp_nr_rings, RTE_ETHDEV_QUEUE_STAT_CNTRS);
 	}
 
+	rc = bnxt_hwrm_if_change(bp, 1);
+	if (!rc) {
+		if (bp->flags & BNXT_FLAG_IF_CHANGE_HOT_FW_RESET_DONE) {
+			rc = bnxt_handle_if_change_status(bp);
+			if (rc)
+				return rc;
+		}
+	}
+
 	rc = bnxt_init_chip(bp);
 	if (rc)
 		goto error;
@@ -833,6 +861,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 	return 0;
 
 error:
+	bnxt_hwrm_if_change(bp, 0);
 	bnxt_shutdown_nic(bp);
 	bnxt_free_tx_mbufs(bp);
 	bnxt_free_rx_mbufs(bp);
@@ -899,6 +928,7 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
 	bnxt_free_tx_mbufs(bp);
 	bnxt_free_rx_mbufs(bp);
 	bnxt_shutdown_nic(bp);
+	bnxt_hwrm_if_change(bp, 0);
 	bp->dev_stopped = 1;
 }
 
drivers/net/bnxt/bnxt_hwrm.c +42 -0

51 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.h +1 -0
index a036205329..2f57e950bb 100644
@@ -201,4 +201,5 @@ int bnxt_hwrm_tunnel_redirect_query(struct bnxt *bp, uint32_t *type);
 int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
 				   uint16_t *dst_fid);
 int bnxt_hwrm_set_mac(struct bnxt *bp);
+int bnxt_hwrm_if_change(struct bnxt *bp, bool state);
 #endif
Signature · 1 line
2.20.1 (Apple Git-117)
#23 lore raw

PATCH v3 5/15 net/bnxt: handle fatal event from FW under error conditions

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

When firmware hit some unrecoverable error conditions, firmware initiate the recovery by sending an async event EVENT_CMPL_EVENT_ID_RESET_NOTIFY with data1 set to RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL to all host drivers and will reset the chip.

The recovery procedure is same sequence as the one for hot FW upgrade.

---
 drivers/net/bnxt/bnxt_cpr.c    | 13 +++++++++++--
 drivers/net/bnxt/bnxt_cpr.h    |  5 +++++
 drivers/net/bnxt/bnxt_ethdev.c |  3 +++
 3 files changed, 19 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt_cpr.c +11 -2
index 1a23649b05..3afb9902b0 100644
@@ -21,6 +21,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
 	struct hwrm_async_event_cmpl *async_cmp =
 				(struct hwrm_async_event_cmpl *)cmp;
 	uint16_t event_id = rte_le_to_cpu_16(async_cmp->event_id);
+	uint32_t event_data;
 
 	/* TODO: HWRM async events are not defined yet */
 	/* Needs to handle: link events, error events, etc. */
@@ -42,6 +43,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
 		PMD_DRV_LOG(INFO, "Port conn async event\n");
 		break;
 	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY:
+		event_data = rte_le_to_cpu_32(async_cmp->event_data1);
 		/* timestamp_lo/hi values are in units of 100ms */
 		bp->fw_reset_max_msecs = async_cmp->timestamp_hi ?
 			rte_le_to_cpu_16(async_cmp->timestamp_hi) * 100 :
@@ -49,8 +51,15 @@ void bnxt_handle_async_event(struct bnxt *bp,
 		bp->fw_reset_min_msecs = async_cmp->timestamp_lo ?
 			async_cmp->timestamp_lo * 100 :
 			BNXT_MIN_FW_READY_TIMEOUT;
-		PMD_DRV_LOG(INFO,
-			    "Firmware non-fatal reset event received\n");
+		if ((event_data & EVENT_DATA1_REASON_CODE_MASK) ==
+		    EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL) {
+			PMD_DRV_LOG(INFO,
+				    "Firmware fatal reset event received\n");
+			bp->flags |= BNXT_FLAG_FATAL_ERROR;
+		} else {
+			PMD_DRV_LOG(INFO,
+				    "Firmware non-fatal reset event received\n");
+		}
 
 		bp->flags |= BNXT_FLAG_FW_RESET;
 		rte_eal_alarm_set(US_PER_MS, bnxt_dev_reset_and_resume,
drivers/net/bnxt/bnxt_cpr.h +5 -0
index f48293b963..b61bafa0e8 100644
@@ -108,4 +108,9 @@ void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmp);
 int bnxt_event_hwrm_resp_handler(struct bnxt *bp, struct cmpl_base *cmp);
 void bnxt_dev_reset_and_resume(void *arg);
 
+#define EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL     \
+	HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL
+#define EVENT_DATA1_REASON_CODE_MASK                   \
+	HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MASK
+
 #endif
drivers/net/bnxt/bnxt_ethdev.c +3 -0
index 1bb84eacd9..768b6cdc74 100644
@@ -3592,6 +3592,9 @@ static void bnxt_dev_recover(void *arg)
 	int timeout = bp->fw_reset_max_msecs;
 	int rc = 0;
 
+	/* Clear Error flag so that device re-init should happen */
+	bp->flags &= ~BNXT_FLAG_FATAL_ERROR;
+
 	do {
 		rc = bnxt_hwrm_ver_get(bp);
 		if (rc == 0)
Signature · 1 line
2.20.1 (Apple Git-117)
#24 lore raw

PATCH v3 6/15 net/bnxt: query firmware error recovery capabilities

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

In Driver initiated error recovery process, driver has to know about the registers offset and values to initiate FW reset. The HWRM command HWRM_ERROR_RECOVERY_QCFG is used to obtain all the registers and values required to initiate FW reset. This command response includes FW heart_beat register, health status register, Error counter register, register offsets and values to do chip reset if firmware crashes and becomes unresponsive.

---
 drivers/net/bnxt/bnxt.h        | 27 ++++++++++
 drivers/net/bnxt/bnxt_ethdev.c | 13 ++++-
 drivers/net/bnxt/bnxt_hwrm.c   | 93 ++++++++++++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.h   |  1 +
 4 files changed, 133 insertions(+), 1 deletion(-)
drivers/net/bnxt/bnxt.h +27 -0
index 040cae3b19..bfe5cb0df2 100644
@@ -343,6 +343,29 @@ struct bnxt_ctx_mem_info {
 #define US_PER_MS			1000
 #define NS_PER_US			1000
 
+struct bnxt_error_recovery_info {
+	/* All units in milliseconds */
+	uint32_t	driver_polling_freq;
+	uint32_t	master_func_wait_period;
+	uint32_t	normal_func_wait_period;
+	uint32_t	master_func_wait_period_after_reset;
+	uint32_t	max_bailout_time_after_reset;
+#define BNXT_FW_STATUS_REG		0
+#define BNXT_FW_HEARTBEAT_CNT_REG	1
+#define BNXT_FW_RECOVERY_CNT_REG	2
+#define BNXT_FW_RESET_INPROG_REG	3
+	uint32_t	status_regs[4];
+	uint32_t	reset_inprogress_reg_mask;
+#define BNXT_NUM_RESET_REG	16
+	uint8_t		reg_array_cnt;
+	uint32_t	reset_reg[BNXT_NUM_RESET_REG];
+	uint32_t	reset_reg_val[BNXT_NUM_RESET_REG];
+	uint8_t		delay_after_reset[BNXT_NUM_RESET_REG];
+#define BNXT_FLAG_ERROR_RECOVERY_HOST	(1 << 0)
+#define BNXT_FLAG_ERROR_RECOVERY_CO_CPU	(1 << 1)
+	uint32_t	flags;
+};
+
 #define BNXT_HWRM_SHORT_REQ_LEN		sizeof(struct hwrm_short_input)
 struct bnxt {
 	void				*bar0;
@@ -372,6 +395,7 @@ struct bnxt {
 #define BNXT_FLAG_FATAL_ERROR	(1 << 16)
 #define BNXT_FLAG_FW_CAP_IF_CHANGE	(1 << 17)
 #define BNXT_FLAG_IF_CHANGE_HOT_FW_RESET_DONE	(1 << 18)
+#define BNXT_FLAG_FW_CAP_ERROR_RECOVERY		(1 << 19)
 #define BNXT_FLAG_EXT_STATS_SUPPORTED	(1 << 29)
 #define BNXT_FLAG_NEW_RM	(1 << 30)
 #define BNXT_FLAG_INIT_DONE	(1U << 31)
@@ -478,6 +502,9 @@ struct bnxt {
 
 	uint16_t		fw_reset_min_msecs;
 	uint16_t		fw_reset_max_msecs;
+
+	/* Struct to hold adapter error recovery related info */
+	struct bnxt_error_recovery_info *recovery_info;
 };
 
 int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete);
drivers/net/bnxt/bnxt_ethdev.c +12 -1
index 768b6cdc74..95d63435bb 100644
@@ -4170,6 +4170,11 @@ static int bnxt_init_fw(struct bnxt *bp)
 	if (rc)
 		return rc;
 
+	/* Get the adapter error recovery support info */
+	rc = bnxt_hwrm_error_recovery_qcfg(bp);
+	if (rc)
+		bp->flags &= ~BNXT_FLAG_FW_CAP_ERROR_RECOVERY;
+
 	if (mtu >= RTE_ETHER_MIN_MTU && mtu <= BNXT_MAX_MTU &&
 	    mtu != bp->eth_dev->data->mtu)
 		bp->eth_dev->data->mtu = mtu;
@@ -4328,9 +4333,15 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev)
 	rc = bnxt_hwrm_func_driver_unregister(bp, 0);
 	bp->flags &= ~BNXT_FLAG_REGISTERED;
 	bnxt_free_ctx_mem(bp);
-	if (!reconfig_dev)
+	if (!reconfig_dev) {
 		bnxt_free_hwrm_resources(bp);
 
+		if (bp->recovery_info != NULL) {
+			rte_free(bp->recovery_info);
+			bp->recovery_info = NULL;
+		}
+	}
+
 	return rc;
 }
 
drivers/net/bnxt/bnxt_hwrm.c +93 -0

102 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.h +1 -0
index 2f57e950bb..c332c129dd 100644
@@ -202,4 +202,5 @@ int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
 				   uint16_t *dst_fid);
 int bnxt_hwrm_set_mac(struct bnxt *bp);
 int bnxt_hwrm_if_change(struct bnxt *bp, bool state);
+int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp);
 #endif
Signature · 1 line
2.20.1 (Apple Git-117)
#25 lore raw

PATCH v3 7/15 net/bnxt: map status registers for FW health monitoring

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

HWRM_ERROR_RECOVERY_QCFG command returns the FW status registers offset for periodic firmware health check monitoring. Map them to GRC window 2.

---
 drivers/net/bnxt/bnxt.h        | 22 +++++++++++++++++++++-
 drivers/net/bnxt/bnxt_ethdev.c | 34 ++++++++++++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.c   |  4 ++++
 3 files changed, 59 insertions(+), 1 deletion(-)
drivers/net/bnxt/bnxt.h +21 -1
index bfe5cb0df2..ac2bf158dd 100644
@@ -354,7 +354,9 @@ struct bnxt_error_recovery_info {
 #define BNXT_FW_HEARTBEAT_CNT_REG	1
 #define BNXT_FW_RECOVERY_CNT_REG	2
 #define BNXT_FW_RESET_INPROG_REG	3
-	uint32_t	status_regs[4];
+#define BNXT_FW_STATUS_REG_CNT		4
+	uint32_t	status_regs[BNXT_FW_STATUS_REG_CNT];
+	uint32_t	mapped_status_regs[BNXT_FW_STATUS_REG_CNT];
 	uint32_t	reset_inprogress_reg_mask;
 #define BNXT_NUM_RESET_REG	16
 	uint8_t		reg_array_cnt;
@@ -366,6 +368,22 @@ struct bnxt_error_recovery_info {
 	uint32_t	flags;
 };
 
+/* address space location of register */
+#define BNXT_FW_STATUS_REG_TYPE_MASK	3
+/* register is located in PCIe config space */
+#define BNXT_FW_STATUS_REG_TYPE_CFG	0
+/* register is located in GRC address space */
+#define BNXT_FW_STATUS_REG_TYPE_GRC	1
+/* register is located in BAR0  */
+#define BNXT_FW_STATUS_REG_TYPE_BAR0	2
+/* register is located in BAR1  */
+#define BNXT_FW_STATUS_REG_TYPE_BAR1	3
+
+#define BNXT_FW_STATUS_REG_TYPE(reg)	((reg) & BNXT_FW_STATUS_REG_TYPE_MASK)
+#define BNXT_FW_STATUS_REG_OFF(reg)	((reg) & ~BNXT_FW_STATUS_REG_TYPE_MASK)
+
+#define BNXT_GRCP_WINDOW_2_BASE		0x2000
+
 #define BNXT_HWRM_SHORT_REQ_LEN		sizeof(struct hwrm_short_input)
 struct bnxt {
 	void				*bar0;
@@ -511,6 +529,8 @@ int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete);
 int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id, void *msg);
 int is_bnxt_in_error(struct bnxt *bp);
 
+int bnxt_map_fw_health_status_regs(struct bnxt *bp);
+
 bool is_bnxt_supported(struct rte_eth_dev *dev);
 bool bnxt_stratus_device(struct bnxt *bp);
 extern const struct rte_flow_ops bnxt_flow_ops;
drivers/net/bnxt/bnxt_ethdev.c +34 -0
index 95d63435bb..a23ca2b53d 100644
@@ -3562,6 +3562,40 @@ static const struct eth_dev_ops bnxt_dev_ops = {
 	.timesync_read_tx_timestamp = bnxt_timesync_read_tx_timestamp,
 };
 
+int bnxt_map_fw_health_status_regs(struct bnxt *bp)
+{
+	struct bnxt_error_recovery_info *info = bp->recovery_info;
+	uint32_t reg_base = 0xffffffff;
+	int i;
+
+	/* Only pre-map the monitoring GRC registers using window 2 */
+	for (i = 0; i < BNXT_FW_STATUS_REG_CNT; i++) {
+		uint32_t reg = info->status_regs[i];
+
+		if (BNXT_FW_STATUS_REG_TYPE(reg) != BNXT_FW_STATUS_REG_TYPE_GRC)
+			continue;
+
+		if (reg_base == 0xffffffff)
+			reg_base = reg & 0xfffff000;
+		if ((reg & 0xfffff000) != reg_base)
+			return -ERANGE;
+
+		/* Use mask 0xffc as the Lower 2 bits indicates
+		 * address space location
+		 */
+		info->mapped_status_regs[i] = BNXT_GRCP_WINDOW_2_BASE +
+						(reg & 0xffc);
+	}
+
+	if (reg_base == 0xffffffff)
+		return 0;
+
+	rte_write32(reg_base, (uint8_t *)bp->bar0 +
+		    BNXT_GRCPF_REG_WINDOW_BASE_OUT + 4);
+
+	return 0;
+}
+
 static void bnxt_dev_cleanup(struct bnxt *bp)
 {
 	bnxt_set_hwrm_link_config(bp, false);
drivers/net/bnxt/bnxt_hwrm.c +4 -0
index f197997b89..34672dfb00 100644
@@ -4788,6 +4788,10 @@ int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp)
 err:
 	HWRM_UNLOCK();
 
+	/* Map the FW status registers */
+	if (!rc)
+		rc = bnxt_map_fw_health_status_regs(bp);
+
 	if (rc) {
 		rte_free(bp->recovery_info);
 		bp->recovery_info = NULL;
Signature · 1 line
2.20.1 (Apple Git-117)
#26 lore raw

PATCH v3 8/15 net/bnxt: advertise error recovery capability and handle async event

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

1. Advertise HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_ERROR_RECOVERY_SUPPORT flag in the FUNC_DRV_RGTR command.
2. request for the async event ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY in the FUNC_DRV_RGTR command.
3. handle the async event EVENT_ID_ERROR_RECOVERY from FW.

Error recovery support will be used by firmware only if all the driver instances support error recovery process.

---
 drivers/net/bnxt/bnxt.h      |  2 ++
 drivers/net/bnxt/bnxt_cpr.c  | 45 ++++++++++++++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_cpr.h  | 12 ++++++++++
 drivers/net/bnxt/bnxt_hwrm.c |  5 ++++
 drivers/net/bnxt/bnxt_hwrm.h |  2 ++
 5 files changed, 66 insertions(+)
drivers/net/bnxt/bnxt.h +2 -0
index ac2bf158dd..ea556d0792 100644
@@ -365,6 +365,8 @@ struct bnxt_error_recovery_info {
 	uint8_t		delay_after_reset[BNXT_NUM_RESET_REG];
 #define BNXT_FLAG_ERROR_RECOVERY_HOST	(1 << 0)
 #define BNXT_FLAG_ERROR_RECOVERY_CO_CPU	(1 << 1)
+#define BNXT_FLAG_MASTER_FUNC		(1 << 2)
+#define BNXT_FLAG_RECOVERY_ENABLED	(1 << 3)
 	uint32_t	flags;
 };
 
drivers/net/bnxt/bnxt_cpr.c +45 -0

60 lines not on this page · raw message

drivers/net/bnxt/bnxt_cpr.h +12 -0
index b61bafa0e8..f118bda36e 100644
@@ -113,4 +113,16 @@ void bnxt_dev_reset_and_resume(void *arg);
 #define EVENT_DATA1_REASON_CODE_MASK                   \
 	HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MASK
 
+#define EVENT_DATA1_FLAGS_MASK                         \
+	HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_MASK
+
+#define EVENT_DATA1_FLAGS_MASTER_FUNC                  \
+	HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_MASTER_FUNC
+
+#define EVENT_DATA1_FLAGS_RECOVERY_ENABLED             \
+	HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_RECOVERY_ENABLED
+
+bool bnxt_is_recovery_enabled(struct bnxt *bp);
+bool bnxt_is_master_func(struct bnxt *bp);
+
 #endif
drivers/net/bnxt/bnxt_hwrm.c +5 -0
index 34672dfb00..c7d6f9fdc4 100644
@@ -689,6 +689,8 @@ int bnxt_hwrm_func_driver_register(struct bnxt *bp)
 		return 0;
 
 	flags = HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_HOT_RESET_SUPPORT;
+	if (bp->flags & BNXT_FLAG_FW_CAP_ERROR_RECOVERY)
+		flags |= HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_ERROR_RECOVERY_SUPPORT;
 
 	/* PFs and trusted VFs should indicate the support of the
 	 * Master capability on non Stingray platform
@@ -726,6 +728,9 @@ int bnxt_hwrm_func_driver_register(struct bnxt *bp)
 				 ASYNC_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED |
 				 ASYNC_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE |
 				 ASYNC_CMPL_EVENT_ID_RESET_NOTIFY);
+	if (bp->flags & BNXT_FLAG_FW_CAP_ERROR_RECOVERY)
+		req.async_event_fwd[0] |=
+			rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_ERROR_RECOVERY);
 	req.async_event_fwd[1] |=
 		rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_PF_DRVR_UNLOAD |
 				 ASYNC_CMPL_EVENT_ID_VF_CFG_CHANGE);
drivers/net/bnxt/bnxt_hwrm.h +2 -0
index c332c129dd..44e3355075 100644
@@ -23,6 +23,8 @@ struct bnxt_cp_ring_info;
 	(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE)
 #define ASYNC_CMPL_EVENT_ID_RESET_NOTIFY \
 	(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY)
+#define ASYNC_CMPL_EVENT_ID_ERROR_RECOVERY \
+	(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY)
 #define ASYNC_CMPL_EVENT_ID_PF_DRVR_UNLOAD	\
 	(1 << (HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD - 32))
 #define ASYNC_CMPL_EVENT_ID_VF_CFG_CHANGE	\
Signature · 1 line
2.20.1 (Apple Git-117)
#27 lore raw

PATCH v3 9/15 net/bnxt: add code for periodic FW health monitoring

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

Periodically poll the FW heartbeat register and FW recovery counter registers to check the FW health. Polling frequency will be advertised by the FW in HWRM_ERROR_RECOVERY_QCFG response. Schedule the task upon receiving the async event from FW.

---
 drivers/net/bnxt/bnxt.h        |  6 +++
 drivers/net/bnxt/bnxt_cpr.c    | 10 ++++
 drivers/net/bnxt/bnxt_ethdev.c | 97 ++++++++++++++++++++++++++++++++++
 3 files changed, 113 insertions(+)
drivers/net/bnxt/bnxt.h +6 -0
index ea556d0792..50b9b38565 100644
@@ -368,6 +368,9 @@ struct bnxt_error_recovery_info {
 #define BNXT_FLAG_MASTER_FUNC		(1 << 2)
 #define BNXT_FLAG_RECOVERY_ENABLED	(1 << 3)
 	uint32_t	flags;
+
+	uint32_t        last_heart_beat;
+	uint32_t        last_reset_counter;
 };
 
 /* address space location of register */
@@ -416,6 +419,7 @@ struct bnxt {
 #define BNXT_FLAG_FW_CAP_IF_CHANGE	(1 << 17)
 #define BNXT_FLAG_IF_CHANGE_HOT_FW_RESET_DONE	(1 << 18)
 #define BNXT_FLAG_FW_CAP_ERROR_RECOVERY		(1 << 19)
+#define BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED	(1 << 20)
 #define BNXT_FLAG_EXT_STATS_SUPPORTED	(1 << 29)
 #define BNXT_FLAG_NEW_RM	(1 << 30)
 #define BNXT_FLAG_INIT_DONE	(1U << 31)
@@ -532,6 +536,8 @@ int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id, void *msg);
 int is_bnxt_in_error(struct bnxt *bp);
 
 int bnxt_map_fw_health_status_regs(struct bnxt *bp);
+uint32_t bnxt_read_fw_status_reg(struct bnxt *bp, uint32_t index);
+void bnxt_schedule_fw_health_check(struct bnxt *bp);
 
 bool is_bnxt_supported(struct rte_eth_dev *dev);
 bool bnxt_stratus_device(struct bnxt *bp);
drivers/net/bnxt/bnxt_cpr.c +10 -0
index 1b046bbfac..38931799eb 100644
@@ -90,6 +90,16 @@ void bnxt_handle_async_event(struct bnxt *bp,
 		PMD_DRV_LOG(INFO, "recovery enabled(%d), master function(%d)\n",
 			    bnxt_is_recovery_enabled(bp),
 			    bnxt_is_master_func(bp));
+
+		if (bp->flags & BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED)
+			return;
+
+		info->last_heart_beat =
+			bnxt_read_fw_status_reg(bp, BNXT_FW_HEARTBEAT_CNT_REG);
+		info->last_reset_counter =
+			bnxt_read_fw_status_reg(bp, BNXT_FW_RECOVERY_CNT_REG);
+
+		bnxt_schedule_fw_health_check(bp);
 		break;
 	default:
 		PMD_DRV_LOG(INFO, "handle_async_event id = 0x%x\n", event_id);
drivers/net/bnxt/bnxt_ethdev.c +97 -0

121 lines not on this page · raw message

Signature · 1 line
2.20.1 (Apple Git-117)
#28 lore raw

PATCH v3 10/15 net/bnxt: add support for FW reset

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

Added code to perform FW_RESET. When the driver detects error in FW, it has to initiate the recovery by resetting the cores. FW advertise the method to do a core reset, reset register offsets and values to perform reset in response of HWRM_ERROR_RECOVERY_QCFG command.

There are 2 ways to recover from the error.
1. Master function issues core resets to recover from error.
2. Master function detects chimp dead condition and notify the Kong processor about the chimp dead case through FW_RESET HWRM command. Kong Processor send an RESET_NOTIFY async event with REASON_CODE_FW_EXCEPTION_FATAL to all the PF’s/VF’s that chimp is dead and it is going to reset the chimp.

---
 drivers/net/bnxt/bnxt.h        |   1 +
 drivers/net/bnxt/bnxt_ethdev.c | 104 ++++++++++++++++++++++++++++++++-
 drivers/net/bnxt/bnxt_hwrm.c   |  26 +++++++++
 drivers/net/bnxt/bnxt_hwrm.h   |   1 +
 4 files changed, 131 insertions(+), 1 deletion(-)
drivers/net/bnxt/bnxt.h +1 -0
index 50b9b38565..637ee9a0f7 100644
@@ -388,6 +388,7 @@ struct bnxt_error_recovery_info {
 #define BNXT_FW_STATUS_REG_OFF(reg)	((reg) & ~BNXT_FW_STATUS_REG_TYPE_MASK)
 
 #define BNXT_GRCP_WINDOW_2_BASE		0x2000
+#define BNXT_GRCP_WINDOW_3_BASE		0x3000
 
 #define BNXT_HWRM_SHORT_REQ_LEN		sizeof(struct hwrm_short_input)
 struct bnxt {
drivers/net/bnxt/bnxt_ethdev.c +103 -1

134 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.c +26 -0
index c7d6f9fdc4..e96e6cef91 100644
@@ -4803,3 +4803,29 @@ int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp)
 	}
 	return rc;
 }
+
+int bnxt_hwrm_fw_reset(struct bnxt *bp)
+{
+	struct hwrm_fw_reset_output *resp = bp->hwrm_cmd_resp_addr;
+	struct hwrm_fw_reset_input req = {0};
+	int rc;
+
+	if (!BNXT_PF(bp))
+		return -EOPNOTSUPP;
+
+	HWRM_PREP(req, FW_RESET, BNXT_USE_KONG(bp));
+
+	req.embedded_proc_type =
+		HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_CHIP;
+	req.selfrst_status =
+		HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTASAP;
+	req.flags = HWRM_FW_RESET_INPUT_FLAGS_RESET_GRACEFUL;
+
+	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req),
+				    BNXT_USE_KONG(bp));
+
+	HWRM_CHECK_RESULT();
+	HWRM_UNLOCK();
+
+	return rc;
+}
drivers/net/bnxt/bnxt_hwrm.h +1 -0
index 44e3355075..db25ad5919 100644
@@ -205,4 +205,5 @@ int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
 int bnxt_hwrm_set_mac(struct bnxt *bp);
 int bnxt_hwrm_if_change(struct bnxt *bp, bool state);
 int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp);
+int bnxt_hwrm_fw_reset(struct bnxt *bp);
 #endif
Signature · 1 line
2.20.1 (Apple Git-117)
#29 lore raw

PATCH v3 11/15 net/bnxt: add hot firmware upgrade support for Stingray

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

FW sets HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERR_RECOVER_RELOAD in HWRM_FUNC_QCAPS command, if device requires to invoke fastboot FW during FW reset.

Driver has to poll for shutdown bit in fw_status register:
1. in case of hot fw upgrade, this bit will be set after all function drivers unregistered with fw.
2. in case of fw initiated error recovery, this bit will be set after fw has collected the core dump

---
 drivers/net/bnxt/bnxt.h                |  3 +++
 drivers/net/bnxt/bnxt_cpr.c            | 35 ++++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_cpr.h            |  1 +
 drivers/net/bnxt/bnxt_ethdev.c         |  2 ++
 drivers/net/bnxt/bnxt_hwrm.c           |  5 ++++
 drivers/net/bnxt/hsi_struct_def_dpdk.h |  8 ++++++
 6 files changed, 54 insertions(+)
drivers/net/bnxt/bnxt.h +3 -0
index 637ee9a0f7..f47874882b 100644
@@ -390,6 +390,8 @@ struct bnxt_error_recovery_info {
 #define BNXT_GRCP_WINDOW_2_BASE		0x2000
 #define BNXT_GRCP_WINDOW_3_BASE		0x3000
 
+#define BNXT_FW_STATUS_SHUTDOWN		0x100000
+
 #define BNXT_HWRM_SHORT_REQ_LEN		sizeof(struct hwrm_short_input)
 struct bnxt {
 	void				*bar0;
@@ -421,6 +423,7 @@ struct bnxt {
 #define BNXT_FLAG_IF_CHANGE_HOT_FW_RESET_DONE	(1 << 18)
 #define BNXT_FLAG_FW_CAP_ERROR_RECOVERY		(1 << 19)
 #define BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED	(1 << 20)
+#define BNXT_FLAG_FW_CAP_ERR_RECOVER_RELOAD	(1 << 21)
 #define BNXT_FLAG_EXT_STATS_SUPPORTED	(1 << 29)
 #define BNXT_FLAG_NEW_RM	(1 << 30)
 #define BNXT_FLAG_INIT_DONE	(1U << 31)
drivers/net/bnxt/bnxt_cpr.c +35 -0
index 38931799eb..00ca6bbd1f 100644
@@ -5,6 +5,7 @@
 
 #include <rte_malloc.h>
 #include <rte_alarm.h>
+#include <rte_cycles.h>
 
 #include "bnxt.h"
 #include "bnxt_cpr.h"
@@ -12,6 +13,40 @@
 #include "bnxt_ring.h"
 #include "hsi_struct_def_dpdk.h"
 
+void bnxt_wait_for_device_shutdown(struct bnxt *bp)
+{
+	uint32_t val, timeout;
+
+	/* if HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERR_RECOVER_RELOAD is set
+	 * in HWRM_FUNC_QCAPS command, wait for FW_STATUS to set
+	 * the SHUTDOWN bit in health register
+	 */
+	if (!(bp->recovery_info &&
+	      (bp->flags & BNXT_FLAG_FW_CAP_ERR_RECOVER_RELOAD)))
+		return;
+
+	/* Driver has to wait for fw_reset_max_msecs or shutdown bit which comes
+	 * first for FW to collect crash dump.
+	 */
+	timeout = bp->fw_reset_max_msecs;
+
+	/* Driver has to poll for shutdown bit in fw_status register
+	 *
+	 * 1. in case of hot fw upgrade, this bit will be set after all
+	 *    function drivers unregistered with fw.
+	 * 2. in case of fw initiated error recovery, this bit will be
+	 *    set after fw has collected the core dump
+	 */
+	do {
+		val = bnxt_read_fw_status_reg(bp, BNXT_FW_STATUS_REG);
+		if (val & BNXT_FW_STATUS_SHUTDOWN)
+			return;
+
+		rte_delay_ms(100);
+		timeout -= 100;
+	} while (timeout);
+}
+
 /*
  * Async event handling
  */
drivers/net/bnxt/bnxt_cpr.h +1 -0
index f118bda36e..c2880783f6 100644
@@ -107,6 +107,7 @@ void bnxt_handle_async_event(struct bnxt *bp, struct cmpl_base *cmp);
 void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmp);
 int bnxt_event_hwrm_resp_handler(struct bnxt *bp, struct cmpl_base *cmp);
 void bnxt_dev_reset_and_resume(void *arg);
+void bnxt_wait_for_device_shutdown(struct bnxt *bp);
 
 #define EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL     \
 	HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL
drivers/net/bnxt/bnxt_ethdev.c +2 -0
index 40973c37b9..fbd00d1c72 100644
@@ -3721,6 +3721,8 @@ void bnxt_dev_reset_and_resume(void *arg)
 
 	bnxt_dev_cleanup(bp);
 
+	bnxt_wait_for_device_shutdown(bp);
+
 	rc = rte_eal_alarm_set(US_PER_MS * bp->fw_reset_min_msecs,
 			       bnxt_dev_recover, (void *)bp);
 	if (rc)
drivers/net/bnxt/bnxt_hwrm.c +5 -0
index e96e6cef91..7304cbf72c 100644
@@ -637,6 +637,11 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
 		bp->flags &= ~BNXT_FLAG_FW_CAP_ERROR_RECOVERY;
 	}
 
+	if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERR_RECOVER_RELOAD)
+		bp->flags |= BNXT_FLAG_FW_CAP_ERR_RECOVER_RELOAD;
+	else
+		bp->flags &= ~BNXT_FLAG_FW_CAP_ERR_RECOVER_RELOAD;
+
 	HWRM_UNLOCK();
 
 	return rc;
drivers/net/bnxt/hsi_struct_def_dpdk.h +8 -0
index 809ea48736..bd04fe4838 100644
@@ -7327,6 +7327,14 @@ struct hwrm_func_qcaps_output {
 	 */
 	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_STATS_SUPPORTED \
 		UINT32_C(0x1000000)
+	/*
+	 * If the query is for a VF, then this flag shall be ignored.
+	 * If this query is for a PF and this flag is set to 1, then host
+	 * must initiate reset or reload (or fastboot) the firmware image
+	 * upon detection of device shutdown state.
+	 */
+	#define HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERR_RECOVER_RELOAD \
+		UINT32_C(0x2000000)
 	/*
 	 * This value is current MAC address configured for this
 	 * function. A value of 00-00-00-00-00-00 indicates no
Signature · 1 line
2.20.1 (Apple Git-117)
#30 lore raw

PATCH v3 12/15 net/bnxt: reduce verbosity of logs

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

When IOMMU is available, EAL picks IOVA as VA as the default IOVA mode. This causes the bnxt driver to log warning messages saying "Memzone physical address same as virtual." and "Using rte_mem_virt2iova()" during load.

Reduce the verbosity of logs to DEBUG. Reduced couple of other logs level to DEBUG as well.

---
 drivers/net/bnxt/bnxt_cpr.c    |  4 ++--
 drivers/net/bnxt/bnxt_ethdev.c | 21 +++++++++------------
 drivers/net/bnxt/bnxt_filter.c |  2 +-
 drivers/net/bnxt/bnxt_ring.c   |  7 +++----
 drivers/net/bnxt/bnxt_vnic.c   |  7 +++----
 5 files changed, 18 insertions(+), 23 deletions(-)
drivers/net/bnxt/bnxt_cpr.c +2 -2
index 00ca6bbd1f..4817672ef0 100644
@@ -137,7 +137,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
 		bnxt_schedule_fw_health_check(bp);
 		break;
 	default:
-		PMD_DRV_LOG(INFO, "handle_async_event id = 0x%x\n", event_id);
+		PMD_DRV_LOG(DEBUG, "handle_async_event id = 0x%x\n", event_id);
 		break;
 	}
 }
@@ -254,7 +254,7 @@ int bnxt_event_hwrm_resp_handler(struct bnxt *bp, struct cmpl_base *cmp)
 		break;
 	default:
 		/* Ignore any other events */
-		PMD_DRV_LOG(INFO, "Ignoring %02x completion\n", CMP_TYPE(cmp));
+		PMD_DRV_LOG(DEBUG, "Ignoring %02x completion\n", CMP_TYPE(cmp));
 		break;
 	}
 
drivers/net/bnxt/bnxt_ethdev.c +9 -12
index fbd00d1c72..7c3ef93253 100644
@@ -3976,10 +3976,9 @@ static int bnxt_alloc_ctx_mem_blk(__rte_unused struct bnxt *bp,
 		memset(mz->addr, 0, mz->len);
 		mz_phys_addr = mz->iova;
 		if ((unsigned long)mz->addr == mz_phys_addr) {
-			PMD_DRV_LOG(WARNING,
-				"Memzone physical address same as virtual.\n");
-			PMD_DRV_LOG(WARNING,
-				    "Using rte_mem_virt2iova()\n");
+			PMD_DRV_LOG(DEBUG,
+				    "physical address same as virtual\n");
+			PMD_DRV_LOG(DEBUG, "Using rte_mem_virt2iova()\n");
 			mz_phys_addr = rte_mem_virt2iova(mz->addr);
 			if (mz_phys_addr == RTE_BAD_IOVA) {
 				PMD_DRV_LOG(ERR,
@@ -4012,10 +4011,9 @@ static int bnxt_alloc_ctx_mem_blk(__rte_unused struct bnxt *bp,
 	memset(mz->addr, 0, mz->len);
 	mz_phys_addr = mz->iova;
 	if ((unsigned long)mz->addr == mz_phys_addr) {
-		PMD_DRV_LOG(WARNING,
+		PMD_DRV_LOG(DEBUG,
 			    "Memzone physical address same as virtual.\n");
-		PMD_DRV_LOG(WARNING,
-			    "Using rte_mem_virt2iova()\n");
+		PMD_DRV_LOG(DEBUG, "Using rte_mem_virt2iova()\n");
 		for (sz = 0; sz < mem_size; sz += BNXT_PAGE_SIZE)
 			rte_mem_lock_page(((char *)mz->addr) + sz);
 		mz_phys_addr = rte_mem_virt2iova(mz->addr);
@@ -4203,9 +4201,9 @@ static int bnxt_alloc_stats_mem(struct bnxt *bp)
 	memset(mz->addr, 0, mz->len);
 	mz_phys_addr = mz->iova;
 	if ((unsigned long)mz->addr == mz_phys_addr) {
-		PMD_DRV_LOG(WARNING,
+		PMD_DRV_LOG(DEBUG,
 			    "Memzone physical address same as virtual.\n");
-		PMD_DRV_LOG(WARNING,
+		PMD_DRV_LOG(DEBUG,
 			    "Using rte_mem_virt2iova()\n");
 		mz_phys_addr = rte_mem_virt2iova(mz->addr);
 		if (mz_phys_addr == RTE_BAD_IOVA) {
@@ -4241,10 +4239,9 @@ static int bnxt_alloc_stats_mem(struct bnxt *bp)
 	memset(mz->addr, 0, mz->len);
 	mz_phys_addr = mz->iova;
 	if ((unsigned long)mz->addr == mz_phys_addr) {
-		PMD_DRV_LOG(WARNING,
+		PMD_DRV_LOG(DEBUG,
 			    "Memzone physical address same as virtual\n");
-		PMD_DRV_LOG(WARNING,
-			    "Using rte_mem_virt2iova()\n");
+		PMD_DRV_LOG(DEBUG, "Using rte_mem_virt2iova()\n");
 		mz_phys_addr = rte_mem_virt2iova(mz->addr);
 		if (mz_phys_addr == RTE_BAD_IOVA) {
 			PMD_DRV_LOG(ERR,
drivers/net/bnxt/bnxt_filter.c +1 -1
index 0aed29fb08..34db988181 100644
@@ -119,7 +119,7 @@ void bnxt_free_filter_mem(struct bnxt *bp)
 		filter = &bp->filter_info[i];
 		if (filter->fw_l2_filter_id != ((uint64_t)-1) &&
 		    filter->filter_type == HWRM_CFA_L2_FILTER) {
-			PMD_DRV_LOG(ERR, "L2 filter is not free\n");
+			PMD_DRV_LOG(DEBUG, "L2 filter is not free\n");
 			/* Call HWRM to try to free filter again */
 			rc = bnxt_hwrm_clear_l2_filter(bp, filter);
 			if (rc)
drivers/net/bnxt/bnxt_ring.c +3 -4
index f19865c832..2f57e038a0 100644
@@ -212,10 +212,9 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
 	mz_phys_addr_base = mz->iova;
 	mz_phys_addr = mz->iova;
 	if ((unsigned long)mz->addr == mz_phys_addr_base) {
-		PMD_DRV_LOG(WARNING,
-			"Memzone physical address same as virtual.\n");
-		PMD_DRV_LOG(WARNING,
-			"Using rte_mem_virt2iova()\n");
+		PMD_DRV_LOG(DEBUG,
+			    "Memzone physical address same as virtual.\n");
+		PMD_DRV_LOG(DEBUG, "Using rte_mem_virt2iova()\n");
 		for (sz = 0; sz < total_alloc_len; sz += getpagesize())
 			rte_mem_lock_page(((char *)mz->addr) + sz);
 		mz_phys_addr_base = rte_mem_virt2iova(mz->addr);
drivers/net/bnxt/bnxt_vnic.c +3 -4
index 98415633e4..9ea99388b7 100644
@@ -150,10 +150,9 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp)
 	}
 	mz_phys_addr = mz->iova;
 	if ((unsigned long)mz->addr == mz_phys_addr) {
-		PMD_DRV_LOG(WARNING,
-			"Memzone physical address same as virtual.\n");
-		PMD_DRV_LOG(WARNING,
-			"Using rte_mem_virt2iova()\n");
+		PMD_DRV_LOG(DEBUG,
+			    "Memzone physical address same as virtual.\n");
+		PMD_DRV_LOG(DEBUG, "Using rte_mem_virt2iova()\n");
 		mz_phys_addr = rte_mem_virt2iova(mz->addr);
 		if (mz_phys_addr == RTE_BAD_IOVA) {
 			PMD_DRV_LOG(ERR,
Signature · 1 line
2.20.1 (Apple Git-117)
#31 lore raw

PATCH v3 13/15 net/bnxt: avoid null pointer dereference

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

Commit "bd0a14c99f65" enables the creation of a dedicated completion ring for asynchronous event handling instead of handling these events on a receive completion ring on non Stingray Platforms.

This causes a segfault due to NULL pointer defreference in bnxt_alloc_async_cp_ring() on stingray. Fix this by checking the pointer validity before accessing it.

Fixes bd0a14c99f65 ("net/bnxt: use dedicated CPR for async events")
---
 drivers/net/bnxt/bnxt_ring.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt_ring.c +4 -2
index 2f57e038a0..ec17783cf8 100644
@@ -694,13 +694,15 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp)
 int bnxt_alloc_async_cp_ring(struct bnxt *bp)
 {
 	struct bnxt_cp_ring_info *cpr = bp->async_cp_ring;
-	struct bnxt_ring *cp_ring = cpr->cp_ring_struct;
+	struct bnxt_ring *cp_ring;
 	uint8_t ring_type;
 	int rc;
 
-	if (BNXT_NUM_ASYNC_CPR(bp) == 0)
+	if (BNXT_NUM_ASYNC_CPR(bp) == 0 || cpr == NULL)
 		return 0;
 
+	cp_ring = cpr->cp_ring_struct;
+
 	if (BNXT_HAS_NQ(bp))
 		ring_type = HWRM_RING_ALLOC_INPUT_RING_TYPE_NQ;
 	else
Signature · 1 line
2.20.1 (Apple Git-117)
#32 lore raw

PATCH v3 14/15 net/bnxt: use BIT macro instead of bit fields

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

use BIT macro instead of bit fields.

---
 drivers/net/bnxt/bnxt.h      | 79 ++++++++++++++++++------------------
 drivers/net/bnxt/bnxt_util.h |  4 ++
 2 files changed, 44 insertions(+), 39 deletions(-)
drivers/net/bnxt/bnxt.h +40 -39
index f47874882b..310b730e68 100644
@@ -19,6 +19,7 @@
 #include <rte_time.h>
 
 #include "bnxt_cpr.h"
+#include "bnxt_util.h"
 
 #define BNXT_MAX_MTU		9574
 #define VLAN_TAG_SIZE		4
@@ -198,16 +199,16 @@ struct bnxt_ptp_cfg {
 	struct bnxt		*bp;
 #define BNXT_MAX_TX_TS	1
 	uint16_t			rxctl;
-#define BNXT_PTP_MSG_SYNC			(1 << 0)
-#define BNXT_PTP_MSG_DELAY_REQ			(1 << 1)
-#define BNXT_PTP_MSG_PDELAY_REQ			(1 << 2)
-#define BNXT_PTP_MSG_PDELAY_RESP		(1 << 3)
-#define BNXT_PTP_MSG_FOLLOW_UP			(1 << 8)
-#define BNXT_PTP_MSG_DELAY_RESP			(1 << 9)
-#define BNXT_PTP_MSG_PDELAY_RESP_FOLLOW_UP	(1 << 10)
-#define BNXT_PTP_MSG_ANNOUNCE			(1 << 11)
-#define BNXT_PTP_MSG_SIGNALING			(1 << 12)
-#define BNXT_PTP_MSG_MANAGEMENT			(1 << 13)
+#define BNXT_PTP_MSG_SYNC			BIT(0)
+#define BNXT_PTP_MSG_DELAY_REQ			BIT(1)
+#define BNXT_PTP_MSG_PDELAY_REQ			BIT(2)
+#define BNXT_PTP_MSG_PDELAY_RESP		BIT(3)
+#define BNXT_PTP_MSG_FOLLOW_UP			BIT(8)
+#define BNXT_PTP_MSG_DELAY_RESP			BIT(9)
+#define BNXT_PTP_MSG_PDELAY_RESP_FOLLOW_UP	BIT(10)
+#define BNXT_PTP_MSG_ANNOUNCE			BIT(11)
+#define BNXT_PTP_MSG_SIGNALING			BIT(12)
+#define BNXT_PTP_MSG_MANAGEMENT			BIT(13)
 #define BNXT_PTP_MSG_EVENTS		(BNXT_PTP_MSG_SYNC |		\
 					 BNXT_PTP_MSG_DELAY_REQ |	\
 					 BNXT_PTP_MSG_PDELAY_REQ |	\
@@ -363,10 +364,10 @@ struct bnxt_error_recovery_info {
 	uint32_t	reset_reg[BNXT_NUM_RESET_REG];
 	uint32_t	reset_reg_val[BNXT_NUM_RESET_REG];
 	uint8_t		delay_after_reset[BNXT_NUM_RESET_REG];
-#define BNXT_FLAG_ERROR_RECOVERY_HOST	(1 << 0)
-#define BNXT_FLAG_ERROR_RECOVERY_CO_CPU	(1 << 1)
-#define BNXT_FLAG_MASTER_FUNC		(1 << 2)
-#define BNXT_FLAG_RECOVERY_ENABLED	(1 << 3)
+#define BNXT_FLAG_ERROR_RECOVERY_HOST	BIT(0)
+#define BNXT_FLAG_ERROR_RECOVERY_CO_CPU	BIT(1)
+#define BNXT_FLAG_MASTER_FUNC		BIT(2)
+#define BNXT_FLAG_RECOVERY_ENABLED	BIT(3)
 	uint32_t	flags;
 
 	uint32_t        last_heart_beat;
@@ -402,31 +403,31 @@ struct bnxt {
 	void				*doorbell_base;
 
 	uint32_t		flags;
-#define BNXT_FLAG_REGISTERED	(1 << 0)
-#define BNXT_FLAG_VF		(1 << 1)
-#define BNXT_FLAG_PORT_STATS	(1 << 2)
-#define BNXT_FLAG_JUMBO		(1 << 3)
-#define BNXT_FLAG_SHORT_CMD	(1 << 4)
-#define BNXT_FLAG_UPDATE_HASH	(1 << 5)
-#define BNXT_FLAG_PTP_SUPPORTED	(1 << 6)
-#define BNXT_FLAG_MULTI_HOST    (1 << 7)
-#define BNXT_FLAG_EXT_RX_PORT_STATS	(1 << 8)
-#define BNXT_FLAG_EXT_TX_PORT_STATS	(1 << 9)
-#define BNXT_FLAG_KONG_MB_EN	(1 << 10)
-#define BNXT_FLAG_TRUSTED_VF_EN	(1 << 11)
-#define BNXT_FLAG_DFLT_VNIC_SET	(1 << 12)
-#define BNXT_FLAG_THOR_CHIP	(1 << 13)
-#define BNXT_FLAG_STINGRAY	(1 << 14)
-#define BNXT_FLAG_FW_RESET	(1 << 15)
-#define BNXT_FLAG_FATAL_ERROR	(1 << 16)
-#define BNXT_FLAG_FW_CAP_IF_CHANGE	(1 << 17)
-#define BNXT_FLAG_IF_CHANGE_HOT_FW_RESET_DONE	(1 << 18)
-#define BNXT_FLAG_FW_CAP_ERROR_RECOVERY		(1 << 19)
-#define BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED	(1 << 20)
-#define BNXT_FLAG_FW_CAP_ERR_RECOVER_RELOAD	(1 << 21)
-#define BNXT_FLAG_EXT_STATS_SUPPORTED	(1 << 29)
-#define BNXT_FLAG_NEW_RM	(1 << 30)
-#define BNXT_FLAG_INIT_DONE	(1U << 31)
+#define BNXT_FLAG_REGISTERED		BIT(0)
+#define BNXT_FLAG_VF			BIT(1)
+#define BNXT_FLAG_PORT_STATS		BIT(2)
+#define BNXT_FLAG_JUMBO			BIT(3)
+#define BNXT_FLAG_SHORT_CMD		BIT(4)
+#define BNXT_FLAG_UPDATE_HASH		BIT(5)
+#define BNXT_FLAG_PTP_SUPPORTED		BIT(6)
+#define BNXT_FLAG_MULTI_HOST    	BIT(7)
+#define BNXT_FLAG_EXT_RX_PORT_STATS	BIT(8)
+#define BNXT_FLAG_EXT_TX_PORT_STATS	BIT(9)
+#define BNXT_FLAG_KONG_MB_EN		BIT(10)
+#define BNXT_FLAG_TRUSTED_VF_EN		BIT(11)
+#define BNXT_FLAG_DFLT_VNIC_SET		BIT(12)
+#define BNXT_FLAG_THOR_CHIP		BIT(13)
+#define BNXT_FLAG_STINGRAY		BIT(14)
+#define BNXT_FLAG_FW_RESET		BIT(15)
+#define BNXT_FLAG_FATAL_ERROR		BIT(16)
+#define BNXT_FLAG_FW_CAP_IF_CHANGE		BIT(17)
+#define BNXT_FLAG_IF_CHANGE_HOT_FW_RESET_DONE	BIT(18)
+#define BNXT_FLAG_FW_CAP_ERROR_RECOVERY		BIT(19)
+#define BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED	BIT(20)
+#define BNXT_FLAG_FW_CAP_ERR_RECOVER_RELOAD	BIT(21)
+#define BNXT_FLAG_EXT_STATS_SUPPORTED		BIT(22)
+#define BNXT_FLAG_NEW_RM			BIT(23)
+#define BNXT_FLAG_INIT_DONE			BIT(24)
 #define BNXT_PF(bp)		(!((bp)->flags & BNXT_FLAG_VF))
 #define BNXT_VF(bp)		((bp)->flags & BNXT_FLAG_VF)
 #define BNXT_NPAR(bp)		((bp)->port_partition_type)
drivers/net/bnxt/bnxt_util.h +4 -0
index 9f1868a78f..a15b3a1a95 100644
@@ -6,6 +6,10 @@
 #ifndef _BNXT_UTIL_H_
 #define _BNXT_UTIL_H_
 
+#ifndef BIT
+#define BIT(n)	(1UL << (n))
+#endif /* BIT */
+
 int bnxt_check_zero_bytes(const uint8_t *bytes, int len);
 void bnxt_eth_hw_addr_random(uint8_t *mac_addr);
 
Signature · 1 line
2.20.1 (Apple Git-117)
#33 lore raw

PATCH v3 15/15 net/bnxt: add PTP support for Thor

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

On Thor, direct access to PTP registers (via GRC) is not supported. Driver must use HWRM to access the timestamp information.

Vectorized Rx/Tx cannot be enabled if RTE_LIBRTE_IEEE1588=y. Remove the PTP flags handling code from the vector Rx path.

Add support to read tx timestamp value and the time from the timesync clock.

On Thor, Rx timestamps are provided directly in the Rx completion records to the driver. Only 32 bits of the timestamp is present in the completion. Driver needs to read the current 48 bit free running timer using the HWRM_PORT_TS_QUERY command and combine the upper 16 bits from the HWRM response with the lower 32 bits in the Rx completion to produce the 48 bit timestamp for the Rx packet.

---
 drivers/net/bnxt/bnxt.h                |  8 +++
 drivers/net/bnxt/bnxt_ethdev.c         | 46 +++++++++++---
 drivers/net/bnxt/bnxt_hwrm.c           | 86 ++++++++++++++++++++------
 drivers/net/bnxt/bnxt_hwrm.h           |  2 +
 drivers/net/bnxt/bnxt_rxr.c            | 42 +++++++++++--
 drivers/net/bnxt/bnxt_txr.c            |  7 ++-
 drivers/net/bnxt/hsi_struct_def_dpdk.h | 86 ++++++++++++++++++++++++++
 7 files changed, 243 insertions(+), 34 deletions(-)
drivers/net/bnxt/bnxt.h +8 -0
index 310b730e68..818a49f461 100644
@@ -189,6 +189,10 @@ struct rte_flow {
 	struct bnxt_vnic_info	*vnic;
 };
 
+#define BNXT_PTP_FLAGS_PATH_TX		0x0
+#define BNXT_PTP_FLAGS_PATH_RX		0x1
+#define BNXT_PTP_FLAGS_CURRENT_TIME	0x2
+
 struct bnxt_ptp_cfg {
 #define BNXT_GRCPF_REG_WINDOW_BASE_OUT  0x400
 #define BNXT_GRCPF_REG_SYNC_TIME        0x480
@@ -234,6 +238,9 @@ struct bnxt_ptp_cfg {
 	uint32_t			rx_mapped_regs[BNXT_PTP_RX_REGS];
 	uint32_t			tx_regs[BNXT_PTP_TX_REGS];
 	uint32_t			tx_mapped_regs[BNXT_PTP_TX_REGS];
+
+	/* On Thor, the Rx timestamp is present in the Rx completion record */
+	uint64_t			rx_timestamp;
 };
 
 struct bnxt_coal {
@@ -428,6 +435,7 @@ struct bnxt {
 #define BNXT_FLAG_EXT_STATS_SUPPORTED		BIT(22)
 #define BNXT_FLAG_NEW_RM			BIT(23)
 #define BNXT_FLAG_INIT_DONE			BIT(24)
+#define BNXT_FLAG_FW_CAP_ONE_STEP_TX_TS		BIT(25)
 #define BNXT_PF(bp)		(!((bp)->flags & BNXT_FLAG_VF))
 #define BNXT_VF(bp)		((bp)->flags & BNXT_FLAG_VF)
 #define BNXT_NPAR(bp)		((bp)->port_partition_type)
drivers/net/bnxt/bnxt_ethdev.c +37 -9

134 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.c +67 -19

101 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.h +2 -0
index db25ad5919..0d386952b6 100644
@@ -206,4 +206,6 @@ int bnxt_hwrm_set_mac(struct bnxt *bp);
 int bnxt_hwrm_if_change(struct bnxt *bp, bool state);
 int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp);
 int bnxt_hwrm_fw_reset(struct bnxt *bp);
+int bnxt_hwrm_port_ts_query(struct bnxt *bp, uint8_t path,
+			    uint64_t *timestamp);
 #endif
drivers/net/bnxt/bnxt_rxr.c +37 -5

73 lines not on this page · raw message

drivers/net/bnxt/bnxt_txr.c +6 -1
index 35e7166bed..172b480b2e 100644
@@ -155,7 +155,7 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
 				PKT_TX_UDP_CKSUM | PKT_TX_IP_CKSUM |
 				PKT_TX_VLAN_PKT | PKT_TX_OUTER_IP_CKSUM |
 				PKT_TX_TUNNEL_GRE | PKT_TX_TUNNEL_VXLAN |
-				PKT_TX_TUNNEL_GENEVE))
+				PKT_TX_TUNNEL_GENEVE | PKT_TX_IEEE1588_TMST))
 		long_bd = true;
 
 	nr_bds = long_bd + tx_pkt->nb_segs;
@@ -324,6 +324,11 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
 			/* IP CSO */
 			txbd1->lflags |= TX_BD_LONG_LFLAGS_T_IP_CHKSUM;
 			txbd1->mss = 0;
+		} else if ((tx_pkt->ol_flags & PKT_TX_IEEE1588_TMST) ==
+			   PKT_TX_IEEE1588_TMST) {
+			/* PTP */
+			txbd1->lflags |= TX_BD_LONG_LFLAGS_STAMP;
+			txbd1->mss = 0;
 		}
 	} else {
 		txbd->flags_type |= TX_BD_SHORT_TYPE_TX_BD_SHORT;
drivers/net/bnxt/hsi_struct_def_dpdk.h +86 -0

90 lines not on this page · raw message

Signature · 1 line
2.20.1 (Apple Git-117)
#34 lore raw
In reply to Ajit Khaparde
Quoted 11 lines · Ajit Khaparde

This patchset adds support to monitor the health of the firmware and the underlying device and recover to an operational state in case of error. We can also detect if a FW upgrade is in progress and quiesce all access to the device and recover once FW indicates everything is ready.

Patchset against dpdk-next-net. Please apply.

v2->v3: Some APIs and dev_ops return types has been updated since
v2 was submitted. This version addresses the conflicts on account of that.

Quoted 16 lines

Kalesh AP (15):
net/bnxt: add FW reset HWRM command
net/bnxt: prevent device access when device is in reset net/bnxt: handle reset notify async event from FW net/bnxt: inform firmware about IF state changes net/bnxt: handle fatal event from FW under error conditions net/bnxt: query firmware error recovery capabilities net/bnxt: map status registers for FW health monitoring net/bnxt: advertise error recovery capability and handle async event net/bnxt: add code for periodic FW health monitoring net/bnxt: add support for FW reset
net/bnxt: add hot firmware upgrade support for Stingray net/bnxt: reduce verbosity of logs
net/bnxt: avoid null pointer dereference
net/bnxt: use BIT macro instead of bit fields
net/bnxt: add PTP support for Thor

Series applied to dpdk-next-net/master, thanks.

#35 lore raw

PATCH 2/13 net/bnxt: prevent device access when device is in reset

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

Refactor init and uninit functions so that the driver can fail the eth_dev_ops callbacks and accessing Tx and Rx queues when device is in reset or in error state.

Transmit and receive queues are freed during reset cleanup and reallocated during recovery. So we block all data path handling in this state. The eth_dev dev_started field is updated depending on the status of the device.

---
 drivers/net/bnxt/bnxt.h        |   1 +
 drivers/net/bnxt/bnxt_ethdev.c | 455 ++++++++++++++++++++++-----------
 drivers/net/bnxt/bnxt_hwrm.c   |   2 -
 drivers/net/bnxt/bnxt_ring.c   |  32 +++
 drivers/net/bnxt/bnxt_ring.h   |   1 +
 drivers/net/bnxt/bnxt_rxq.c    |  25 ++
 drivers/net/bnxt/bnxt_rxr.c    |  17 ++
 drivers/net/bnxt/bnxt_rxr.h    |   2 +
 drivers/net/bnxt/bnxt_stats.c  |  34 ++-
 drivers/net/bnxt/bnxt_txq.c    |   7 +
 drivers/net/bnxt/bnxt_txr.c    |  27 ++
 drivers/net/bnxt/bnxt_txr.h    |   2 +
 12 files changed, 452 insertions(+), 153 deletions(-)
drivers/net/bnxt/bnxt.h +1 -0
index 0c9f994ea..49418cac9 100644
@@ -465,6 +465,7 @@ struct bnxt {
 
 int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete);
 int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id, void *msg);
+int is_bnxt_in_error(struct bnxt *bp);
 
 bool is_bnxt_supported(struct rte_eth_dev *dev);
 bool bnxt_stratus_device(struct bnxt *bp);
drivers/net/bnxt/bnxt_ethdev.c +305 -150

751 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.c +0 -2
index 9883fb506..24a5a0914 100644
@@ -964,8 +964,6 @@ int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, uint32_t flags)
 	HWRM_CHECK_RESULT();
 	HWRM_UNLOCK();
 
-	bp->flags &= ~BNXT_FLAG_REGISTERED;
-
 	return rc;
 }
 
drivers/net/bnxt/bnxt_ring.c +32 -0
index be15b4bd1..f19865c83 100644
@@ -50,6 +50,38 @@ int bnxt_init_ring_grps(struct bnxt *bp)
 	return 0;
 }
 
+int bnxt_alloc_ring_grps(struct bnxt *bp)
+{
+	if (bp->max_tx_rings == 0) {
+		PMD_DRV_LOG(ERR, "No TX rings available!\n");
+		return -EBUSY;
+	}
+
+	/* THOR does not support ring groups.
+	 * But we will use the array to save RSS context IDs.
+	 */
+	if (BNXT_CHIP_THOR(bp)) {
+		bp->max_ring_grps = BNXT_MAX_RSS_CTXTS_THOR;
+	} else if (bp->max_ring_grps < bp->rx_cp_nr_rings) {
+		/* 1 ring is for default completion ring */
+		PMD_DRV_LOG(ERR, "Insufficient resource: Ring Group\n");
+		return -ENOSPC;
+	}
+
+	if (BNXT_HAS_RING_GRPS(bp)) {
+		bp->grp_info = rte_zmalloc("bnxt_grp_info",
+					   sizeof(*bp->grp_info) *
+					   bp->max_ring_grps, 0);
+		if (!bp->grp_info) {
+			PMD_DRV_LOG(ERR,
+				    "Failed to alloc grp info tbl.\n");
+			return -ENOMEM;
+		}
+	}
+
+	return 0;
+}
+
 /*
  * Allocates a completion ring with vmem and stats optionally also allocating
  * a TX and/or RX ring.  Passing NULL as tx_ring_info and/or rx_ring_info
drivers/net/bnxt/bnxt_ring.h +1 -0
index 04c7b04b8..a31d59ea3 100644
@@ -67,6 +67,7 @@ struct bnxt_rx_ring_info;
 struct bnxt_cp_ring_info;
 void bnxt_free_ring(struct bnxt_ring *ring);
 int bnxt_init_ring_grps(struct bnxt *bp);
+int bnxt_alloc_ring_grps(struct bnxt *bp);
 int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
 			    struct bnxt_tx_queue *txq,
 			    struct bnxt_rx_queue *rxq,
drivers/net/bnxt/bnxt_rxq.c +25 -0
index 1d95f1139..d5fc5268d 100644
@@ -263,6 +263,9 @@ void bnxt_rx_queue_release_op(void *rx_queue)
 	struct bnxt_rx_queue *rxq = (struct bnxt_rx_queue *)rx_queue;
 
 	if (rxq) {
+		if (is_bnxt_in_error(rxq->bp))
+			return;
+
 		bnxt_rx_queue_release_mbufs(rxq);
 
 		/* Free RX ring hardware descriptors */
@@ -294,6 +297,10 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
 	int rc = 0;
 	uint8_t queue_state;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	if (queue_idx >= bp->max_rx_rings) {
 		PMD_DRV_LOG(ERR,
 			"Cannot create Rx ring %d. Only %d rings available\n",
@@ -363,10 +370,15 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
 int
 bnxt_rx_queue_intr_enable_op(struct rte_eth_dev *eth_dev, uint16_t queue_id)
 {
+	struct bnxt *bp = eth_dev->data->dev_private;
 	struct bnxt_rx_queue *rxq;
 	struct bnxt_cp_ring_info *cpr;
 	int rc = 0;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	if (eth_dev->data->rx_queues) {
 		rxq = eth_dev->data->rx_queues[queue_id];
 		if (!rxq) {
@@ -382,10 +394,15 @@ bnxt_rx_queue_intr_enable_op(struct rte_eth_dev *eth_dev, uint16_t queue_id)
 int
 bnxt_rx_queue_intr_disable_op(struct rte_eth_dev *eth_dev, uint16_t queue_id)
 {
+	struct bnxt *bp = eth_dev->data->dev_private;
 	struct bnxt_rx_queue *rxq;
 	struct bnxt_cp_ring_info *cpr;
 	int rc = 0;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	if (eth_dev->data->rx_queues) {
 		rxq = eth_dev->data->rx_queues[queue_id];
 		if (!rxq) {
@@ -406,6 +423,10 @@ int bnxt_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 	struct bnxt_vnic_info *vnic = NULL;
 	int rc = 0;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	if (rxq == NULL) {
 		PMD_DRV_LOG(ERR, "Invalid Rx queue %d\n", rx_queue_id);
 		return -EINVAL;
@@ -458,6 +479,10 @@ int bnxt_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 	struct bnxt_rx_queue *rxq = NULL;
 	int rc = 0;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	/* For the stingray platform and other platforms needing tighter
 	 * control of resource utilization, Rx CQ 0 also works as
 	 * Default CQ for async notifications
drivers/net/bnxt/bnxt_rxr.c +17 -0
index 185a0e376..12313dd53 100644
@@ -539,6 +539,9 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	int rc = 0;
 	bool evt = false;
 
+	if (unlikely(is_bnxt_in_error(rxq->bp)))
+		return 0;
+
 	/* If Rx Q was stopped return. RxQ0 cannot be stopped. */
 	if (unlikely(((rxq->rx_deferred_start ||
 		       !rte_spinlock_trylock(&rxq->lock)) &&
@@ -625,6 +628,20 @@ uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 	return nb_rx_pkts;
 }
 
+/*
+ * Dummy DPDK callback for RX.
+ *
+ * This function is used to temporarily replace the real callback during
+ * unsafe control operations on the queue, or in case of error.
+ */
+uint16_t
+bnxt_dummy_recv_pkts(void *rx_queue __rte_unused,
+		     struct rte_mbuf **rx_pkts __rte_unused,
+		     uint16_t nb_pkts __rte_unused)
+{
+	return 0;
+}
+
 void bnxt_free_rx_rings(struct bnxt *bp)
 {
 	int i;
drivers/net/bnxt/bnxt_rxr.h +2 -0
index 6a80c37c8..493b75406 100644
@@ -185,6 +185,8 @@ struct bnxt_rx_ring_info {
 
 uint16_t bnxt_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 			       uint16_t nb_pkts);
+uint16_t bnxt_dummy_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+			      uint16_t nb_pkts);
 void bnxt_free_rx_rings(struct bnxt *bp);
 int bnxt_init_rx_ring_struct(struct bnxt_rx_queue *rxq, unsigned int socket_id);
 int bnxt_init_one_rx_ring(struct bnxt_rx_queue *rxq);
drivers/net/bnxt/bnxt_stats.c +33 -1
index 69ac2dd91..79f23746c 100644
@@ -353,6 +353,10 @@ int bnxt_stats_get_op(struct rte_eth_dev *eth_dev,
 	struct bnxt *bp = eth_dev->data->dev_private;
 	unsigned int num_q_stats;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	memset(bnxt_stats, 0, sizeof(*bnxt_stats));
 	if (!(bp->flags & BNXT_FLAG_INIT_DONE)) {
 		PMD_DRV_LOG(ERR, "Device Initialization not complete!\n");
@@ -397,6 +401,9 @@ void bnxt_stats_reset_op(struct rte_eth_dev *eth_dev)
 	struct bnxt *bp = eth_dev->data->dev_private;
 	unsigned int i;
 
+	if (is_bnxt_in_error(bp))
+		return;
+
 	if (!(bp->flags & BNXT_FLAG_INIT_DONE)) {
 		PMD_DRV_LOG(ERR, "Device Initialization not complete!\n");
 		return;
@@ -414,13 +421,17 @@ int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev,
 			   struct rte_eth_xstat *xstats, unsigned int n)
 {
 	struct bnxt *bp = eth_dev->data->dev_private;
-
 	unsigned int count, i;
 	uint64_t tx_drop_pkts;
 	unsigned int rx_port_stats_ext_cnt;
 	unsigned int tx_port_stats_ext_cnt;
 	unsigned int stat_size = sizeof(uint64_t);
 	unsigned int stat_count;
+	int rc;
+
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
 
 	memset(xstats, 0, sizeof(*xstats));
 
@@ -499,7 +510,13 @@ int bnxt_dev_xstats_get_names_op(__rte_unused struct rte_eth_dev *eth_dev,
 				RTE_DIM(bnxt_tx_stats_strings) + 1 +
 				RTE_DIM(bnxt_rx_ext_stats_strings) +
 				RTE_DIM(bnxt_tx_ext_stats_strings);
+	struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
 	unsigned int i, count;
+	int rc;
+
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
 
 	if (xstats_names != NULL) {
 		count = 0;
@@ -547,6 +564,9 @@ void bnxt_dev_xstats_reset_op(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt *bp = eth_dev->data->dev_private;
 
+	if (is_bnxt_in_error(bp))
+		return;
+
 	if (bp->flags & BNXT_FLAG_PORT_STATS && BNXT_SINGLE_PF(bp))
 		bnxt_hwrm_port_clr_stats(bp);
 
@@ -566,9 +586,15 @@ int bnxt_dev_xstats_get_by_id_op(struct rte_eth_dev *dev, const uint64_t *ids,
 				RTE_DIM(bnxt_tx_stats_strings) + 1 +
 				RTE_DIM(bnxt_rx_ext_stats_strings) +
 				RTE_DIM(bnxt_tx_ext_stats_strings);
+	struct bnxt *bp = dev->data->dev_private;
 	struct rte_eth_xstat xstats[stat_cnt];
 	uint64_t values_copy[stat_cnt];
 	uint16_t i;
+	int rc;
+
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
 
 	if (!ids)
 		return bnxt_dev_xstats_get_op(dev, xstats, stat_cnt);
@@ -594,7 +620,13 @@ int bnxt_dev_xstats_get_names_by_id_op(struct rte_eth_dev *dev,
 				RTE_DIM(bnxt_rx_ext_stats_strings) +
 				RTE_DIM(bnxt_tx_ext_stats_strings);
 	struct rte_eth_xstat_name xstats_names_copy[stat_cnt];
+	struct bnxt *bp = dev->data->dev_private;
 	uint16_t i;
+	int rc;
+
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
 
 	if (!ids)
 		return bnxt_dev_xstats_get_names_op(dev, xstats_names,
drivers/net/bnxt/bnxt_txq.c +7 -0
index 43b3496c1..090132479 100644
@@ -58,6 +58,9 @@ void bnxt_tx_queue_release_op(void *tx_queue)
 	struct bnxt_tx_queue *txq = (struct bnxt_tx_queue *)tx_queue;
 
 	if (txq) {
+		if (is_bnxt_in_error(txq->bp))
+			return;
+
 		/* Free TX ring hardware descriptors */
 		bnxt_tx_queue_release_mbufs(txq);
 		bnxt_free_ring(txq->tx_ring->tx_ring_struct);
@@ -84,6 +87,10 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
 	struct bnxt_tx_queue *txq;
 	int rc = 0;
 
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
+
 	if (queue_idx >= bp->max_tx_rings) {
 		PMD_DRV_LOG(ERR,
 			"Cannot create Tx ring %d. Only %d rings available\n",
drivers/net/bnxt/bnxt_txr.c +27 -0
index c71e6f189..35e7166be 100644
@@ -148,6 +148,9 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,
 		TX_BD_LONG_FLAGS_LHINT_LT2K
 	};
 
+	if (unlikely(is_bnxt_in_error(txq->bp)))
+		return -EIO;
+
 	if (tx_pkt->ol_flags & (PKT_TX_TCP_SEG | PKT_TX_TCP_CKSUM |
 				PKT_TX_UDP_CKSUM | PKT_TX_IP_CKSUM |
 				PKT_TX_VLAN_PKT | PKT_TX_OUTER_IP_CKSUM |
@@ -485,10 +488,29 @@ uint16_t bnxt_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 	return nb_tx_pkts;
 }
 
+/*
+ * Dummy DPDK callback for TX.
+ *
+ * This function is used to temporarily replace the real callback during
+ * unsafe control operations on the queue, or in case of error.
+ */
+uint16_t
+bnxt_dummy_xmit_pkts(void *tx_queue __rte_unused,
+		     struct rte_mbuf **tx_pkts __rte_unused,
+		     uint16_t nb_pkts __rte_unused)
+{
+	return 0;
+}
+
 int bnxt_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 {
 	struct bnxt *bp = dev->data->dev_private;
 	struct bnxt_tx_queue *txq = bp->tx_queues[tx_queue_id];
+	int rc = 0;
+
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
 
 	dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
 	txq->tx_deferred_start = false;
@@ -501,6 +523,11 @@ int bnxt_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 {
 	struct bnxt *bp = dev->data->dev_private;
 	struct bnxt_tx_queue *txq = bp->tx_queues[tx_queue_id];
+	int rc = 0;
+
+	rc = is_bnxt_in_error(bp);
+	if (rc)
+		return rc;
 
 	/* Handle TX completions */
 	bnxt_handle_tx_cp(txq);
drivers/net/bnxt/bnxt_txr.h +2 -0
index 08fd2e014..e7f43f9d1 100644
@@ -57,6 +57,8 @@ int bnxt_init_one_tx_ring(struct bnxt_tx_queue *txq);
 int bnxt_init_tx_ring_struct(struct bnxt_tx_queue *txq, unsigned int socket_id);
 uint16_t bnxt_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			       uint16_t nb_pkts);
+uint16_t bnxt_dummy_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+			      uint16_t nb_pkts);
 #ifdef RTE_ARCH_X86
 uint16_t bnxt_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
 			    uint16_t nb_pkts);
Signature · 1 line
2.20.1 (Apple Git-117)
#36 lore raw

Re: [dpdk-dev] [PATCH 02/13] net/bnxt: prevent device access when device is in reset

Quoted 15 lines · Ajit Khaparde

From: Kalesh AP <[email protected]>

Refactor init and uninit functions so that the driver can fail the eth_dev_ops callbacks and accessing Tx and Rx queues when device is in reset or in error state.

Transmit and receive queues are freed during reset cleanup and reallocated during recovery. So we block all data path handling in this state. The eth_dev dev_started field is updated depending on the status of the device.

<...>

drivers/net/bnxt/bnxt_ethdev.c static void bnxt_print_link_info(struct rte_eth_dev *eth_dev); · line 178

Quoted 13 lines
drivers/net/bnxt/bnxt_ethdev.c +9 -0
@@ -167,6 +167,16 @@ static void bnxt_print_link_info(struct rte_eth_dev *eth_dev);
 static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu);
 static int bnxt_dev_uninit(struct rte_eth_dev *eth_dev);
 
+int is_bnxt_in_error(struct bnxt *bp)
+{
+	if (bp->flags & BNXT_FLAG_FATAL_ERROR)
+		return -EIO;
+	if (bp->flags & BNXT_FLAG_FW_RESET)
+		return -EBUSY;
+
+	return 0;
+}

In this patch 'BNXT_FLAG_FATAL_ERROR' & 'BNXT_FLAG_FW_RESET' are not defined yet, causing build error [1], can you please move the definitions in this patch?

[1]
.../dpdk/drivers/net/bnxt/bnxt_ethdev.c:172:18: error: use of undeclared identifier 'BNXT_FLAG_FATAL_ERROR'

        if (bp->flags & BNXT_FLAG_FATAL_ERROR)
                        ^
.../dpdk/drivers/net/bnxt/bnxt_ethdev.c:174:18: error: use of undeclared
identifier 'BNXT_FLAG_FW_RESET'
        if (bp->flags & BNXT_FLAG_FW_RESET)
                        ^
#37 lore raw

PATCH 3/13 net/bnxt: handle reset notify async event from FW

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

When the FW upgrade is initiated the current instance of FW issues a HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY async notification to the driver. On receiving this notification, the PMD shall quiesce itself and poll on the HWRM_VER_GET FW command at regular intervals.

Once the VER_GET command succeeds, the driver should go through the rediscovery process and re-initialize the device.

Also register with FW for the reset notify async event.

---
 drivers/net/bnxt/bnxt.h        |  15 +++++
 drivers/net/bnxt/bnxt_cpr.c    |  14 +++++
 drivers/net/bnxt/bnxt_cpr.h    |   1 +
 drivers/net/bnxt/bnxt_ethdev.c | 110 ++++++++++++++++++++++++++++-----
 drivers/net/bnxt/bnxt_hwrm.c   |  39 +++++++++---
 drivers/net/bnxt/bnxt_hwrm.h   |   2 +
 6 files changed, 158 insertions(+), 23 deletions(-)
drivers/net/bnxt/bnxt.h +15 -0
index 49418cac9..8797b032e 100644
@@ -333,6 +333,16 @@ struct bnxt_ctx_mem_info {
 	struct bnxt_ctx_pg_info *tqm_mem[BNXT_MAX_TC_Q];
 };
 
+/* Maximum Firmware Reset bail out value in milliseconds */
+#define BNXT_MAX_FW_RESET_TIMEOUT	6000
+/* Minimum time required for the firmware readiness in milliseconds */
+#define BNXT_MIN_FW_READY_TIMEOUT	2000
+/* Frequency for the firmware readiness check in milliseconds */
+#define BNXT_FW_READY_WAIT_INTERVAL	100
+
+#define US_PER_MS			1000
+#define NS_PER_US			1000
+
 #define BNXT_HWRM_SHORT_REQ_LEN		sizeof(struct hwrm_short_input)
 struct bnxt {
 	void				*bar0;
@@ -358,6 +368,8 @@ struct bnxt {
 #define BNXT_FLAG_DFLT_VNIC_SET	(1 << 12)
 #define BNXT_FLAG_THOR_CHIP	(1 << 13)
 #define BNXT_FLAG_STINGRAY	(1 << 14)
+#define BNXT_FLAG_FW_RESET	(1 << 15)
+#define BNXT_FLAG_FATAL_ERROR	(1 << 16)
 #define BNXT_FLAG_EXT_STATS_SUPPORTED	(1 << 29)
 #define BNXT_FLAG_NEW_RM	(1 << 30)
 #define BNXT_FLAG_INIT_DONE	(1U << 31)
@@ -461,6 +473,9 @@ struct bnxt {
 	struct bnxt_ptp_cfg     *ptp_cfg;
 	uint16_t		vf_resv_strategy;
 	struct bnxt_ctx_mem_info        *ctx;
+
+	uint16_t		fw_reset_min_msecs;
+	uint16_t		fw_reset_max_msecs;
 };
 
 int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete);
drivers/net/bnxt/bnxt_cpr.c +14 -0
index 655bcf1a8..cefb5db2a 100644
@@ -40,6 +40,20 @@ void bnxt_handle_async_event(struct bnxt *bp,
 	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED:
 		PMD_DRV_LOG(INFO, "Port conn async event\n");
 		break;
+	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY:
+		/* timestamp_lo/hi values are in units of 100ms */
+		bp->fw_reset_max_msecs = async_cmp->timestamp_hi ?
+			rte_le_to_cpu_16(async_cmp->timestamp_hi) * 100 :
+			BNXT_MAX_FW_RESET_TIMEOUT;
+		bp->fw_reset_min_msecs = async_cmp->timestamp_lo ?
+			async_cmp->timestamp_lo * 100 :
+			BNXT_MIN_FW_READY_TIMEOUT;
+		PMD_DRV_LOG(INFO,
+			    "Firmware non-fatal reset event received\n");
+
+		bp->flags |= BNXT_FLAG_FW_RESET;
+		bnxt_dev_reset_and_resume(bp);
+		break;
 	default:
 		PMD_DRV_LOG(INFO, "handle_async_event id = 0x%x\n", event_id);
 		break;
drivers/net/bnxt/bnxt_cpr.h +1 -0
index 8c6a34b61..4f86e3f60 100644
@@ -106,5 +106,6 @@ struct bnxt;
 void bnxt_handle_async_event(struct bnxt *bp, struct cmpl_base *cmp);
 void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmp);
 int bnxt_event_hwrm_resp_handler(struct bnxt *bp, struct cmpl_base *cmp);
+int bnxt_dev_reset_and_resume(struct bnxt *bp);
 
 #endif
drivers/net/bnxt/bnxt_ethdev.c +94 -16

193 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.c +32 -7
index 24a5a0914..b27dbe87e 100644
@@ -26,7 +26,7 @@
 
 #include <rte_io.h>
 
-#define HWRM_CMD_TIMEOUT		6000000
+#define HWRM_SHORT_CMD_TIMEOUT		50000
 #define HWRM_SPEC_CODE_1_8_3		0x10803
 #define HWRM_VERSION_1_9_1		0x10901
 #define HWRM_VERSION_1_9_2		0x10903
@@ -97,6 +97,14 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,
 		GRCPF_REG_KONG_CHANNEL_OFFSET : GRCPF_REG_CHIMP_CHANNEL_OFFSET;
 	uint16_t mb_trigger_offset = use_kong_mb ?
 		GRCPF_REG_KONG_COMM_TRIGGER : GRCPF_REG_CHIMP_COMM_TRIGGER;
+	uint32_t timeout;
+
+	/* Do not send HWRM commands to firmware in error state */
+	if (bp->flags & BNXT_FLAG_FATAL_ERROR)
+		return 0;
+
+	/* For VER_GET command, set timeout as 50ms */
+	timeout = HWRM_SHORT_CMD_TIMEOUT;
 
 	if (bp->flags & BNXT_FLAG_SHORT_CMD ||
 	    msg_len > bp->max_req_len) {
@@ -139,7 +147,7 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,
 	rte_write32(1, bar);
 
 	/* Poll for the valid bit */
-	for (i = 0; i < HWRM_CMD_TIMEOUT; i++) {
+	for (i = 0; i < timeout; i++) {
 		/* Sanity check on the resp->resp_len */
 		rte_rmb();
 		if (resp->resp_len && resp->resp_len <= bp->max_resp_len) {
@@ -151,7 +159,12 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,
 		rte_delay_us(1);
 	}
 
-	if (i >= HWRM_CMD_TIMEOUT) {
+	if (i >= timeout) {
+		/* Suppress VER_GET timeout messages during reset recovery */
+		if (bp->flags & BNXT_FLAG_FW_RESET &&
+		    rte_cpu_to_le_16(req->req_type) == HWRM_VER_GET)
+			return -ETIMEDOUT;
+
 		PMD_DRV_LOG(ERR, "Error(timeout) sending msg 0x%04x\n",
 			    req->req_type);
 		return -ETIMEDOUT;
@@ -657,12 +670,15 @@ int bnxt_hwrm_func_reset(struct bnxt *bp)
 int bnxt_hwrm_func_driver_register(struct bnxt *bp)
 {
 	int rc;
+	uint32_t flags = 0;
 	struct hwrm_func_drv_rgtr_input req = {.req_type = 0 };
 	struct hwrm_func_drv_rgtr_output *resp = bp->hwrm_cmd_resp_addr;
 
 	if (bp->flags & BNXT_FLAG_REGISTERED)
 		return 0;
 
+	flags = HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_HOT_RESET_SUPPORT;
+
 	HWRM_PREP(req, FUNC_DRV_RGTR, BNXT_USE_CHIMP_MB);
 	req.enables = rte_cpu_to_le_32(HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VER |
 			HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_ASYNC_EVENT_FWD);
@@ -683,14 +699,16 @@ int bnxt_hwrm_func_driver_register(struct bnxt *bp)
 		 * this HWRM sniffer list in FW because DPDK PF driver does
 		 * not support this.
 		 */
-		req.flags =
-		rte_cpu_to_le_32(HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_FWD_NONE_MODE);
+		flags |= HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_FWD_NONE_MODE;
 	}
 
+	req.flags = rte_cpu_to_le_32(flags);
+
 	req.async_event_fwd[0] |=
 		rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_LINK_STATUS_CHANGE |
 				 ASYNC_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED |
-				 ASYNC_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE);
+				 ASYNC_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE |
+				 ASYNC_CMPL_EVENT_ID_RESET_NOTIFY);
 	req.async_event_fwd[1] |=
 		rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_PF_DRVR_UNLOAD |
 				 ASYNC_CMPL_EVENT_ID_VF_CFG_CHANGE);
@@ -837,7 +855,10 @@ int bnxt_hwrm_ver_get(struct bnxt *bp)
 
 	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
 
-	HWRM_CHECK_RESULT();
+	if (bp->flags & BNXT_FLAG_FW_RESET)
+		HWRM_CHECK_RESULT_SILENT();
+	else
+		HWRM_CHECK_RESULT();
 
 	PMD_DRV_LOG(INFO, "%d.%d.%d:%d.%d.%d\n",
 		resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b,
@@ -2685,6 +2706,10 @@ int bnxt_hwrm_func_qcfg(struct bnxt *bp, uint16_t *mtu)
 	if (BNXT_VF(bp) && (flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_TRUSTED_VF)) {
 		bp->flags |= BNXT_FLAG_TRUSTED_VF_EN;
 		PMD_DRV_LOG(INFO, "Trusted VF cap enabled\n");
+	} else if (BNXT_VF(bp) &&
+		   !(flags & HWRM_FUNC_QCFG_OUTPUT_FLAGS_TRUSTED_VF)) {
+		bp->flags &= ~BNXT_FLAG_TRUSTED_VF_EN;
+		PMD_DRV_LOG(INFO, "Trusted VF cap disabled\n");
 	}
 
 	if (mtu)
drivers/net/bnxt/bnxt_hwrm.h +2 -0
index c882fc2a1..a03620532 100644
@@ -21,6 +21,8 @@ struct bnxt_cp_ring_info;
 	(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED)
 #define ASYNC_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE	\
 	(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE)
+#define ASYNC_CMPL_EVENT_ID_RESET_NOTIFY \
+	(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY)
 #define ASYNC_CMPL_EVENT_ID_PF_DRVR_UNLOAD	\
 	(1 << (HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD - 32))
 #define ASYNC_CMPL_EVENT_ID_VF_CFG_CHANGE	\
Signature · 1 line
2.20.1 (Apple Git-117)
#38 lore raw

PATCH 4/13 net/bnxt: inform firmware about IF state changes

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

Use latest firmware API to inform firmware about IF state changes. Firmware has the option to clean up resources during IF down and to require the driver to reserve resources again during IF up.

---
 drivers/net/bnxt/bnxt.h        |  1 +
 drivers/net/bnxt/bnxt_ethdev.c |  4 ++++
 drivers/net/bnxt/bnxt_hwrm.c   | 35 ++++++++++++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.h   |  1 +
 4 files changed, 41 insertions(+)
drivers/net/bnxt/bnxt.h +1 -0
index 8797b032e..394a2a941 100644
@@ -370,6 +370,7 @@ struct bnxt {
 #define BNXT_FLAG_STINGRAY	(1 << 14)
 #define BNXT_FLAG_FW_RESET	(1 << 15)
 #define BNXT_FLAG_FATAL_ERROR	(1 << 16)
+#define BNXT_FLAG_FW_CAP_IF_CHANGE	(1 << 17)
 #define BNXT_FLAG_EXT_STATS_SUPPORTED	(1 << 29)
 #define BNXT_FLAG_NEW_RM	(1 << 30)
 #define BNXT_FLAG_INIT_DONE	(1U << 31)
drivers/net/bnxt/bnxt_ethdev.c +4 -0
index 1aef227f2..f7b2ef179 100644
@@ -803,6 +803,8 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 			bp->rx_cp_nr_rings, RTE_ETHDEV_QUEUE_STAT_CNTRS);
 	}
 
+	bnxt_hwrm_if_change(bp, 1);
+
 	rc = bnxt_init_chip(bp);
 	if (rc)
 		goto error;
@@ -829,6 +831,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 	return 0;
 
 error:
+	bnxt_hwrm_if_change(bp, 0);
 	bnxt_shutdown_nic(bp);
 	bnxt_free_tx_mbufs(bp);
 	bnxt_free_rx_mbufs(bp);
@@ -895,6 +898,7 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
 	bnxt_free_tx_mbufs(bp);
 	bnxt_free_rx_mbufs(bp);
 	bnxt_shutdown_nic(bp);
+	bnxt_hwrm_if_change(bp, 0);
 	bp->dev_stopped = 1;
 }
 
drivers/net/bnxt/bnxt_hwrm.c +35 -0
index b27dbe87e..17c7b5e9e 100644
@@ -716,6 +716,11 @@ int bnxt_hwrm_func_driver_register(struct bnxt *bp)
 	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
 
 	HWRM_CHECK_RESULT();
+
+	flags = rte_le_to_cpu_32(resp->flags);
+	if (flags & HWRM_FUNC_DRV_RGTR_OUTPUT_FLAGS_IF_CHANGE_SUPPORTED)
+		bp->flags |= BNXT_FLAG_FW_CAP_IF_CHANGE;
+
 	HWRM_UNLOCK();
 
 	bp->flags |= BNXT_FLAG_REGISTERED;
@@ -4649,3 +4654,33 @@ int bnxt_hwrm_set_mac(struct bnxt *bp)
 
 	return rc;
 }
+
+int bnxt_hwrm_if_change(struct bnxt *bp, bool state)
+{
+	struct hwrm_func_drv_if_change_output *resp = bp->hwrm_cmd_resp_addr;
+	struct hwrm_func_drv_if_change_input req = {0};
+	int rc;
+
+	if (!(bp->flags & BNXT_FLAG_FW_CAP_IF_CHANGE))
+		return 0;
+
+	/* Do not issue FUNC_DRV_IF_CHANGE during reset recovery.
+	 * If we issue FUNC_DRV_IF_CHANGE with flags down before
+	 * FUNC_DRV_UNRGTR, FW resets before FUNC_DRV_UNRGTR
+	 */
+	if (!state && (bp->flags & BNXT_FLAG_FW_RESET))
+		return 0;
+
+	HWRM_PREP(req, FUNC_DRV_IF_CHANGE, BNXT_USE_CHIMP_MB);
+
+	if (state)
+		req.flags =
+		rte_cpu_to_le_32(HWRM_FUNC_DRV_IF_CHANGE_INPUT_FLAGS_UP);
+
+	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+
+	HWRM_CHECK_RESULT();
+	HWRM_UNLOCK();
+
+	return rc;
+}
drivers/net/bnxt/bnxt_hwrm.h +1 -0
index a03620532..2f57e950b 100644
@@ -201,4 +201,5 @@ int bnxt_hwrm_tunnel_redirect_query(struct bnxt *bp, uint32_t *type);
 int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
 				   uint16_t *dst_fid);
 int bnxt_hwrm_set_mac(struct bnxt *bp);
+int bnxt_hwrm_if_change(struct bnxt *bp, bool state);
 #endif
Signature · 1 line
2.20.1 (Apple Git-117)
#39 lore raw

PATCH 5/13 net/bnxt: handle fatal event from FW under error conditions

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

When firmware hit some unrecoverable error conditions, firmware initiate the recovery by sending an async event EVENT_CMPL_EVENT_ID_RESET_NOTIFY with data1 set to RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL to all host drivers and will reset the chip.

The recovery procedure is same sequence as the one for hot FW upgrade.

---
 drivers/net/bnxt/bnxt_cpr.c    | 13 +++++++++++--
 drivers/net/bnxt/bnxt_cpr.h    |  5 +++++
 drivers/net/bnxt/bnxt_ethdev.c |  3 +++
 3 files changed, 19 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt_cpr.c +11 -2
index cefb5db2a..6e0b1d67e 100644
@@ -20,6 +20,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
 	struct hwrm_async_event_cmpl *async_cmp =
 				(struct hwrm_async_event_cmpl *)cmp;
 	uint16_t event_id = rte_le_to_cpu_16(async_cmp->event_id);
+	uint32_t event_data;
 
 	/* TODO: HWRM async events are not defined yet */
 	/* Needs to handle: link events, error events, etc. */
@@ -41,6 +42,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
 		PMD_DRV_LOG(INFO, "Port conn async event\n");
 		break;
 	case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY:
+		event_data = rte_le_to_cpu_32(async_cmp->event_data1);
 		/* timestamp_lo/hi values are in units of 100ms */
 		bp->fw_reset_max_msecs = async_cmp->timestamp_hi ?
 			rte_le_to_cpu_16(async_cmp->timestamp_hi) * 100 :
@@ -48,8 +50,15 @@ void bnxt_handle_async_event(struct bnxt *bp,
 		bp->fw_reset_min_msecs = async_cmp->timestamp_lo ?
 			async_cmp->timestamp_lo * 100 :
 			BNXT_MIN_FW_READY_TIMEOUT;
-		PMD_DRV_LOG(INFO,
-			    "Firmware non-fatal reset event received\n");
+		if ((event_data & EVENT_DATA1_REASON_CODE_MASK) ==
+		    EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL) {
+			PMD_DRV_LOG(INFO,
+				    "Firmware fatal reset event received\n");
+			bp->flags |= BNXT_FLAG_FATAL_ERROR;
+		} else {
+			PMD_DRV_LOG(INFO,
+				    "Firmware non-fatal reset event received\n");
+		}
 
 		bp->flags |= BNXT_FLAG_FW_RESET;
 		bnxt_dev_reset_and_resume(bp);
drivers/net/bnxt/bnxt_cpr.h +5 -0
index 4f86e3f60..4e63fd12f 100644
@@ -108,4 +108,9 @@ void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmp);
 int bnxt_event_hwrm_resp_handler(struct bnxt *bp, struct cmpl_base *cmp);
 int bnxt_dev_reset_and_resume(struct bnxt *bp);
 
+#define EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL     \
+	HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_FW_EXCEPTION_FATAL
+#define EVENT_DATA1_REASON_CODE_MASK                   \
+	HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MASK
+
 #endif
drivers/net/bnxt/bnxt_ethdev.c +3 -0
index f7b2ef179..a0b9e8f9e 100644
@@ -3512,6 +3512,9 @@ static void bnxt_dev_recover(void *arg)
 	int timeout = bp->fw_reset_max_msecs;
 	int rc = 0;
 
+	/* Clear Error flag so that device re-init should happen */
+	bp->flags &= ~BNXT_FLAG_FATAL_ERROR;
+
 	do {
 		rc = bnxt_hwrm_ver_get(bp);
 		if (rc == 0)
Signature · 1 line
2.20.1 (Apple Git-117)
#40 lore raw

PATCH 6/13 net/bnxt: query firmware error recovery capabilities

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

In Driver initiated error recovery process, driver has to know about the registers offset and values to initiate FW reset. The HWRM command HWRM_ERROR_RECOVERY_QCFG is used to obtain all the registers and values required to initiate FW reset. This command response includes FW heart_beat register, health status register, Error counter register, register offsets and values to do chip reset if firmware crashes and becomes unresponsive.

---
 drivers/net/bnxt/bnxt.h        | 27 +++++++++++
 drivers/net/bnxt/bnxt_ethdev.c | 10 ++++
 drivers/net/bnxt/bnxt_hwrm.c   | 89 ++++++++++++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.h   |  1 +
 4 files changed, 127 insertions(+)
drivers/net/bnxt/bnxt.h +27 -0
index 394a2a941..19bd13a7f 100644
@@ -343,6 +343,29 @@ struct bnxt_ctx_mem_info {
 #define US_PER_MS			1000
 #define NS_PER_US			1000
 
+struct bnxt_error_recovery_info {
+	/* All units in milliseconds */
+	uint32_t	driver_polling_freq;
+	uint32_t	master_func_wait_period;
+	uint32_t	normal_func_wait_period;
+	uint32_t	master_func_wait_period_after_reset;
+	uint32_t	max_bailout_time_after_reset;
+#define BNXT_FW_STATUS_REG		0
+#define BNXT_FW_HEARTBEAT_CNT_REG	1
+#define BNXT_FW_RECOVERY_CNT_REG	2
+#define BNXT_FW_RESET_INPROG_REG	3
+	uint32_t	status_regs[4];
+	uint32_t	reset_inprogress_reg_mask;
+#define BNXT_NUM_RESET_REG	16
+	uint8_t		reg_array_cnt;
+	uint32_t	reset_reg[BNXT_NUM_RESET_REG];
+	uint32_t	reset_reg_val[BNXT_NUM_RESET_REG];
+	uint8_t		delay_after_reset[BNXT_NUM_RESET_REG];
+#define BNXT_FLAG_ERROR_RECOVERY_HOST	(1 << 0)
+#define BNXT_FLAG_ERROR_RECOVERY_CO_CPU	(1 << 1)
+	uint32_t	flags;
+};
+
 #define BNXT_HWRM_SHORT_REQ_LEN		sizeof(struct hwrm_short_input)
 struct bnxt {
 	void				*bar0;
@@ -371,6 +394,7 @@ struct bnxt {
 #define BNXT_FLAG_FW_RESET	(1 << 15)
 #define BNXT_FLAG_FATAL_ERROR	(1 << 16)
 #define BNXT_FLAG_FW_CAP_IF_CHANGE	(1 << 17)
+#define BNXT_FLAG_FW_CAP_ERROR_RECOVERY	(1 << 18)
 #define BNXT_FLAG_EXT_STATS_SUPPORTED	(1 << 29)
 #define BNXT_FLAG_NEW_RM	(1 << 30)
 #define BNXT_FLAG_INIT_DONE	(1U << 31)
@@ -477,6 +501,9 @@ struct bnxt {
 
 	uint16_t		fw_reset_min_msecs;
 	uint16_t		fw_reset_max_msecs;
+
+	/* Struct to hold adapter error recovery related info */
+	struct bnxt_error_recovery_info *recovery_info;
 };
 
 int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete);
drivers/net/bnxt/bnxt_ethdev.c +10 -0
index a0b9e8f9e..18046c00a 100644
@@ -4071,6 +4071,11 @@ static int bnxt_init_fw(struct bnxt *bp)
 	if (rc)
 		return rc;
 
+	/* Get the adapter error recovery support info */
+	rc = bnxt_hwrm_error_recovery_qcfg(bp);
+	if (rc)
+		bp->flags &= ~BNXT_FLAG_FW_CAP_ERROR_RECOVERY;
+
 	if (mtu >= RTE_ETHER_MIN_MTU && mtu <= BNXT_MAX_MTU &&
 	    mtu != bp->eth_dev->data->mtu)
 		bp->eth_dev->data->mtu = mtu;
@@ -4228,6 +4233,11 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev)
 	if (!reconfig_dev)
 		bnxt_free_hwrm_resources(bp);
 
+	if (bp->recovery_info != NULL) {
+		rte_free(bp->recovery_info);
+		bp->recovery_info = NULL;
+	}
+
 	return rc;
 }
 
drivers/net/bnxt/bnxt_hwrm.c +89 -0

98 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.h +1 -0
index 2f57e950b..c332c129d 100644
@@ -202,4 +202,5 @@ int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
 				   uint16_t *dst_fid);
 int bnxt_hwrm_set_mac(struct bnxt *bp);
 int bnxt_hwrm_if_change(struct bnxt *bp, bool state);
+int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp);
 #endif
Signature · 1 line
2.20.1 (Apple Git-117)
#41 lore raw

PATCH 7/13 net/bnxt: map status registers for FW health monitoring

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

HWRM_ERROR_RECOVERY_QCFG command returns the FW status registers offset for periodic firmware health check monitoring. Map them to GRC window 2.

---
 drivers/net/bnxt/bnxt.h        | 22 ++++++++++++++++-
 drivers/net/bnxt/bnxt_ethdev.c | 44 ++++++++++++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_hwrm.c   |  4 ++++
 3 files changed, 69 insertions(+), 1 deletion(-)
drivers/net/bnxt/bnxt.h +21 -1
index 19bd13a7f..1da09569d 100644
@@ -354,7 +354,9 @@ struct bnxt_error_recovery_info {
 #define BNXT_FW_HEARTBEAT_CNT_REG	1
 #define BNXT_FW_RECOVERY_CNT_REG	2
 #define BNXT_FW_RESET_INPROG_REG	3
-	uint32_t	status_regs[4];
+#define BNXT_FW_STATUS_REG_CNT		4
+	uint32_t	status_regs[BNXT_FW_STATUS_REG_CNT];
+	uint32_t	mapped_status_regs[BNXT_FW_STATUS_REG_CNT];
 	uint32_t	reset_inprogress_reg_mask;
 #define BNXT_NUM_RESET_REG	16
 	uint8_t		reg_array_cnt;
@@ -366,6 +368,22 @@ struct bnxt_error_recovery_info {
 	uint32_t	flags;
 };
 
+/* address space location of register */
+#define BNXT_FW_STATUS_REG_TYPE_MASK	3
+/* register is located in PCIe config space */
+#define BNXT_FW_STATUS_REG_TYPE_CFG	0
+/* register is located in GRC address space */
+#define BNXT_FW_STATUS_REG_TYPE_GRC	1
+/* register is located in BAR0  */
+#define BNXT_FW_STATUS_REG_TYPE_BAR0	2
+/* register is located in BAR1  */
+#define BNXT_FW_STATUS_REG_TYPE_BAR1	3
+
+#define BNXT_FW_STATUS_REG_TYPE(reg)	((reg) & BNXT_FW_STATUS_REG_TYPE_MASK)
+#define BNXT_FW_STATUS_REG_OFF(reg)	((reg) & ~BNXT_FW_STATUS_REG_TYPE_MASK)
+
+#define BNXT_GRCP_WINDOW_2_BASE		0x2000
+
 #define BNXT_HWRM_SHORT_REQ_LEN		sizeof(struct hwrm_short_input)
 struct bnxt {
 	void				*bar0;
@@ -510,6 +528,8 @@ int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete);
 int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id, void *msg);
 int is_bnxt_in_error(struct bnxt *bp);
 
+int bnxt_map_fw_health_status_regs(struct bnxt *bp);
+
 bool is_bnxt_supported(struct rte_eth_dev *dev);
 bool bnxt_stratus_device(struct bnxt *bp);
 extern const struct rte_flow_ops bnxt_flow_ops;
drivers/net/bnxt/bnxt_ethdev.c +44 -0

56 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.c +4 -0
index e2c993936..2d9c43c98 100644
@@ -4767,6 +4767,10 @@ int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp)
 err:
 	HWRM_UNLOCK();
 
+	/* Map the FW status registers */
+	if (!rc)
+		rc = bnxt_map_fw_health_status_regs(bp);
+
 	if (rc) {
 		rte_free(bp->recovery_info);
 		bp->recovery_info = NULL;
Signature · 1 line
2.20.1 (Apple Git-117)
#42 lore raw

PATCH 8/13 net/bnxt: advertise error recovery capability and handle async event

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

1. Advertise HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_ERROR_RECOVERY_SUPPORT flag in the FUNC_DRV_RGTR command.
2. request for the async event ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY in the FUNC_DRV_RGTR command.
3. handle the async event EVENT_ID_ERROR_RECOVERY from FW.

Error recovery support will be used by firmware only if all the driver instances support error recovery process.

---
 drivers/net/bnxt/bnxt.h      |  2 ++
 drivers/net/bnxt/bnxt_cpr.c  | 45 ++++++++++++++++++++++++++++++++++++
 drivers/net/bnxt/bnxt_cpr.h  | 12 ++++++++++
 drivers/net/bnxt/bnxt_hwrm.c |  5 ++++
 drivers/net/bnxt/bnxt_hwrm.h |  2 ++
 5 files changed, 66 insertions(+)
drivers/net/bnxt/bnxt.h +2 -0
index 1da09569d..f9147a9a8 100644
@@ -365,6 +365,8 @@ struct bnxt_error_recovery_info {
 	uint8_t		delay_after_reset[BNXT_NUM_RESET_REG];
 #define BNXT_FLAG_ERROR_RECOVERY_HOST	(1 << 0)
 #define BNXT_FLAG_ERROR_RECOVERY_CO_CPU	(1 << 1)
+#define BNXT_FLAG_MASTER_FUNC		(1 << 2)
+#define BNXT_FLAG_RECOVERY_ENABLED	(1 << 3)
 	uint32_t	flags;
 };
 
drivers/net/bnxt/bnxt_cpr.c +45 -0

60 lines not on this page · raw message

drivers/net/bnxt/bnxt_cpr.h +12 -0
index 4e63fd12f..22fba5b40 100644
@@ -113,4 +113,16 @@ int bnxt_dev_reset_and_resume(struct bnxt *bp);
 #define EVENT_DATA1_REASON_CODE_MASK                   \
 	HWRM_ASYNC_EVENT_CMPL_RESET_NOTIFY_EVENT_DATA1_REASON_CODE_MASK
 
+#define EVENT_DATA1_FLAGS_MASK                         \
+	HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_MASK
+
+#define EVENT_DATA1_FLAGS_MASTER_FUNC                  \
+	HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_MASTER_FUNC
+
+#define EVENT_DATA1_FLAGS_RECOVERY_ENABLED             \
+	HWRM_ASYNC_EVENT_CMPL_ERROR_RECOVERY_EVENT_DATA1_FLAGS_RECOVERY_ENABLED
+
+bool bnxt_is_recovery_enabled(struct bnxt *bp);
+bool bnxt_is_master_func(struct bnxt *bp);
+
 #endif
drivers/net/bnxt/bnxt_hwrm.c +5 -0
index 2d9c43c98..350e867bf 100644
@@ -685,6 +685,8 @@ int bnxt_hwrm_func_driver_register(struct bnxt *bp)
 		return 0;
 
 	flags = HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_HOT_RESET_SUPPORT;
+	if (bp->flags & BNXT_FLAG_FW_CAP_ERROR_RECOVERY)
+		flags |= HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_ERROR_RECOVERY_SUPPORT;
 
 	HWRM_PREP(req, FUNC_DRV_RGTR, BNXT_USE_CHIMP_MB);
 	req.enables = rte_cpu_to_le_32(HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VER |
@@ -716,6 +718,9 @@ int bnxt_hwrm_func_driver_register(struct bnxt *bp)
 				 ASYNC_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED |
 				 ASYNC_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE |
 				 ASYNC_CMPL_EVENT_ID_RESET_NOTIFY);
+	if (bp->flags & BNXT_FLAG_FW_CAP_ERROR_RECOVERY)
+		req.async_event_fwd[0] |=
+			rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_ERROR_RECOVERY);
 	req.async_event_fwd[1] |=
 		rte_cpu_to_le_32(ASYNC_CMPL_EVENT_ID_PF_DRVR_UNLOAD |
 				 ASYNC_CMPL_EVENT_ID_VF_CFG_CHANGE);
drivers/net/bnxt/bnxt_hwrm.h +2 -0
index c332c129d..44e335507 100644
@@ -23,6 +23,8 @@ struct bnxt_cp_ring_info;
 	(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE)
 #define ASYNC_CMPL_EVENT_ID_RESET_NOTIFY \
 	(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_RESET_NOTIFY)
+#define ASYNC_CMPL_EVENT_ID_ERROR_RECOVERY \
+	(1 << HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY)
 #define ASYNC_CMPL_EVENT_ID_PF_DRVR_UNLOAD	\
 	(1 << (HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD - 32))
 #define ASYNC_CMPL_EVENT_ID_VF_CFG_CHANGE	\
Signature · 1 line
2.20.1 (Apple Git-117)
#43 lore raw

PATCH 9/13 net/bnxt: add code for periodic FW health monitoring

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

Periodically poll the FW heartbeat register and FW recovery counter registers to check the FW health. Polling frequency will be advertised by the FW in HWRM_ERROR_RECOVERY_QCFG response. Schedule the task upon receiving the async event from FW.

---
 drivers/net/bnxt/bnxt.h        |  5 ++
 drivers/net/bnxt/bnxt_cpr.c    |  7 +++
 drivers/net/bnxt/bnxt_ethdev.c | 89 ++++++++++++++++++++++++++++++++++
 3 files changed, 101 insertions(+)
drivers/net/bnxt/bnxt.h +5 -0
index f9147a9a8..a23c4a64c 100644
@@ -368,6 +368,9 @@ struct bnxt_error_recovery_info {
 #define BNXT_FLAG_MASTER_FUNC		(1 << 2)
 #define BNXT_FLAG_RECOVERY_ENABLED	(1 << 3)
 	uint32_t	flags;
+
+	uint32_t        last_heart_beat;
+	uint32_t        last_reset_counter;
 };
 
 /* address space location of register */
@@ -531,6 +534,8 @@ int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id, void *msg);
 int is_bnxt_in_error(struct bnxt *bp);
 
 int bnxt_map_fw_health_status_regs(struct bnxt *bp);
+uint32_t bnxt_read_fw_status_reg(struct bnxt *bp, uint32_t index);
+void bnxt_schedule_fw_health_check(struct bnxt *bp);
 
 bool is_bnxt_supported(struct rte_eth_dev *dev);
 bool bnxt_stratus_device(struct bnxt *bp);
drivers/net/bnxt/bnxt_cpr.c +7 -0
index 7f5b3314e..a692fbe7c 100644
@@ -88,6 +88,13 @@ void bnxt_handle_async_event(struct bnxt *bp,
 		PMD_DRV_LOG(INFO, "recovery enabled(%d), master function(%d)\n",
 			    bnxt_is_recovery_enabled(bp),
 			    bnxt_is_master_func(bp));
+
+		info->last_heart_beat =
+			bnxt_read_fw_status_reg(bp, BNXT_FW_HEARTBEAT_CNT_REG);
+		info->last_reset_counter =
+			bnxt_read_fw_status_reg(bp, BNXT_FW_RECOVERY_CNT_REG);
+
+		bnxt_schedule_fw_health_check(bp);
 		break;
 	default:
 		PMD_DRV_LOG(INFO, "handle_async_event id = 0x%x\n", event_id);
drivers/net/bnxt/bnxt_ethdev.c +89 -0

107 lines not on this page · raw message

Signature · 1 line
2.20.1 (Apple Git-117)
#44 lore raw

PATCH 10/13 net/bnxt: use BIT macro instead of bit fields

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

use BIT macro instead of bit fields.

---
 drivers/net/bnxt/bnxt.h      | 73 ++++++++++++++++++------------------
 drivers/net/bnxt/bnxt_util.h |  4 ++
 2 files changed, 41 insertions(+), 36 deletions(-)
drivers/net/bnxt/bnxt.h +37 -36
index a23c4a64c..93aac15b4 100644
@@ -19,6 +19,7 @@
 #include <rte_time.h>
 
 #include "bnxt_cpr.h"
+#include "bnxt_util.h"
 
 #define BNXT_MAX_MTU		9574
 #define VLAN_TAG_SIZE		4
@@ -198,16 +199,16 @@ struct bnxt_ptp_cfg {
 	struct bnxt		*bp;
 #define BNXT_MAX_TX_TS	1
 	uint16_t			rxctl;
-#define BNXT_PTP_MSG_SYNC			(1 << 0)
-#define BNXT_PTP_MSG_DELAY_REQ			(1 << 1)
-#define BNXT_PTP_MSG_PDELAY_REQ			(1 << 2)
-#define BNXT_PTP_MSG_PDELAY_RESP		(1 << 3)
-#define BNXT_PTP_MSG_FOLLOW_UP			(1 << 8)
-#define BNXT_PTP_MSG_DELAY_RESP			(1 << 9)
-#define BNXT_PTP_MSG_PDELAY_RESP_FOLLOW_UP	(1 << 10)
-#define BNXT_PTP_MSG_ANNOUNCE			(1 << 11)
-#define BNXT_PTP_MSG_SIGNALING			(1 << 12)
-#define BNXT_PTP_MSG_MANAGEMENT			(1 << 13)
+#define BNXT_PTP_MSG_SYNC			BIT(0)
+#define BNXT_PTP_MSG_DELAY_REQ			BIT(1)
+#define BNXT_PTP_MSG_PDELAY_REQ			BIT(2)
+#define BNXT_PTP_MSG_PDELAY_RESP		BIT(3)
+#define BNXT_PTP_MSG_FOLLOW_UP			BIT(8)
+#define BNXT_PTP_MSG_DELAY_RESP			BIT(9)
+#define BNXT_PTP_MSG_PDELAY_RESP_FOLLOW_UP	BIT(10)
+#define BNXT_PTP_MSG_ANNOUNCE			BIT(11)
+#define BNXT_PTP_MSG_SIGNALING			BIT(12)
+#define BNXT_PTP_MSG_MANAGEMENT			BIT(13)
 #define BNXT_PTP_MSG_EVENTS		(BNXT_PTP_MSG_SYNC |		\
 					 BNXT_PTP_MSG_DELAY_REQ |	\
 					 BNXT_PTP_MSG_PDELAY_REQ |	\
@@ -363,10 +364,10 @@ struct bnxt_error_recovery_info {
 	uint32_t	reset_reg[BNXT_NUM_RESET_REG];
 	uint32_t	reset_reg_val[BNXT_NUM_RESET_REG];
 	uint8_t		delay_after_reset[BNXT_NUM_RESET_REG];
-#define BNXT_FLAG_ERROR_RECOVERY_HOST	(1 << 0)
-#define BNXT_FLAG_ERROR_RECOVERY_CO_CPU	(1 << 1)
-#define BNXT_FLAG_MASTER_FUNC		(1 << 2)
-#define BNXT_FLAG_RECOVERY_ENABLED	(1 << 3)
+#define BNXT_FLAG_ERROR_RECOVERY_HOST	BIT(0)
+#define BNXT_FLAG_ERROR_RECOVERY_CO_CPU	BIT(1)
+#define BNXT_FLAG_MASTER_FUNC		BIT(2)
+#define BNXT_FLAG_RECOVERY_ENABLED	BIT(3)
 	uint32_t	flags;
 
 	uint32_t        last_heart_beat;
@@ -399,28 +400,28 @@ struct bnxt {
 	void				*doorbell_base;
 
 	uint32_t		flags;
-#define BNXT_FLAG_REGISTERED	(1 << 0)
-#define BNXT_FLAG_VF		(1 << 1)
-#define BNXT_FLAG_PORT_STATS	(1 << 2)
-#define BNXT_FLAG_JUMBO		(1 << 3)
-#define BNXT_FLAG_SHORT_CMD	(1 << 4)
-#define BNXT_FLAG_UPDATE_HASH	(1 << 5)
-#define BNXT_FLAG_PTP_SUPPORTED	(1 << 6)
-#define BNXT_FLAG_MULTI_HOST    (1 << 7)
-#define BNXT_FLAG_EXT_RX_PORT_STATS	(1 << 8)
-#define BNXT_FLAG_EXT_TX_PORT_STATS	(1 << 9)
-#define BNXT_FLAG_KONG_MB_EN	(1 << 10)
-#define BNXT_FLAG_TRUSTED_VF_EN	(1 << 11)
-#define BNXT_FLAG_DFLT_VNIC_SET	(1 << 12)
-#define BNXT_FLAG_THOR_CHIP	(1 << 13)
-#define BNXT_FLAG_STINGRAY	(1 << 14)
-#define BNXT_FLAG_FW_RESET	(1 << 15)
-#define BNXT_FLAG_FATAL_ERROR	(1 << 16)
-#define BNXT_FLAG_FW_CAP_IF_CHANGE	(1 << 17)
-#define BNXT_FLAG_FW_CAP_ERROR_RECOVERY	(1 << 18)
-#define BNXT_FLAG_EXT_STATS_SUPPORTED	(1 << 29)
-#define BNXT_FLAG_NEW_RM	(1 << 30)
-#define BNXT_FLAG_INIT_DONE	(1U << 31)
+#define BNXT_FLAG_REGISTERED		BIT(0)
+#define BNXT_FLAG_VF			BIT(1)
+#define BNXT_FLAG_PORT_STATS		BIT(2)
+#define BNXT_FLAG_JUMBO			BIT(3)
+#define BNXT_FLAG_SHORT_CMD		BIT(4)
+#define BNXT_FLAG_UPDATE_HASH		BIT(5)
+#define BNXT_FLAG_PTP_SUPPORTED		BIT(6)
+#define BNXT_FLAG_MULTI_HOST		BIT(7)
+#define BNXT_FLAG_EXT_RX_PORT_STATS	BIT(8)
+#define BNXT_FLAG_EXT_TX_PORT_STATS	BIT(9)
+#define BNXT_FLAG_KONG_MB_EN		BIT(10)
+#define BNXT_FLAG_TRUSTED_VF_EN		BIT(11)
+#define BNXT_FLAG_DFLT_VNIC_SET		BIT(12)
+#define BNXT_FLAG_THOR_CHIP		BIT(13)
+#define BNXT_FLAG_STINGRAY		BIT(14)
+#define BNXT_FLAG_FW_RESET		BIT(15)
+#define BNXT_FLAG_FATAL_ERROR		BIT(16)
+#define BNXT_FLAG_FW_CAP_IF_CHANGE	BIT(17)
+#define BNXT_FLAG_FW_CAP_ERROR_RECOVERY	BIT(18)
+#define BNXT_FLAG_EXT_STATS_SUPPORTED	BIT(19)
+#define BNXT_FLAG_NEW_RM		BIT(20)
+#define BNXT_FLAG_INIT_DONE		BIT(21)
 #define BNXT_PF(bp)		(!((bp)->flags & BNXT_FLAG_VF))
 #define BNXT_VF(bp)		((bp)->flags & BNXT_FLAG_VF)
 #define BNXT_NPAR(bp)		((bp)->port_partition_type)
drivers/net/bnxt/bnxt_util.h +4 -0
index 9f1868a78..a15b3a1a9 100644
@@ -6,6 +6,10 @@
 #ifndef _BNXT_UTIL_H_
 #define _BNXT_UTIL_H_
 
+#ifndef BIT
+#define BIT(n)	(1UL << (n))
+#endif /* BIT */
+
 int bnxt_check_zero_bytes(const uint8_t *bytes, int len);
 void bnxt_eth_hw_addr_random(uint8_t *mac_addr);
 
Signature · 1 line
2.20.1 (Apple Git-117)
#45 lore raw

PATCH 11/13 net/bnxt: reschedule the health check alarm correctly

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

When the driver receives the error recovery notify event from fw for the first time, it has to read the heartbeat count register and recovery count register and schedule the fw health check task for periodically monitoring the fw health.

FW may send this event at a later time when the state of master function changes. There is no need to schedule the health check task this time.

---
 drivers/net/bnxt/bnxt.h        | 1 +
 drivers/net/bnxt/bnxt_cpr.c    | 3 +++
 drivers/net/bnxt/bnxt_ethdev.c | 2 ++
 3 files changed, 6 insertions(+)
drivers/net/bnxt/bnxt.h +1 -0
index 93aac15b4..edaef7897 100644
@@ -422,6 +422,7 @@ struct bnxt {
 #define BNXT_FLAG_EXT_STATS_SUPPORTED	BIT(19)
 #define BNXT_FLAG_NEW_RM		BIT(20)
 #define BNXT_FLAG_INIT_DONE		BIT(21)
+#define BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED	BIT(22)
 #define BNXT_PF(bp)		(!((bp)->flags & BNXT_FLAG_VF))
 #define BNXT_VF(bp)		((bp)->flags & BNXT_FLAG_VF)
 #define BNXT_NPAR(bp)		((bp)->port_partition_type)
drivers/net/bnxt/bnxt_cpr.c +3 -0
index a692fbe7c..50f93bd21 100644
@@ -89,6 +89,9 @@ void bnxt_handle_async_event(struct bnxt *bp,
 			    bnxt_is_recovery_enabled(bp),
 			    bnxt_is_master_func(bp));
 
+		if (bp->flags & BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED)
+			return;
+
 		info->last_heart_beat =
 			bnxt_read_fw_status_reg(bp, BNXT_FW_HEARTBEAT_CNT_REG);
 		info->last_reset_counter =
drivers/net/bnxt/bnxt_ethdev.c +2 -0
index 0317eb888..e7b0b44c4 100644
@@ -3687,6 +3687,7 @@ void bnxt_schedule_fw_health_check(struct bnxt *bp)
 
 	rte_eal_alarm_set(US_PER_MS * polling_freq,
 			  bnxt_check_fw_health, (void *)bp);
+	bp->flags |= BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED;
 }
 
 static void bnxt_cancel_fw_health_check(struct bnxt *bp)
@@ -3695,6 +3696,7 @@ static void bnxt_cancel_fw_health_check(struct bnxt *bp)
 		return;
 
 	rte_eal_alarm_cancel(bnxt_check_fw_health, (void *)bp);
+	bp->flags &= ~BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED;
 }
 
 static bool bnxt_vf_pciid(uint16_t id)
Signature · 1 line
2.20.1 (Apple Git-117)
#46 lore raw

PATCH 12/13 net/bnxt: add support for FW reset

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

Added code to perform FW_RESET. When the driver detects error in FW, it has to initiate the recovery by resetting the cores. FW advertise the method to do a core reset, reset register offsets and values to perform reset in response of HWRM_ERROR_RECOVERY_QCFG command.

There are 2 ways to recover from the error.
1. Master function issues core resets to recover from error.
2. Master function detects chimp dead condition and notify the Kong processor about the chimp dead case through FW_RESET HWRM command. Kong Processor send an RESET_NOTIFY async event with REASON_CODE_FW_EXCEPTION_FATAL to all the PF’s/VF’s that chimp is dead and it is going to reset the chimp.

---
 drivers/net/bnxt/bnxt.h        |   1 +
 drivers/net/bnxt/bnxt_ethdev.c | 103 ++++++++++++++++++++++++++++++++-
 drivers/net/bnxt/bnxt_hwrm.c   |  26 +++++++++
 drivers/net/bnxt/bnxt_hwrm.h   |   1 +
 4 files changed, 130 insertions(+), 1 deletion(-)
drivers/net/bnxt/bnxt.h +1 -0
index edaef7897..9ea84ec2f 100644
@@ -389,6 +389,7 @@ struct bnxt_error_recovery_info {
 #define BNXT_FW_STATUS_REG_OFF(reg)	((reg) & ~BNXT_FW_STATUS_REG_TYPE_MASK)
 
 #define BNXT_GRCP_WINDOW_2_BASE		0x2000
+#define BNXT_GRCP_WINDOW_3_BASE		0x3000
 
 #define BNXT_HWRM_SHORT_REQ_LEN		sizeof(struct hwrm_short_input)
 struct bnxt {
drivers/net/bnxt/bnxt_ethdev.c +102 -1

133 lines not on this page · raw message

drivers/net/bnxt/bnxt_hwrm.c +26 -0
index 350e867bf..bd2cc01e1 100644
@@ -4782,3 +4782,29 @@ int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp)
 	}
 	return rc;
 }
+
+int bnxt_hwrm_fw_reset(struct bnxt *bp)
+{
+	struct hwrm_fw_reset_output *resp = bp->hwrm_cmd_resp_addr;
+	struct hwrm_fw_reset_input req = {0};
+	int rc;
+
+	if (!BNXT_PF(bp))
+		return -EOPNOTSUPP;
+
+	HWRM_PREP(req, FW_RESET, BNXT_USE_KONG(bp));
+
+	req.embedded_proc_type =
+		HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_CHIP;
+	req.selfrst_status =
+		HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTASAP;
+	req.flags = HWRM_FW_RESET_INPUT_FLAGS_RESET_GRACEFUL;
+
+	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req),
+				    BNXT_USE_KONG(bp));
+
+	HWRM_CHECK_RESULT();
+	HWRM_UNLOCK();
+
+	return rc;
+}
drivers/net/bnxt/bnxt_hwrm.h +1 -0
index 44e335507..db25ad591 100644
@@ -205,4 +205,5 @@ int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
 int bnxt_hwrm_set_mac(struct bnxt *bp);
 int bnxt_hwrm_if_change(struct bnxt *bp, bool state);
 int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp);
+int bnxt_hwrm_fw_reset(struct bnxt *bp);
 #endif
Signature · 1 line
2.20.1 (Apple Git-117)
#47 lore raw

PATCH 13/13 net/bnxt: reduce verbosity of logs

In reply to Ajit Khaparde

From: Kalesh AP <[email protected]>

When IOMMU is available, EAL picks IOVA as VA as the default IOVA mode. This causes the bnxt driver to log warning messages saying "Memzone physical address same as virtual." and "Using rte_mem_virt2iova()" during load.

Reduce the verbosity of logs to DEBUG.

---
 drivers/net/bnxt/bnxt_ethdev.c | 21 +++++++++------------
 drivers/net/bnxt/bnxt_ring.c   |  7 +++----
 drivers/net/bnxt/bnxt_vnic.c   |  7 +++----
 3 files changed, 15 insertions(+), 20 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +9 -12
index 095395dae..13f1ff6fb 100644
@@ -3893,10 +3893,9 @@ static int bnxt_alloc_ctx_mem_blk(__rte_unused struct bnxt *bp,
 		memset(mz->addr, 0, mz->len);
 		mz_phys_addr = mz->iova;
 		if ((unsigned long)mz->addr == mz_phys_addr) {
-			PMD_DRV_LOG(WARNING,
-				"Memzone physical address same as virtual.\n");
-			PMD_DRV_LOG(WARNING,
-				    "Using rte_mem_virt2iova()\n");
+			PMD_DRV_LOG(DEBUG,
+				    "physical address same as virtual\n");
+			PMD_DRV_LOG(DEBUG, "Using rte_mem_virt2iova()\n");
 			mz_phys_addr = rte_mem_virt2iova(mz->addr);
 			if (mz_phys_addr == RTE_BAD_IOVA) {
 				PMD_DRV_LOG(ERR,
@@ -3929,10 +3928,9 @@ static int bnxt_alloc_ctx_mem_blk(__rte_unused struct bnxt *bp,
 	memset(mz->addr, 0, mz->len);
 	mz_phys_addr = mz->iova;
 	if ((unsigned long)mz->addr == mz_phys_addr) {
-		PMD_DRV_LOG(WARNING,
+		PMD_DRV_LOG(DEBUG,
 			    "Memzone physical address same as virtual.\n");
-		PMD_DRV_LOG(WARNING,
-			    "Using rte_mem_virt2iova()\n");
+		PMD_DRV_LOG(DEBUG, "Using rte_mem_virt2iova()\n");
 		for (sz = 0; sz < mem_size; sz += BNXT_PAGE_SIZE)
 			rte_mem_lock_page(((char *)mz->addr) + sz);
 		mz_phys_addr = rte_mem_virt2iova(mz->addr);
@@ -4120,9 +4118,9 @@ static int bnxt_alloc_stats_mem(struct bnxt *bp)
 	memset(mz->addr, 0, mz->len);
 	mz_phys_addr = mz->iova;
 	if ((unsigned long)mz->addr == mz_phys_addr) {
-		PMD_DRV_LOG(WARNING,
+		PMD_DRV_LOG(DEBUG,
 			    "Memzone physical address same as virtual.\n");
-		PMD_DRV_LOG(WARNING,
+		PMD_DRV_LOG(DEBUG,
 			    "Using rte_mem_virt2iova()\n");
 		mz_phys_addr = rte_mem_virt2iova(mz->addr);
 		if (mz_phys_addr == RTE_BAD_IOVA) {
@@ -4158,10 +4156,9 @@ static int bnxt_alloc_stats_mem(struct bnxt *bp)
 	memset(mz->addr, 0, mz->len);
 	mz_phys_addr = mz->iova;
 	if ((unsigned long)mz->addr == mz_phys_addr) {
-		PMD_DRV_LOG(WARNING,
+		PMD_DRV_LOG(DEBUG,
 			    "Memzone physical address same as virtual\n");
-		PMD_DRV_LOG(WARNING,
-			    "Using rte_mem_virt2iova()\n");
+		PMD_DRV_LOG(DEBUG, "Using rte_mem_virt2iova()\n");
 		mz_phys_addr = rte_mem_virt2iova(mz->addr);
 		if (mz_phys_addr == RTE_BAD_IOVA) {
 			PMD_DRV_LOG(ERR,
drivers/net/bnxt/bnxt_ring.c +3 -4
index f19865c83..2f57e038a 100644
@@ -212,10 +212,9 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
 	mz_phys_addr_base = mz->iova;
 	mz_phys_addr = mz->iova;
 	if ((unsigned long)mz->addr == mz_phys_addr_base) {
-		PMD_DRV_LOG(WARNING,
-			"Memzone physical address same as virtual.\n");
-		PMD_DRV_LOG(WARNING,
-			"Using rte_mem_virt2iova()\n");
+		PMD_DRV_LOG(DEBUG,
+			    "Memzone physical address same as virtual.\n");
+		PMD_DRV_LOG(DEBUG, "Using rte_mem_virt2iova()\n");
 		for (sz = 0; sz < total_alloc_len; sz += getpagesize())
 			rte_mem_lock_page(((char *)mz->addr) + sz);
 		mz_phys_addr_base = rte_mem_virt2iova(mz->addr);
drivers/net/bnxt/bnxt_vnic.c +3 -4
index 98415633e..9ea99388b 100644
@@ -150,10 +150,9 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp)
 	}
 	mz_phys_addr = mz->iova;
 	if ((unsigned long)mz->addr == mz_phys_addr) {
-		PMD_DRV_LOG(WARNING,
-			"Memzone physical address same as virtual.\n");
-		PMD_DRV_LOG(WARNING,
-			"Using rte_mem_virt2iova()\n");
+		PMD_DRV_LOG(DEBUG,
+			    "Memzone physical address same as virtual.\n");
+		PMD_DRV_LOG(DEBUG, "Using rte_mem_virt2iova()\n");
 		mz_phys_addr = rte_mem_virt2iova(mz->addr);
 		if (mz_phys_addr == RTE_BAD_IOVA) {
 			PMD_DRV_LOG(ERR,
Signature · 1 line
2.20.1 (Apple Git-117)