net/dpaa2: enable error queues optionally
[dpdk.git] / drivers / net / bnxt / bnxt_cpr.c
index 8311e26..b7be3e8 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2014-2018 Broadcom
+ * Copyright(c) 2014-2021 Broadcom
  * All rights reserved.
  */
 
@@ -50,7 +50,7 @@ static void
 bnxt_process_default_vnic_change(struct bnxt *bp,
                                 struct hwrm_async_event_cmpl *async_cmp)
 {
-       uint16_t fid, vnic_state, parent_id, vf_fid, vf_id;
+       uint16_t vnic_state, vf_fid, vf_id;
        struct bnxt_representor *vf_rep_bp;
        struct rte_eth_dev *eth_dev;
        bool vfr_found = false;
@@ -67,10 +67,7 @@ bnxt_process_default_vnic_change(struct bnxt *bp,
        if (vnic_state != BNXT_DEFAULT_VNIC_ALLOC)
                return;
 
-       parent_id = (event_data & BNXT_DEFAULT_VNIC_CHANGE_PF_ID_MASK) >>
-                       BNXT_DEFAULT_VNIC_CHANGE_PF_ID_SFT;
-       fid = BNXT_PF(bp) ? bp->fw_fid : bp->parent->fid;
-       if (parent_id != fid || !bp->rep_info)
+       if (!bp->rep_info)
                return;
 
        vf_fid = (event_data & BNXT_DEFAULT_VNIC_CHANGE_VF_ID_MASK) >>
@@ -111,7 +108,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
        case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CHANGE:
        case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE:
                /* FALLTHROUGH */
-               bnxt_link_update(bp->eth_dev, 0, ETH_LINK_UP);
+               bnxt_link_update_op(bp->eth_dev, 0);
                break;
        case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD:
                PMD_DRV_LOG(INFO, "Async event: PF driver unloaded\n");
@@ -124,12 +121,19 @@ 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:
+               /*
+                * Avoid any rx/tx packet processing during firmware reset
+                * operation.
+                */
+               bnxt_stop_rxtx(bp);
+
                /* Ignore reset notify async events when stopping the port */
                if (!bp->eth_dev->data->dev_started) {
                        bp->flags |= BNXT_FLAG_FATAL_ERROR;
                        return;
                }
 
+               pthread_mutex_lock(&bp->err_recovery_lock);
                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 ?
@@ -149,6 +153,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
                }
 
                bp->flags |= BNXT_FLAG_FW_RESET;
+               pthread_mutex_unlock(&bp->err_recovery_lock);
                rte_eal_alarm_set(US_PER_MS, bnxt_dev_reset_and_resume,
                                  (void *)bp);
                break;
@@ -239,7 +244,7 @@ void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmpl)
                goto reject;
        }
 
-       if (bnxt_rcv_msg_from_vf(bp, vf_id, fwd_cmd) == true) {
+       if (bnxt_rcv_msg_from_vf(bp, vf_id, fwd_cmd)) {
                /*
                 * In older firmware versions, the MAC had to be all zeros for
                 * the VF to set it's MAC via hwrm_func_vf_cfg. Set to all
@@ -254,6 +259,7 @@ void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmpl)
                                (const uint8_t *)"\x00\x00\x00\x00\x00");
                        }
                }
+
                if (fwd_cmd->req_type == HWRM_CFA_L2_SET_RX_MASK) {
                        struct hwrm_cfa_l2_set_rx_mask_input *srm =
                                                        (void *)fwd_cmd;
@@ -265,6 +271,7 @@ void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmpl)
                            HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLAN_NONVLAN |
                            HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ANYVLAN_NONVLAN);
                }
+
                /* Forward */
                rc = bnxt_hwrm_exec_fwd_resp(bp, fw_vf_id, fwd_cmd, req_len);
                if (rc) {
@@ -306,7 +313,7 @@ int bnxt_event_hwrm_resp_handler(struct bnxt *bp, struct cmpl_base *cmp)
                bnxt_handle_async_event(bp, cmp);
                evt = 1;
                break;
-       case CMPL_BASE_TYPE_HWRM_FWD_RESP:
+       case CMPL_BASE_TYPE_HWRM_FWD_REQ:
                /* Handle HWRM forwarded responses */
                bnxt_handle_fwd_req(bp, cmp);
                evt = 1;
@@ -338,3 +345,9 @@ bool bnxt_is_recovery_enabled(struct bnxt *bp)
 
        return false;
 }
+
+void bnxt_stop_rxtx(struct bnxt *bp)
+{
+       bp->eth_dev->rx_pkt_burst = &bnxt_dummy_recv_pkts;
+       bp->eth_dev->tx_pkt_burst = &bnxt_dummy_xmit_pkts;
+}