X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fbnxt%2Fbnxt_cpr.c;h=40e5350f6dca24c172b3f799381a71a214b3ca74;hb=2e449a26e7e81632dac39ff975081473c90e7b73;hp=0fd6e51e51e7a0335f67f9e1bc85f90750aa6bb9;hpb=b42c15c83e882621aea730a71c7fab1481e14051;p=dpdk.git diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c index 0fd6e51e51..40e5350f6d 100644 --- a/drivers/net/bnxt/bnxt_cpr.c +++ b/drivers/net/bnxt/bnxt_cpr.c @@ -4,13 +4,48 @@ */ #include +#include +#include #include "bnxt.h" -#include "bnxt_cpr.h" #include "bnxt_hwrm.h" #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->fw_cap & BNXT_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 */ @@ -20,28 +55,97 @@ 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); + struct bnxt_error_recovery_info *info; + uint32_t event_data; - /* TODO: HWRM async events are not defined yet */ - /* Needs to handle: link events, error events, etc. */ switch (event_id) { case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE: 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_op(bp->eth_dev, 1); + bnxt_link_update(bp->eth_dev, 0, ETH_LINK_UP); break; case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD: PMD_DRV_LOG(INFO, "Async event: PF driver unloaded\n"); break; case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_CFG_CHANGE: PMD_DRV_LOG(INFO, "Async event: VF config changed\n"); - bnxt_hwrm_func_qcfg(bp); + bnxt_hwrm_func_qcfg(bp, NULL); break; 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: + /* Ignore reset notify async events when stopping the port */ + if (!bp->eth_dev->data->dev_started) { + bp->flags |= BNXT_FLAG_FATAL_ERROR; + return; + } + + 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 : + BNXT_MAX_FW_RESET_TIMEOUT; + bp->fw_reset_min_msecs = async_cmp->timestamp_lo ? + async_cmp->timestamp_lo * 100 : + BNXT_MIN_FW_READY_TIMEOUT; + 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, + (void *)bp); + break; + case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_ERROR_RECOVERY: + info = bp->recovery_info; + + if (!info) + return; + + PMD_DRV_LOG(INFO, "Error recovery async event received\n"); + + event_data = rte_le_to_cpu_32(async_cmp->event_data1) & + EVENT_DATA1_FLAGS_MASK; + + if (event_data & EVENT_DATA1_FLAGS_MASTER_FUNC) + info->flags |= BNXT_FLAG_MASTER_FUNC; + else + info->flags &= ~BNXT_FLAG_MASTER_FUNC; + + if (event_data & EVENT_DATA1_FLAGS_RECOVERY_ENABLED) + info->flags |= BNXT_FLAG_RECOVERY_ENABLED; + else + info->flags &= ~BNXT_FLAG_RECOVERY_ENABLED; + + 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; + case HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DEBUG_NOTIFICATION: + PMD_DRV_LOG(INFO, "DNC event: evt_data1 %#x evt_data2 %#x\n", + rte_le_to_cpu_32(async_cmp->event_data1), + rte_le_to_cpu_32(async_cmp->event_data2)); + 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; } } @@ -56,14 +160,14 @@ void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmpl) uint16_t req_len; int rc; - if (bp->pf.active_vfs <= 0) { + if (bp->pf->active_vfs <= 0) { PMD_DRV_LOG(ERR, "Forwarded VF with no active VFs\n"); return; } /* Qualify the fwd request */ fw_vf_id = rte_le_to_cpu_16(fwd_cmpl->source_id); - vf_id = fw_vf_id - bp->pf.first_vf_id; + vf_id = fw_vf_id - bp->pf->first_vf_id; req_len = (rte_le_to_cpu_16(fwd_cmpl->req_len_type) & HWRM_FWD_REQ_CMPL_REQ_LEN_MASK) >> @@ -72,15 +176,15 @@ void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmpl) req_len = sizeof(fwreq->encap_request); /* Locate VF's forwarded command */ - fwd_cmd = (struct input *)bp->pf.vf_info[vf_id].req_buf; + fwd_cmd = (struct input *)bp->pf->vf_info[vf_id].req_buf; - if (fw_vf_id < bp->pf.first_vf_id || - fw_vf_id >= (bp->pf.first_vf_id) + bp->pf.active_vfs) { + if (fw_vf_id < bp->pf->first_vf_id || + fw_vf_id >= bp->pf->first_vf_id + bp->pf->active_vfs) { PMD_DRV_LOG(ERR, "FWD req's source_id 0x%x out of range 0x%x - 0x%x (%d %d)\n", - fw_vf_id, bp->pf.first_vf_id, - (bp->pf.first_vf_id) + bp->pf.active_vfs - 1, - bp->pf.first_vf_id, bp->pf.active_vfs); + fw_vf_id, bp->pf->first_vf_id, + (bp->pf->first_vf_id) + bp->pf->active_vfs - 1, + bp->pf->first_vf_id, bp->pf->active_vfs); goto reject; } @@ -115,7 +219,7 @@ void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmpl) if (rc) { PMD_DRV_LOG(ERR, "Failed to send FWD req VF 0x%x, type 0x%x.\n", - fw_vf_id - bp->pf.first_vf_id, + fw_vf_id - bp->pf->first_vf_id, rte_le_to_cpu_16(fwd_cmd->req_type)); } return; @@ -126,7 +230,7 @@ reject: if (rc) { PMD_DRV_LOG(ERR, "Failed to send REJECT req VF 0x%x, type 0x%x.\n", - fw_vf_id - bp->pf.first_vf_id, + fw_vf_id - bp->pf->first_vf_id, rte_le_to_cpu_16(fwd_cmd->req_type)); } @@ -142,6 +246,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 */ @@ -155,9 +262,28 @@ 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; } return evt; } + +bool bnxt_is_master_func(struct bnxt *bp) +{ + if (bp->recovery_info->flags & BNXT_FLAG_MASTER_FUNC) + return true; + + return false; +} + +bool bnxt_is_recovery_enabled(struct bnxt *bp) +{ + struct bnxt_error_recovery_info *info; + + info = bp->recovery_info; + if (info && (info->flags & BNXT_FLAG_RECOVERY_ENABLED)) + return true; + + return false; +}