net/bnxt: enforce IO barrier for doorbell command
[dpdk.git] / drivers / net / bnxt / bnxt_hwrm.c
index a4c879b..cdb6fa4 100644 (file)
@@ -27,6 +27,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 +98,17 @@ 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 */
+       if (rte_cpu_to_le_16(req->req_type) == HWRM_VER_GET)
+               timeout = HWRM_SHORT_CMD_TIMEOUT;
+       else
+               timeout = HWRM_CMD_TIMEOUT;
 
        if (bp->flags & BNXT_FLAG_SHORT_CMD ||
            msg_len > bp->max_req_len) {
@@ -115,9 +127,6 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,
                data = (uint32_t *)&short_input;
                msg_len = sizeof(short_input);
 
-               /* Sync memory write before updating doorbell */
-               rte_wmb();
-
                max_req_len = BNXT_HWRM_SHORT_REQ_LEN;
        }
 
@@ -137,11 +146,17 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,
        /* Ring channel doorbell */
        bar = (uint8_t *)bp->bar0 + mb_trigger_offset;
        rte_write32(1, bar);
+       /*
+        * Make sure the channel doorbell ring command complete before
+        * reading the response to avoid getting stale or invalid
+        * responses.
+        */
+       rte_io_mb();
 
        /* 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();
+               rte_cio_rmb();
                if (resp->resp_len && resp->resp_len <= bp->max_resp_len) {
                        /* Last byte of resp contains the valid key */
                        valid = (uint8_t *)resp + resp->resp_len - 1;
@@ -151,15 +166,17 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg,
                rte_delay_us(1);
        }
 
-       if (i >= HWRM_CMD_TIMEOUT) {
-               PMD_DRV_LOG(ERR, "Error sending msg 0x%04x\n",
-                       req->req_type);
-               goto err_ret;
+       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;
        }
        return 0;
-
-err_ret:
-       return -1;
 }
 
 /*
@@ -492,31 +509,37 @@ static int bnxt_hwrm_ptp_qcfg(struct bnxt *bp)
 
        HWRM_CHECK_RESULT();
 
-       if (!(resp->flags & HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_DIRECT_ACCESS))
+       if (!BNXT_CHIP_THOR(bp) &&
+           !(resp->flags & HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_DIRECT_ACCESS))
                return 0;
 
+       if (resp->flags & HWRM_PORT_MAC_PTP_QCFG_OUTPUT_FLAGS_ONE_STEP_TX_TS)
+               bp->flags |= BNXT_FLAG_FW_CAP_ONE_STEP_TX_TS;
+
        ptp = rte_zmalloc("ptp_cfg", sizeof(*ptp), 0);
        if (!ptp)
                return -ENOMEM;
 
-       ptp->rx_regs[BNXT_PTP_RX_TS_L] =
-               rte_le_to_cpu_32(resp->rx_ts_reg_off_lower);
-       ptp->rx_regs[BNXT_PTP_RX_TS_H] =
-               rte_le_to_cpu_32(resp->rx_ts_reg_off_upper);
-       ptp->rx_regs[BNXT_PTP_RX_SEQ] =
-               rte_le_to_cpu_32(resp->rx_ts_reg_off_seq_id);
-       ptp->rx_regs[BNXT_PTP_RX_FIFO] =
-               rte_le_to_cpu_32(resp->rx_ts_reg_off_fifo);
-       ptp->rx_regs[BNXT_PTP_RX_FIFO_ADV] =
-               rte_le_to_cpu_32(resp->rx_ts_reg_off_fifo_adv);
-       ptp->tx_regs[BNXT_PTP_TX_TS_L] =
-               rte_le_to_cpu_32(resp->tx_ts_reg_off_lower);
-       ptp->tx_regs[BNXT_PTP_TX_TS_H] =
-               rte_le_to_cpu_32(resp->tx_ts_reg_off_upper);
-       ptp->tx_regs[BNXT_PTP_TX_SEQ] =
-               rte_le_to_cpu_32(resp->tx_ts_reg_off_seq_id);
-       ptp->tx_regs[BNXT_PTP_TX_FIFO] =
-               rte_le_to_cpu_32(resp->tx_ts_reg_off_fifo);
+       if (!BNXT_CHIP_THOR(bp)) {
+               ptp->rx_regs[BNXT_PTP_RX_TS_L] =
+                       rte_le_to_cpu_32(resp->rx_ts_reg_off_lower);
+               ptp->rx_regs[BNXT_PTP_RX_TS_H] =
+                       rte_le_to_cpu_32(resp->rx_ts_reg_off_upper);
+               ptp->rx_regs[BNXT_PTP_RX_SEQ] =
+                       rte_le_to_cpu_32(resp->rx_ts_reg_off_seq_id);
+               ptp->rx_regs[BNXT_PTP_RX_FIFO] =
+                       rte_le_to_cpu_32(resp->rx_ts_reg_off_fifo);
+               ptp->rx_regs[BNXT_PTP_RX_FIFO_ADV] =
+                       rte_le_to_cpu_32(resp->rx_ts_reg_off_fifo_adv);
+               ptp->tx_regs[BNXT_PTP_TX_TS_L] =
+                       rte_le_to_cpu_32(resp->tx_ts_reg_off_lower);
+               ptp->tx_regs[BNXT_PTP_TX_TS_H] =
+                       rte_le_to_cpu_32(resp->tx_ts_reg_off_upper);
+               ptp->tx_regs[BNXT_PTP_TX_SEQ] =
+                       rte_le_to_cpu_32(resp->tx_ts_reg_off_seq_id);
+               ptp->tx_regs[BNXT_PTP_TX_FIFO] =
+                       rte_le_to_cpu_32(resp->tx_ts_reg_off_fifo);
+       }
 
        ptp->bp = bp;
        bp->ptp_cfg = ptp;
@@ -589,7 +612,10 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
        bp->max_cp_rings = rte_le_to_cpu_16(resp->max_cmpl_rings);
        bp->max_tx_rings = rte_le_to_cpu_16(resp->max_tx_rings);
        bp->max_rx_rings = rte_le_to_cpu_16(resp->max_rx_rings);
-       bp->max_l2_ctx = rte_le_to_cpu_16(resp->max_l2_ctxs);
+       bp->first_vf_id = rte_le_to_cpu_16(resp->first_vf_id);
+       bp->max_rx_em_flows = rte_le_to_cpu_16(resp->max_rx_em_flows);
+       bp->max_l2_ctx =
+               rte_le_to_cpu_16(resp->max_l2_ctxs) + bp->max_rx_em_flows;
        /* TODO: For now, do not support VMDq/RFS on VFs. */
        if (BNXT_PF(bp)) {
                if (bp->pf.max_vfs)
@@ -610,6 +636,21 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
                }
        }
 
+       if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_EXT_STATS_SUPPORTED)
+               bp->flags |= BNXT_FLAG_EXT_STATS_SUPPORTED;
+
+       if (flags & HWRM_FUNC_QCAPS_OUTPUT_FLAGS_ERROR_RECOVERY_CAPABLE) {
+               bp->flags |= BNXT_FLAG_FW_CAP_ERROR_RECOVERY;
+               PMD_DRV_LOG(DEBUG, "Adapter Error recovery SUPPORTED\n");
+       } else {
+               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;
@@ -654,12 +695,23 @@ 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;
+       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
+        */
+       if ((BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp)) && !BNXT_STINGRAY(bp))
+               flags |= HWRM_FUNC_DRV_RGTR_INPUT_FLAGS_MASTER_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);
@@ -680,14 +732,19 @@ 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);
+       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);
@@ -695,6 +752,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;
@@ -734,9 +796,12 @@ int bnxt_hwrm_func_reserve_vf_resc(struct bnxt *bp, bool test)
        req.num_tx_rings = rte_cpu_to_le_16(bp->tx_nr_rings);
        req.num_rx_rings = rte_cpu_to_le_16(bp->rx_nr_rings *
                                            AGG_RING_MULTIPLIER);
-       req.num_stat_ctxs = rte_cpu_to_le_16(bp->rx_nr_rings + bp->tx_nr_rings);
+       req.num_stat_ctxs = rte_cpu_to_le_16(bp->rx_nr_rings +
+                                            bp->tx_nr_rings +
+                                            BNXT_NUM_ASYNC_CPR(bp));
        req.num_cmpl_rings = rte_cpu_to_le_16(bp->rx_nr_rings +
-                                             bp->tx_nr_rings);
+                                             bp->tx_nr_rings +
+                                             BNXT_NUM_ASYNC_CPR(bp));
        req.num_vnics = rte_cpu_to_le_16(bp->rx_nr_rings);
        if (bp->vf_resv_strategy ==
            HWRM_FUNC_RESOURCE_QCAPS_OUTPUT_VF_RESV_STRATEGY_MINIMAL_STATIC) {
@@ -792,7 +857,12 @@ int bnxt_hwrm_func_resc_qcaps(struct bnxt *bp)
                bp->max_tx_rings = rte_le_to_cpu_16(resp->max_tx_rings);
                bp->max_rx_rings = rte_le_to_cpu_16(resp->max_rx_rings);
                bp->max_ring_grps = rte_le_to_cpu_32(resp->max_hw_ring_grps);
-               bp->max_l2_ctx = rte_le_to_cpu_16(resp->max_l2_ctxs);
+               /* func_resource_qcaps does not return max_rx_em_flows.
+                * So use the value provided by func_qcaps.
+                */
+               bp->max_l2_ctx =
+                       rte_le_to_cpu_16(resp->max_l2_ctxs) +
+                       bp->max_rx_em_flows;
                bp->max_vnics = rte_le_to_cpu_16(resp->max_vnics);
                bp->max_stat_ctx = rte_le_to_cpu_16(resp->max_stat_ctx);
        }
@@ -826,7 +896,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,
@@ -877,7 +950,7 @@ int bnxt_hwrm_ver_get(struct bnxt *bp)
                rte_mem_lock_page(bp->hwrm_cmd_resp_addr);
                bp->hwrm_cmd_resp_dma_addr =
                        rte_mem_virt2iova(bp->hwrm_cmd_resp_addr);
-               if (bp->hwrm_cmd_resp_dma_addr == 0) {
+               if (bp->hwrm_cmd_resp_dma_addr == RTE_BAD_IOVA) {
                        PMD_DRV_LOG(ERR,
                        "Unable to map response buffer to physical memory.\n");
                        rc = -ENOMEM;
@@ -914,7 +987,7 @@ int bnxt_hwrm_ver_get(struct bnxt *bp)
                rte_mem_lock_page(bp->hwrm_short_cmd_req_addr);
                bp->hwrm_short_cmd_req_dma_addr =
                        rte_mem_virt2iova(bp->hwrm_short_cmd_req_addr);
-               if (bp->hwrm_short_cmd_req_dma_addr == 0) {
+               if (bp->hwrm_short_cmd_req_dma_addr == RTE_BAD_IOVA) {
                        rte_free(bp->hwrm_short_cmd_req_addr);
                        PMD_DRV_LOG(ERR,
                                "Unable to map buffer to physical memory.\n");
@@ -953,8 +1026,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;
 }
 
@@ -1206,7 +1277,7 @@ int bnxt_hwrm_ring_alloc(struct bnxt *bp,
                PMD_DRV_LOG(ERR, "hwrm alloc invalid ring type %d\n",
                        ring_type);
                HWRM_UNLOCK();
-               return -1;
+               return -EINVAL;
        }
        req.enables = rte_cpu_to_le_32(enables);
 
@@ -1486,6 +1557,11 @@ static int bnxt_hwrm_vnic_plcmodes_cfg(struct bnxt *bp,
        struct hwrm_vnic_plcmodes_cfg_input req = {.req_type = 0 };
        struct hwrm_vnic_plcmodes_cfg_output *resp = bp->hwrm_cmd_resp_addr;
 
+       if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
+               PMD_DRV_LOG(DEBUG, "VNIC ID %x\n", vnic->fw_vnic_id);
+               return rc;
+       }
+
        HWRM_PREP(req, VNIC_PLCMODES_CFG, BNXT_USE_CHIMP_MB);
 
        req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
@@ -1512,8 +1588,8 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic)
        int rc = 0;
        struct hwrm_vnic_cfg_input req = {.req_type = 0 };
        struct hwrm_vnic_cfg_output *resp = bp->hwrm_cmd_resp_addr;
+       struct bnxt_plcmodes_cfg pmodes = { 0 };
        uint32_t ctx_enable_flag = 0;
-       struct bnxt_plcmodes_cfg pmodes;
        uint32_t enables = 0;
 
        if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
@@ -1530,7 +1606,7 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic)
        if (BNXT_CHIP_THOR(bp)) {
                struct bnxt_rx_queue *rxq = bp->eth_dev->data->rx_queues[0];
                struct bnxt_rx_ring_info *rxr = rxq->rx_ring;
-               struct bnxt_cp_ring_info *cpr = bp->def_cp_ring;
+               struct bnxt_cp_ring_info *cpr = rxq->cp_ring;
 
                req.default_rx_ring_id =
                        rte_cpu_to_le_16(rxr->rx_ring_struct->fw_ring_id);
@@ -1720,23 +1796,20 @@ bnxt_hwrm_vnic_rss_cfg_thor(struct bnxt *bp, struct bnxt_vnic_info *vnic)
 {
        int i;
        int rc = 0;
-       int nr_ctxs = bp->max_ring_grps;
+       int nr_ctxs = vnic->num_lb_ctxts;
        struct hwrm_vnic_rss_cfg_input req = {.req_type = 0 };
        struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr;
 
-       if (!(vnic->rss_table && vnic->hash_type))
-               return 0;
-
-       HWRM_PREP(req, VNIC_RSS_CFG, BNXT_USE_CHIMP_MB);
+       for (i = 0; i < nr_ctxs; i++) {
+               HWRM_PREP(req, VNIC_RSS_CFG, BNXT_USE_CHIMP_MB);
 
-       req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
-       req.hash_type = rte_cpu_to_le_32(vnic->hash_type);
-       req.hash_mode_flags = vnic->hash_mode;
+               req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
+               req.hash_type = rte_cpu_to_le_32(vnic->hash_type);
+               req.hash_mode_flags = vnic->hash_mode;
 
-       req.hash_key_tbl_addr =
-           rte_cpu_to_le_64(vnic->rss_hash_key_dma_addr);
+               req.hash_key_tbl_addr =
+                       rte_cpu_to_le_64(vnic->rss_hash_key_dma_addr);
 
-       for (i = 0; i < nr_ctxs; i++) {
                req.ring_grp_tbl_addr =
                        rte_cpu_to_le_64(vnic->rss_table_dma_addr +
                                         i * HW_HASH_INDEX_SIZE);
@@ -1747,12 +1820,9 @@ bnxt_hwrm_vnic_rss_cfg_thor(struct bnxt *bp, struct bnxt_vnic_info *vnic)
                                            BNXT_USE_CHIMP_MB);
 
                HWRM_CHECK_RESULT();
-               if (rc)
-                       break;
+               HWRM_UNLOCK();
        }
 
-       HWRM_UNLOCK();
-
        return rc;
 }
 
@@ -1763,6 +1833,9 @@ int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp,
        struct hwrm_vnic_rss_cfg_input req = {.req_type = 0 };
        struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr;
 
+       if (!vnic->rss_table)
+               return 0;
+
        if (BNXT_CHIP_THOR(bp))
                return bnxt_hwrm_vnic_rss_cfg_thor(bp, vnic);
 
@@ -2003,7 +2076,8 @@ int bnxt_free_all_hwrm_stat_ctxs(struct bnxt *bp)
                        cpr = bp->tx_queues[i - bp->rx_cp_nr_rings]->cp_ring;
                } else {
                        cpr = bp->rx_queues[i]->cp_ring;
-                       bp->grp_info[i].fw_stats_ctx = -1;
+                       if (BNXT_HAS_RING_GRPS(bp))
+                               bp->grp_info[i].fw_stats_ctx = -1;
                }
                if (cpr->hw_stats_ctx_id != HWRM_NA_SIGNATURE) {
                        rc = bnxt_hwrm_stat_ctx_free(bp, cpr, i);
@@ -2062,7 +2136,7 @@ int bnxt_free_all_hwrm_ring_grps(struct bnxt *bp)
        return rc;
 }
 
-static void bnxt_free_nq_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
+void bnxt_free_nq_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
 {
        struct bnxt_ring *cp_ring = cpr->cp_ring_struct;
 
@@ -2072,9 +2146,10 @@ static void bnxt_free_nq_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
        memset(cpr->cp_desc_ring, 0, cpr->cp_ring_struct->ring_size *
                                     sizeof(*cpr->cp_desc_ring));
        cpr->cp_raw_cons = 0;
+       cpr->valid = 0;
 }
 
-static void bnxt_free_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
+void bnxt_free_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
 {
        struct bnxt_ring *cp_ring = cpr->cp_ring_struct;
 
@@ -2084,6 +2159,7 @@ static void bnxt_free_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr)
        memset(cpr->cp_desc_ring, 0, cpr->cp_ring_struct->ring_size *
                        sizeof(*cpr->cp_desc_ring));
        cpr->cp_raw_cons = 0;
+       cpr->valid = 0;
 }
 
 void bnxt_free_hwrm_rx_ring(struct bnxt *bp, int queue_index)
@@ -2097,7 +2173,9 @@ void bnxt_free_hwrm_rx_ring(struct bnxt *bp, int queue_index)
                bnxt_hwrm_ring_free(bp, ring,
                                    HWRM_RING_FREE_INPUT_RING_TYPE_RX);
                ring->fw_ring_id = INVALID_HW_RING_ID;
-               bp->grp_info[queue_index].rx_fw_ring_id = INVALID_HW_RING_ID;
+               if (BNXT_HAS_RING_GRPS(bp))
+                       bp->grp_info[queue_index].rx_fw_ring_id =
+                                                       INVALID_HW_RING_ID;
                memset(rxr->rx_desc_ring, 0,
                       rxr->rx_ring_struct->ring_size *
                       sizeof(*rxr->rx_desc_ring));
@@ -2117,7 +2195,9 @@ void bnxt_free_hwrm_rx_ring(struct bnxt *bp, int queue_index)
                       rxr->ag_ring_struct->ring_size *
                       sizeof(*rxr->ag_buf_ring));
                rxr->ag_prod = 0;
-               bp->grp_info[queue_index].ag_fw_ring_id = INVALID_HW_RING_ID;
+               if (BNXT_HAS_RING_GRPS(bp))
+                       bp->grp_info[queue_index].ag_fw_ring_id =
+                                                       INVALID_HW_RING_ID;
        }
        if (cpr->cp_ring_struct->fw_ring_id != INVALID_HW_RING_ID) {
                bnxt_free_cp_ring(bp, cpr);
@@ -2125,7 +2205,8 @@ void bnxt_free_hwrm_rx_ring(struct bnxt *bp, int queue_index)
                        bnxt_free_nq_ring(bp, rxq->nq_ring);
        }
 
-       bp->grp_info[queue_index].cp_fw_ring_id = INVALID_HW_RING_ID;
+       if (BNXT_HAS_RING_GRPS(bp))
+               bp->grp_info[queue_index].cp_fw_ring_id = INVALID_HW_RING_ID;
 }
 
 int bnxt_free_all_hwrm_rings(struct bnxt *bp)
@@ -2206,7 +2287,7 @@ int bnxt_alloc_hwrm_resources(struct bnxt *bp)
                return -ENOMEM;
        bp->hwrm_cmd_resp_dma_addr =
                rte_mem_virt2iova(bp->hwrm_cmd_resp_addr);
-       if (bp->hwrm_cmd_resp_dma_addr == 0) {
+       if (bp->hwrm_cmd_resp_dma_addr == RTE_BAD_IOVA) {
                PMD_DRV_LOG(ERR,
                        "unable to map response address to physical memory\n");
                return -ENOMEM;
@@ -2244,7 +2325,7 @@ bnxt_clear_hwrm_vnic_flows(struct bnxt *bp, struct bnxt_vnic_info *vnic)
 
        STAILQ_FOREACH(flow, &vnic->flow_list, next) {
                filter = flow->filter;
-               PMD_DRV_LOG(ERR, "filter type %d\n", filter->filter_type);
+               PMD_DRV_LOG(DEBUG, "filter type %d\n", filter->filter_type);
                if (filter->filter_type == HWRM_CFA_EM_FILTER)
                        rc = bnxt_hwrm_clear_em_filter(bp, filter);
                else if (filter->filter_type == HWRM_CFA_NTUPLE_FILTER)
@@ -2307,16 +2388,22 @@ void bnxt_free_all_hwrm_resources(struct bnxt *bp)
        for (i = bp->nr_vnics - 1; i >= 0; i--) {
                struct bnxt_vnic_info *vnic = &bp->vnic_info[i];
 
+               if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
+                       PMD_DRV_LOG(DEBUG, "Invalid vNIC ID\n");
+                       return;
+               }
+
                bnxt_clear_hwrm_vnic_flows(bp, vnic);
 
                bnxt_clear_hwrm_vnic_filters(bp, vnic);
 
-               if (!BNXT_CHIP_THOR(bp)) {
+               if (BNXT_CHIP_THOR(bp)) {
                        for (j = 0; j < vnic->num_lb_ctxts; j++) {
                                bnxt_hwrm_vnic_ctx_free(bp, vnic,
                                                        vnic->fw_grp_ids[j]);
                                vnic->fw_grp_ids[j] = INVALID_HW_RING_ID;
                        }
+                       vnic->num_lb_ctxts = 0;
                } else {
                        bnxt_hwrm_vnic_ctx_free(bp, vnic, vnic->rss_rule);
                        vnic->rss_rule = INVALID_HW_RING_ID;
@@ -2637,7 +2724,7 @@ error:
 }
 
 /* JIRA 22088 */
-int bnxt_hwrm_func_qcfg(struct bnxt *bp)
+int bnxt_hwrm_func_qcfg(struct bnxt *bp, uint16_t *mtu)
 {
        struct hwrm_func_qcfg_input req = {0};
        struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
@@ -2660,8 +2747,15 @@ int bnxt_hwrm_func_qcfg(struct bnxt *bp)
        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)
+               *mtu = resp->mtu;
+
        switch (resp->port_partition_type) {
        case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_0:
        case HWRM_FUNC_QCFG_OUTPUT_PORT_PARTITION_TYPE_NPAR1_5:
@@ -2858,14 +2952,7 @@ int bnxt_hwrm_func_qcfg_current_vf_vlan(struct bnxt *bp, int vf)
        HWRM_PREP(req, FUNC_QCFG, BNXT_USE_CHIMP_MB);
        req.fid = rte_cpu_to_le_16(bp->pf.vf_info[vf].fid);
        rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
-       if (rc) {
-               PMD_DRV_LOG(ERR, "hwrm_func_qcfg failed rc:%d\n", rc);
-               return -1;
-       } else if (resp->error_code) {
-               rc = rte_le_to_cpu_16(resp->error_code);
-               PMD_DRV_LOG(ERR, "hwrm_func_qcfg error %d\n", rc);
-               return -1;
-       }
+       HWRM_CHECK_RESULT();
        rc = rte_le_to_cpu_16(resp->vlan);
 
        HWRM_UNLOCK();
@@ -2900,7 +2987,7 @@ int bnxt_hwrm_allocate_pf_only(struct bnxt *bp)
 
        if (!BNXT_PF(bp)) {
                PMD_DRV_LOG(ERR, "Attempt to allcoate VFs on a VF!\n");
-               return -1;
+               return -EINVAL;
        }
 
        rc = bnxt_hwrm_func_qcaps(bp);
@@ -2928,7 +3015,7 @@ int bnxt_hwrm_allocate_vfs(struct bnxt *bp, int num_vfs)
 
        if (!BNXT_PF(bp)) {
                PMD_DRV_LOG(ERR, "Attempt to allcoate VFs on a VF!\n");
-               return -1;
+               return -EINVAL;
        }
 
        rc = bnxt_hwrm_func_qcaps(bp);
@@ -3147,7 +3234,7 @@ int bnxt_hwrm_func_buf_rgtr(struct bnxt *bp)
        req.req_buf_len = rte_cpu_to_le_16(HWRM_MAX_REQ_LEN);
        req.req_buf_page_addr0 =
                rte_cpu_to_le_64(rte_mem_virt2iova(bp->pf.vf_req_buf));
-       if (req.req_buf_page_addr0 == 0) {
+       if (req.req_buf_page_addr0 == RTE_BAD_IOVA) {
                PMD_DRV_LOG(ERR,
                        "unable to map buffer address to physical memory\n");
                return -ENOMEM;
@@ -3167,6 +3254,9 @@ int bnxt_hwrm_func_buf_unrgtr(struct bnxt *bp)
        struct hwrm_func_buf_unrgtr_input req = {.req_type = 0 };
        struct hwrm_func_buf_unrgtr_output *resp = bp->hwrm_cmd_resp_addr;
 
+       if (!(BNXT_PF(bp) && bp->pdev->max_vfs))
+               return 0;
+
        HWRM_PREP(req, FUNC_BUF_UNRGTR, BNXT_USE_CHIMP_MB);
 
        rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
@@ -3190,7 +3280,7 @@ int bnxt_hwrm_func_cfg_def_cp(struct bnxt *bp)
        req.enables = rte_cpu_to_le_32(
                        HWRM_FUNC_CFG_INPUT_ENABLES_ASYNC_EVENT_CR);
        req.async_event_cr = rte_cpu_to_le_16(
-                       bp->def_cp_ring->cp_ring_struct->fw_ring_id);
+                       bp->async_cp_ring->cp_ring_struct->fw_ring_id);
        rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
 
        HWRM_CHECK_RESULT();
@@ -3210,7 +3300,7 @@ int bnxt_hwrm_vf_func_cfg_def_cp(struct bnxt *bp)
        req.enables = rte_cpu_to_le_32(
                        HWRM_FUNC_VF_CFG_INPUT_ENABLES_ASYNC_EVENT_CR);
        req.async_event_cr = rte_cpu_to_le_16(
-                       bp->def_cp_ring->cp_ring_struct->fw_ring_id);
+                       bp->async_cp_ring->cp_ring_struct->fw_ring_id);
        rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
 
        HWRM_CHECK_RESULT();
@@ -3544,12 +3634,11 @@ int bnxt_hwrm_nvm_get_dir_info(struct bnxt *bp, uint32_t *entries,
        rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
 
        HWRM_CHECK_RESULT();
-       HWRM_UNLOCK();
 
-       if (!rc) {
-               *entries = rte_le_to_cpu_32(resp->entries);
-               *length = rte_le_to_cpu_32(resp->entry_length);
-       }
+       *entries = rte_le_to_cpu_32(resp->entries);
+       *length = rte_le_to_cpu_32(resp->entry_length);
+
+       HWRM_UNLOCK();
        return rc;
 }
 
@@ -3579,7 +3668,7 @@ int bnxt_get_nvram_directory(struct bnxt *bp, uint32_t len, uint8_t *data)
        if (buf == NULL)
                return -ENOMEM;
        dma_handle = rte_mem_virt2iova(buf);
-       if (dma_handle == 0) {
+       if (dma_handle == RTE_BAD_IOVA) {
                PMD_DRV_LOG(ERR,
                        "unable to map response address to physical memory\n");
                return -ENOMEM;
@@ -3614,7 +3703,7 @@ int bnxt_hwrm_get_nvram_item(struct bnxt *bp, uint32_t index,
                return -ENOMEM;
 
        dma_handle = rte_mem_virt2iova(buf);
-       if (dma_handle == 0) {
+       if (dma_handle == RTE_BAD_IOVA) {
                PMD_DRV_LOG(ERR,
                        "unable to map response address to physical memory\n");
                return -ENOMEM;
@@ -3668,7 +3757,7 @@ int bnxt_hwrm_flash_nvram(struct bnxt *bp, uint16_t dir_type,
                return -ENOMEM;
 
        dma_handle = rte_mem_virt2iova(buf);
-       if (dma_handle == 0) {
+       if (dma_handle == RTE_BAD_IOVA) {
                PMD_DRV_LOG(ERR,
                        "unable to map response address to physical memory\n");
                return -ENOMEM;
@@ -3732,23 +3821,14 @@ static int bnxt_hwrm_func_vf_vnic_query(struct bnxt *bp, uint16_t vf,
        req.max_vnic_id_cnt = rte_cpu_to_le_32(bp->pf.total_vnics);
        req.vnic_id_tbl_addr = rte_cpu_to_le_64(rte_mem_virt2iova(vnic_ids));
 
-       if (req.vnic_id_tbl_addr == 0) {
+       if (req.vnic_id_tbl_addr == RTE_BAD_IOVA) {
                HWRM_UNLOCK();
                PMD_DRV_LOG(ERR,
                "unable to map VNIC ID table address to physical memory\n");
                return -ENOMEM;
        }
        rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
-       if (rc) {
-               HWRM_UNLOCK();
-               PMD_DRV_LOG(ERR, "hwrm_func_vf_vnic_query failed rc:%d\n", rc);
-               return -1;
-       } else if (resp->error_code) {
-               rc = rte_le_to_cpu_16(resp->error_code);
-               HWRM_UNLOCK();
-               PMD_DRV_LOG(ERR, "hwrm_func_vf_vnic_query error %d\n", rc);
-               return -1;
-       }
+       HWRM_CHECK_RESULT();
        rc = rte_le_to_cpu_32(resp->vnic_id_cnt);
 
        HWRM_UNLOCK();
@@ -3776,10 +3856,9 @@ int bnxt_hwrm_func_vf_vnic_query_and_config(struct bnxt *bp, uint16_t vf,
        vnic_id_sz = bp->pf.total_vnics * sizeof(*vnic_ids);
        vnic_ids = rte_malloc("bnxt_hwrm_vf_vnic_ids_query", vnic_id_sz,
                        RTE_CACHE_LINE_SIZE);
-       if (vnic_ids == NULL) {
-               rc = -ENOMEM;
-               return rc;
-       }
+       if (vnic_ids == NULL)
+               return -ENOMEM;
+
        for (sz = 0; sz < vnic_id_sz; sz += getpagesize())
                rte_mem_lock_page(((char *)vnic_ids) + sz);
 
@@ -3846,10 +3925,8 @@ int bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(struct bnxt *bp, int vf)
        vnic_id_sz = bp->pf.total_vnics * sizeof(*vnic_ids);
        vnic_ids = rte_malloc("bnxt_hwrm_vf_vnic_ids_query", vnic_id_sz,
                        RTE_CACHE_LINE_SIZE);
-       if (vnic_ids == NULL) {
-               rc = -ENOMEM;
-               return rc;
-       }
+       if (vnic_ids == NULL)
+               return -ENOMEM;
 
        for (sz = 0; sz < vnic_id_sz; sz += getpagesize())
                rte_mem_lock_page(((char *)vnic_ids) + sz);
@@ -3880,7 +3957,7 @@ int bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(struct bnxt *bp, int vf)
        PMD_DRV_LOG(ERR, "No default VNIC\n");
 exit:
        rte_free(vnic_ids);
-       return -1;
+       return rc;
 }
 
 int bnxt_hwrm_set_em_filter(struct bnxt *bp,
@@ -4100,28 +4177,30 @@ bnxt_vnic_rss_configure_thor(struct bnxt *bp, struct bnxt_vnic_info *vnic)
        struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr;
        uint8_t *rx_queue_state = bp->eth_dev->data->rx_queue_state;
        struct hwrm_vnic_rss_cfg_input req = {.req_type = 0 };
-       int nr_ctxs = bp->max_ring_grps;
        struct bnxt_rx_queue **rxqs = bp->rx_queues;
        uint16_t *ring_tbl = vnic->rss_table;
+       int nr_ctxs = vnic->num_lb_ctxts;
        int max_rings = bp->rx_nr_rings;
        int i, j, k, cnt;
        int rc = 0;
 
-       HWRM_PREP(req, VNIC_RSS_CFG, BNXT_USE_CHIMP_MB);
-
-       req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
-       req.hash_type = rte_cpu_to_le_32(vnic->hash_type);
-       req.hash_mode_flags = vnic->hash_mode;
-
-       req.ring_grp_tbl_addr =
-           rte_cpu_to_le_64(vnic->rss_table_dma_addr);
-       req.hash_key_tbl_addr =
-           rte_cpu_to_le_64(vnic->rss_hash_key_dma_addr);
-
        for (i = 0, k = 0; i < nr_ctxs; i++) {
                struct bnxt_rx_ring_info *rxr;
                struct bnxt_cp_ring_info *cpr;
 
+               HWRM_PREP(req, VNIC_RSS_CFG, BNXT_USE_CHIMP_MB);
+
+               req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);
+               req.hash_type = rte_cpu_to_le_32(vnic->hash_type);
+               req.hash_mode_flags = vnic->hash_mode;
+
+               req.ring_grp_tbl_addr =
+                   rte_cpu_to_le_64(vnic->rss_table_dma_addr +
+                                    i * BNXT_RSS_ENTRIES_PER_CTX_THOR *
+                                    2 * sizeof(*ring_tbl));
+               req.hash_key_tbl_addr =
+                   rte_cpu_to_le_64(vnic->rss_hash_key_dma_addr);
+
                req.ring_table_pair_index = i;
                req.rss_ctx_idx = rte_cpu_to_le_16(vnic->fw_grp_ids[i]);
 
@@ -4157,12 +4236,9 @@ bnxt_vnic_rss_configure_thor(struct bnxt *bp, struct bnxt_vnic_info *vnic)
                                            BNXT_USE_CHIMP_MB);
 
                HWRM_CHECK_RESULT();
-               if (rc)
-                       break;
+               HWRM_UNLOCK();
        }
 
-       HWRM_UNLOCK();
-
        return rc;
 }
 
@@ -4236,8 +4312,7 @@ static int bnxt_hwrm_set_coal_params_thor(struct bnxt *bp,
 
        HWRM_PREP(req, RING_AGGINT_QCAPS, BNXT_USE_CHIMP_MB);
        rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
-       if (rc)
-               goto out;
+       HWRM_CHECK_RESULT();
 
        agg_req->num_cmpl_dma_aggr = resp->num_cmpl_dma_aggr_max;
        agg_req->cmpl_aggr_dma_tmr = resp->cmpl_aggr_dma_tmr_min;
@@ -4250,8 +4325,6 @@ static int bnxt_hwrm_set_coal_params_thor(struct bnxt *bp,
         HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS_INPUT_ENABLES_NUM_CMPL_DMA_AGGR;
        agg_req->enables = rte_cpu_to_le_32(enables);
 
-out:
-       HWRM_CHECK_RESULT();
        HWRM_UNLOCK();
        return rc;
 }
@@ -4463,8 +4536,7 @@ int bnxt_hwrm_func_backing_store_cfg(struct bnxt *bp, uint32_t enables)
        rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
        HWRM_CHECK_RESULT();
        HWRM_UNLOCK();
-       if (rc)
-               rc = -EIO;
+
        return rc;
 }
 
@@ -4484,13 +4556,13 @@ int bnxt_hwrm_ext_port_qstats(struct bnxt *bp)
        req.port_id = rte_cpu_to_le_16(pf->port_id);
        if (bp->flags & BNXT_FLAG_EXT_TX_PORT_STATS) {
                req.tx_stat_host_addr =
-                       rte_cpu_to_le_64(bp->hw_tx_port_stats_map);
+                       rte_cpu_to_le_64(bp->hw_tx_port_stats_ext_map);
                req.tx_stat_size =
                        rte_cpu_to_le_16(sizeof(struct tx_port_stats_ext));
        }
        if (bp->flags & BNXT_FLAG_EXT_RX_PORT_STATS) {
                req.rx_stat_host_addr =
-                       rte_cpu_to_le_64(bp->hw_rx_port_stats_map);
+                       rte_cpu_to_le_64(bp->hw_rx_port_stats_ext_map);
                req.rx_stat_size =
                        rte_cpu_to_le_16(sizeof(struct rx_port_stats_ext));
        }
@@ -4511,3 +4583,305 @@ int bnxt_hwrm_ext_port_qstats(struct bnxt *bp)
 
        return rc;
 }
+
+int
+bnxt_hwrm_tunnel_redirect(struct bnxt *bp, uint8_t type)
+{
+       struct hwrm_cfa_redirect_tunnel_type_alloc_input req = {0};
+       struct hwrm_cfa_redirect_tunnel_type_alloc_output *resp =
+               bp->hwrm_cmd_resp_addr;
+       int rc = 0;
+
+       HWRM_PREP(req, CFA_REDIRECT_TUNNEL_TYPE_ALLOC, BNXT_USE_CHIMP_MB);
+       req.tunnel_type = type;
+       req.dest_fid = bp->fw_fid;
+       rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+       HWRM_CHECK_RESULT();
+
+       HWRM_UNLOCK();
+
+       return rc;
+}
+
+int
+bnxt_hwrm_tunnel_redirect_free(struct bnxt *bp, uint8_t type)
+{
+       struct hwrm_cfa_redirect_tunnel_type_free_input req = {0};
+       struct hwrm_cfa_redirect_tunnel_type_free_output *resp =
+               bp->hwrm_cmd_resp_addr;
+       int rc = 0;
+
+       HWRM_PREP(req, CFA_REDIRECT_TUNNEL_TYPE_FREE, BNXT_USE_CHIMP_MB);
+       req.tunnel_type = type;
+       req.dest_fid = bp->fw_fid;
+       rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+       HWRM_CHECK_RESULT();
+
+       HWRM_UNLOCK();
+
+       return rc;
+}
+
+int bnxt_hwrm_tunnel_redirect_query(struct bnxt *bp, uint32_t *type)
+{
+       struct hwrm_cfa_redirect_query_tunnel_type_input req = {0};
+       struct hwrm_cfa_redirect_query_tunnel_type_output *resp =
+               bp->hwrm_cmd_resp_addr;
+       int rc = 0;
+
+       HWRM_PREP(req, CFA_REDIRECT_QUERY_TUNNEL_TYPE, BNXT_USE_CHIMP_MB);
+       req.src_fid = bp->fw_fid;
+       rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+       HWRM_CHECK_RESULT();
+
+       if (type)
+               *type = rte_le_to_cpu_32(resp->tunnel_mask);
+
+       HWRM_UNLOCK();
+
+       return rc;
+}
+
+int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
+                                  uint16_t *dst_fid)
+{
+       struct hwrm_cfa_redirect_tunnel_type_info_input req = {0};
+       struct hwrm_cfa_redirect_tunnel_type_info_output *resp =
+               bp->hwrm_cmd_resp_addr;
+       int rc = 0;
+
+       HWRM_PREP(req, CFA_REDIRECT_TUNNEL_TYPE_INFO, BNXT_USE_CHIMP_MB);
+       req.src_fid = bp->fw_fid;
+       req.tunnel_type = tun_type;
+       rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+       HWRM_CHECK_RESULT();
+
+       if (dst_fid)
+               *dst_fid = rte_le_to_cpu_16(resp->dest_fid);
+
+       PMD_DRV_LOG(DEBUG, "dst_fid: %x\n", resp->dest_fid);
+
+       HWRM_UNLOCK();
+
+       return rc;
+}
+
+int bnxt_hwrm_set_mac(struct bnxt *bp)
+{
+       struct hwrm_func_vf_cfg_output *resp = bp->hwrm_cmd_resp_addr;
+       struct hwrm_func_vf_cfg_input req = {0};
+       int rc = 0;
+
+       if (!BNXT_VF(bp))
+               return 0;
+
+       HWRM_PREP(req, FUNC_VF_CFG, BNXT_USE_CHIMP_MB);
+
+       req.enables =
+               rte_cpu_to_le_32(HWRM_FUNC_VF_CFG_INPUT_ENABLES_DFLT_MAC_ADDR);
+       memcpy(req.dflt_mac_addr, bp->mac_addr, RTE_ETHER_ADDR_LEN);
+
+       rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+
+       HWRM_CHECK_RESULT();
+
+       memcpy(bp->dflt_mac_addr, bp->mac_addr, RTE_ETHER_ADDR_LEN);
+       HWRM_UNLOCK();
+
+       return rc;
+}
+
+int bnxt_hwrm_if_change(struct bnxt *bp, bool up)
+{
+       struct hwrm_func_drv_if_change_output *resp = bp->hwrm_cmd_resp_addr;
+       struct hwrm_func_drv_if_change_input req = {0};
+       uint32_t flags;
+       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 (!up && (bp->flags & BNXT_FLAG_FW_RESET))
+               return 0;
+
+       HWRM_PREP(req, FUNC_DRV_IF_CHANGE, BNXT_USE_CHIMP_MB);
+
+       if (up)
+               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();
+       flags = rte_le_to_cpu_32(resp->flags);
+       HWRM_UNLOCK();
+
+       if (flags & HWRM_FUNC_DRV_IF_CHANGE_OUTPUT_FLAGS_HOT_FW_RESET_DONE) {
+               PMD_DRV_LOG(INFO, "FW reset happened while port was down\n");
+               bp->flags |= BNXT_FLAG_IF_CHANGE_HOT_FW_RESET_DONE;
+       }
+
+       return 0;
+}
+
+int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp)
+{
+       struct hwrm_error_recovery_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
+       struct bnxt_error_recovery_info *info = bp->recovery_info;
+       struct hwrm_error_recovery_qcfg_input req = {0};
+       uint32_t flags = 0;
+       unsigned int i;
+       int rc;
+
+       /* Older FW does not have error recovery support */
+       if (!(bp->flags & BNXT_FLAG_FW_CAP_ERROR_RECOVERY))
+               return 0;
+
+       if (!info) {
+               info = rte_zmalloc("bnxt_hwrm_error_recovery_qcfg",
+                                  sizeof(*info), 0);
+               bp->recovery_info = info;
+               if (info == NULL)
+                       return -ENOMEM;
+       } else {
+               memset(info, 0, sizeof(*info));
+       }
+
+       HWRM_PREP(req, ERROR_RECOVERY_QCFG, BNXT_USE_CHIMP_MB);
+
+       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_ERROR_RECOVERY_QCFG_OUTPUT_FLAGS_HOST)
+               info->flags |= BNXT_FLAG_ERROR_RECOVERY_HOST;
+       else if (flags & HWRM_ERROR_RECOVERY_QCFG_OUTPUT_FLAGS_CO_CPU)
+               info->flags |= BNXT_FLAG_ERROR_RECOVERY_CO_CPU;
+
+       if ((info->flags & BNXT_FLAG_ERROR_RECOVERY_CO_CPU) &&
+           !(bp->flags & BNXT_FLAG_KONG_MB_EN)) {
+               rc = -EINVAL;
+               goto err;
+       }
+
+       /* FW returned values are in units of 100msec */
+       info->driver_polling_freq =
+               rte_le_to_cpu_32(resp->driver_polling_freq) * 100;
+       info->master_func_wait_period =
+               rte_le_to_cpu_32(resp->master_func_wait_period) * 100;
+       info->normal_func_wait_period =
+               rte_le_to_cpu_32(resp->normal_func_wait_period) * 100;
+       info->master_func_wait_period_after_reset =
+               rte_le_to_cpu_32(resp->master_func_wait_period_after_reset) * 100;
+       info->max_bailout_time_after_reset =
+               rte_le_to_cpu_32(resp->max_bailout_time_after_reset) * 100;
+       info->status_regs[BNXT_FW_STATUS_REG] =
+               rte_le_to_cpu_32(resp->fw_health_status_reg);
+       info->status_regs[BNXT_FW_HEARTBEAT_CNT_REG] =
+               rte_le_to_cpu_32(resp->fw_heartbeat_reg);
+       info->status_regs[BNXT_FW_RECOVERY_CNT_REG] =
+               rte_le_to_cpu_32(resp->fw_reset_cnt_reg);
+       info->status_regs[BNXT_FW_RESET_INPROG_REG] =
+               rte_le_to_cpu_32(resp->reset_inprogress_reg);
+       info->reg_array_cnt =
+               rte_le_to_cpu_32(resp->reg_array_cnt);
+
+       if (info->reg_array_cnt >= BNXT_NUM_RESET_REG) {
+               rc = -EINVAL;
+               goto err;
+       }
+
+       for (i = 0; i < info->reg_array_cnt; i++) {
+               info->reset_reg[i] =
+                       rte_le_to_cpu_32(resp->reset_reg[i]);
+               info->reset_reg_val[i] =
+                       rte_le_to_cpu_32(resp->reset_reg_val[i]);
+               info->delay_after_reset[i] =
+                       resp->delay_after_reset[i];
+       }
+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;
+       }
+       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;
+}
+
+int bnxt_hwrm_port_ts_query(struct bnxt *bp, uint8_t path, uint64_t *timestamp)
+{
+       struct hwrm_port_ts_query_output *resp = bp->hwrm_cmd_resp_addr;
+       struct hwrm_port_ts_query_input req = {0};
+       struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
+       uint32_t flags = 0;
+       int rc;
+
+       if (!ptp)
+               return 0;
+
+       HWRM_PREP(req, PORT_TS_QUERY, BNXT_USE_CHIMP_MB);
+
+       switch (path) {
+       case BNXT_PTP_FLAGS_PATH_TX:
+               flags |= HWRM_PORT_TS_QUERY_INPUT_FLAGS_PATH_TX;
+               break;
+       case BNXT_PTP_FLAGS_PATH_RX:
+               flags |= HWRM_PORT_TS_QUERY_INPUT_FLAGS_PATH_RX;
+               break;
+       case BNXT_PTP_FLAGS_CURRENT_TIME:
+               flags |= HWRM_PORT_TS_QUERY_INPUT_FLAGS_CURRENT_TIME;
+               break;
+       }
+
+       req.flags = rte_cpu_to_le_32(flags);
+       req.port_id = rte_cpu_to_le_16(bp->pf.port_id);
+
+       rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
+
+       HWRM_CHECK_RESULT();
+
+       if (timestamp) {
+               *timestamp = rte_le_to_cpu_32(resp->ptp_msg_ts[0]);
+               *timestamp |=
+                       (uint64_t)(rte_le_to_cpu_32(resp->ptp_msg_ts[1])) << 32;
+       }
+       HWRM_UNLOCK();
+
+       return rc;
+}