bnxt patchset to support device error recovery
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)
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
@@ -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)
Re: [dpdk-dev] [PATCH 01/13] net/bnxt: hsi version update
Quoted 8 lines · Ajit Khaparde
From: Kalesh AP <[email protected]>
Signed-off-by Kalesh AP <[email protected]>Reviewed-by Somnath Kotur <[email protected]>Reviewed-by Ajit Khaparde <[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?
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)
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
@@ -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)
PATCH v2 2/13 net/bnxt: prevent device access when device is in reset
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)
PATCH v2 3/13 net/bnxt: handle reset notify async event from FW
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)
PATCH v2 4/13 net/bnxt: inform firmware about IF state changes
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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)
PATCH v2 5/13 net/bnxt: handle fatal event from FW under error conditions
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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)
PATCH v2 6/13 net/bnxt: query firmware error recovery capabilities
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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)
PATCH v2 7/13 net/bnxt: map status registers for FW health monitoring
In reply to Ajit KhapardeFrom: 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
@@ -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 16uint8_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
@@ -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)
PATCH v2 8/13 net/bnxt: advertise error recovery capability and handle async event
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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)
PATCH v2 9/13 net/bnxt: add code for periodic FW health monitoring
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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)
PATCH v2 10/13 net/bnxt: add support for FW reset
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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)
PATCH v2 11/13 net/bnxt: reduce verbosity of logs
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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)
PATCH v2 12/13 net/bnxt: use BIT macro instead of bit fields
In reply to Ajit KhapardeFrom: 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
@@ -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 1uint16_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
@@ -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)
PATCH v2 13/13 net/bnxt: avoid null pointer dereference
In reply to Ajit KhapardeFrom: 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.
--- drivers/net/bnxt/bnxt_ring.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt_ring.c +4 -2
@@ -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)
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
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)
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
@@ -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)
PATCH v3 2/15 net/bnxt: prevent device access when device is in reset
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)
PATCH v3 3/15 net/bnxt: handle reset notify async event from FW
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)
PATCH v3 4/15 net/bnxt: inform firmware about IF state changes
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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)
PATCH v3 5/15 net/bnxt: handle fatal event from FW under error conditions
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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)
PATCH v3 6/15 net/bnxt: query firmware error recovery capabilities
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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)
PATCH v3 7/15 net/bnxt: map status registers for FW health monitoring
In reply to Ajit KhapardeFrom: 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
@@ -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 16uint8_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
@@ -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
@@ -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)
PATCH v3 8/15 net/bnxt: advertise error recovery capability and handle async event
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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)
PATCH v3 9/15 net/bnxt: add code for periodic FW health monitoring
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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)
PATCH v3 10/15 net/bnxt: add support for FW reset
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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)
PATCH v3 11/15 net/bnxt: add hot firmware upgrade support for Stingray
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)
PATCH v3 12/15 net/bnxt: reduce verbosity of logs
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)
PATCH v3 13/15 net/bnxt: avoid null pointer dereference
In reply to Ajit KhapardeFrom: 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.
--- drivers/net/bnxt/bnxt_ring.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/bnxt/bnxt_ring.c +4 -2
@@ -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)
PATCH v3 14/15 net/bnxt: use BIT macro instead of bit fields
In reply to Ajit KhapardeFrom: 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
@@ -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 1uint16_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
@@ -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)
PATCH v3 15/15 net/bnxt: add PTP support for Thor
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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)
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 anddev_opsreturn 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.
PATCH 2/13 net/bnxt: prevent device access when device is in reset
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)
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_opscallbacks 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_devdev_startedfield is updated depending on the status of the device.Signed-off-by Kalesh AP <[email protected]>Reviewed-by Ajit Khaparde <[email protected]>Reviewed-by Somnath Kotur <[email protected]>
<...>
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)
^PATCH 3/13 net/bnxt: handle reset notify async event from FW
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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)
PATCH 4/13 net/bnxt: inform firmware about IF state changes
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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)
PATCH 5/13 net/bnxt: handle fatal event from FW under error conditions
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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)
PATCH 6/13 net/bnxt: query firmware error recovery capabilities
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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)
PATCH 7/13 net/bnxt: map status registers for FW health monitoring
In reply to Ajit KhapardeFrom: 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
@@ -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 16uint8_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
@@ -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)
PATCH 8/13 net/bnxt: advertise error recovery capability and handle async event
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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
@@ -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)
PATCH 9/13 net/bnxt: add code for periodic FW health monitoring
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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)
PATCH 10/13 net/bnxt: use BIT macro instead of bit fields
In reply to Ajit KhapardeFrom: 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
@@ -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 1uint16_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
@@ -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)
PATCH 11/13 net/bnxt: reschedule the health check alarm correctly
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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)
PATCH 12/13 net/bnxt: add support for FW reset
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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)
PATCH 13/13 net/bnxt: reduce verbosity of logs
In reply to Ajit KhapardeFrom: 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
@@ -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
@@ -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
@@ -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)