src/dpdk/drivers/net/hns3/hns3_intr.c
int
hns3_reset_process(struct hns3_adapter *hns, enum hns3_reset_level new_level)
{
	struct hns3_hw *hw = &hns->hw;
	struct timeval tv_delta;
	struct timeval tv;
	int ret;

	if (hw->reset.level == HNS3_NONE_RESET) {
		hw->reset.level = new_level;
		hw->reset.stats.exec_cnt++;
		gettimeofday(&hw->reset.start_time, NULL);
		hns3_warn(hw, "Start %s reset time=%ld.%.6ld",
			  reset_string[hw->reset.level],
			  hw->reset.start_time.tv_sec,
			  hw->reset.start_time.tv_usec);
	}

	if (is_reset_pending(hns)) {
		gettimeofday(&tv, NULL);
		hns3_warn(hw,
			  "%s reset is aborted by high level time=%ld.%.6ld",
			  reset_string[hw->reset.level], tv.tv_sec, tv.tv_usec);
		if (hw->reset.wait_data->result == HNS3_WAIT_REQUEST)
			rte_eal_alarm_cancel(hns3_wait_callback,
					     hw->reset.wait_data);
		goto err;
	}

	ret = hns3_reset_pre(hns);
	if (ret)
		goto err;

	if (hw->reset.stage == RESET_STAGE_REQ_HW_RESET) {
		ret = hns3_reset_req_hw_reset(hns);
		if (ret == -EAGAIN)
			return ret;
		gettimeofday(&tv, NULL);
		hns3_warn(hw,
			  "Reset step3 request IMP reset success time=%ld.%.6ld",
			  tv.tv_sec, tv.tv_usec);
		hw->reset.stage = RESET_STAGE_WAIT;
		hw->reset.wait_data->result = HNS3_WAIT_UNKNOWN;
	}
	if (hw->reset.stage == RESET_STAGE_WAIT) {
		ret = hw->reset.ops->wait_hardware_ready(hns);
		if (ret)
			goto retry;
		gettimeofday(&tv, NULL);
		hns3_warn(hw, "Reset step4 reset wait success time=%ld.%.6ld",
			  tv.tv_sec, tv.tv_usec);
		hw->reset.stage = RESET_STAGE_DEV_INIT;
	}

	ret = hns3_reset_post(hns);
	if (ret)
		goto retry;

	return 0;
retry:
	if (ret == -EAGAIN)
		return ret;
err:
	hns3_clear_reset_level(hw, &hw->reset.pending);
	if (hns3_reset_err_handle(hns)) {
		hw->reset.stage = RESET_STAGE_PREWAIT;
		hns3_schedule_reset(hns);
	} else {
		rte_spinlock_lock(&hw->lock);
		if (hw->reset.mbuf_deferred_free) {
			hns3_dev_release_mbufs(hns);
			hw->reset.mbuf_deferred_free = false;
		}
		rte_spinlock_unlock(&hw->lock);
		__atomic_store_n(&hns->hw.reset.resetting, 0, __ATOMIC_RELAXED);
		hw->reset.stage = RESET_STAGE_NONE;
		gettimeofday(&tv, NULL);
		timersub(&tv, &hw->reset.start_time, &tv_delta);
		hns3_warn(hw, "%s reset fail delta %ld ms time=%ld.%.6ld",
			  reset_string[hw->reset.level],
			  tv_delta.tv_sec * MSEC_PER_SEC +
			  tv_delta.tv_usec / USEC_PER_MSEC,
			  tv.tv_sec, tv.tv_usec);
		hw->reset.level = HNS3_NONE_RESET;
	}

	return -EIO;
}
/*
 * There are three scenarios as follows:
 * When the reset is not in progress, the reset process starts.
 * During the reset process, if the reset level has not changed,
 * the reset process continues; otherwise, the reset process is aborted.
 *	hw->reset.level   new_level          action
 *	HNS3_NONE_RESET	 HNS3_XXXX_RESET    start reset
 *	HNS3_XXXX_RESET  HNS3_XXXX_RESET    continue reset
 *	HNS3_LOW_RESET   HNS3_HIGH_RESET    abort
 */
There are three scenarios as follows:
When the reset is not in progress, the reset process starts.
During the reset process, if the reset level has not changed,
the reset process continues; otherwise, the reset process is aborted.
There are three scenarios as follows : When the reset is not in progress the reset process starts . During the reset process if the reset level has not changed the reset process continues ; otherwise the reset process is aborted .
int
hns3_reset_process(struct hns3_adapter *hns, enum hns3_reset_level new_level)
{
	struct hns3_hw *hw = &hns->hw;
	struct timeval tv_delta;
	struct timeval tv;
	int ret;
	if (hw->reset.level == HNS3_NONE_RESET) {
		hw->reset.level = new_level;
		hw->reset.stats.exec_cnt++;
		gettimeofday(&hw->reset.start_time, NULL);
		hns3_warn(hw, "Start %s reset time=%ld.%.6ld",
			  reset_string[hw->reset.level],
			  hw->reset.start_time.tv_sec,
			  hw->reset.start_time.tv_usec);
	}
	if (is_reset_pending(hns)) {
		gettimeofday(&tv, NULL);
		hns3_warn(hw,
			  "%s reset is aborted by high level time=%ld.%.6ld",
			  reset_string[hw->reset.level], tv.tv_sec, tv.tv_usec);
		if (hw->reset.wait_data->result == HNS3_WAIT_REQUEST)
			rte_eal_alarm_cancel(hns3_wait_callback,
					     hw->reset.wait_data);
		goto err;
	}
	ret = hns3_reset_pre(hns);
	if (ret)
		goto err;
	if (hw->reset.stage == RESET_STAGE_REQ_HW_RESET) {
		ret = hns3_reset_req_hw_reset(hns);
		if (ret == -EAGAIN)
			return ret;
		gettimeofday(&tv, NULL);
		hns3_warn(hw,
			  "Reset step3 request IMP reset success time=%ld.%.6ld",
			  tv.tv_sec, tv.tv_usec);
		hw->reset.stage = RESET_STAGE_WAIT;
		hw->reset.wait_data->result = HNS3_WAIT_UNKNOWN;
	}
	if (hw->reset.stage == RESET_STAGE_WAIT) {
		ret = hw->reset.ops->wait_hardware_ready(hns);
		if (ret)
			goto retry;
		gettimeofday(&tv, NULL);
		hns3_warn(hw, "Reset step4 reset wait success time=%ld.%.6ld",
			  tv.tv_sec, tv.tv_usec);
		hw->reset.stage = RESET_STAGE_DEV_INIT;
	}
	ret = hns3_reset_post(hns);
	if (ret)
		goto retry;
	return 0;
retry:
	if (ret == -EAGAIN)
		return ret;
err:
	hns3_clear_reset_level(hw, &hw->reset.pending);
	if (hns3_reset_err_handle(hns)) {
		hw->reset.stage = RESET_STAGE_PREWAIT;
		hns3_schedule_reset(hns);
	} else {
		rte_spinlock_lock(&hw->lock);
		if (hw->reset.mbuf_deferred_free) {
			hns3_dev_release_mbufs(hns);
			hw->reset.mbuf_deferred_free = false;
		}
		rte_spinlock_unlock(&hw->lock);
		__atomic_store_n(&hns->hw.reset.resetting, 0, __ATOMIC_RELAXED);
		hw->reset.stage = RESET_STAGE_NONE;
		gettimeofday(&tv, NULL);
		timersub(&tv, &hw->reset.start_time, &tv_delta);
		hns3_warn(hw, "%s reset fail delta %ld ms time=%ld.%.6ld",
			  reset_string[hw->reset.level],
			  tv_delta.tv_sec * MSEC_PER_SEC +
			  tv_delta.tv_usec / USEC_PER_MSEC,
			  tv.tv_sec, tv.tv_usec);
		hw->reset.level = HNS3_NONE_RESET;
	}
	return -EIO;
}
int hns3_reset_process ( struct hns3_adapter * hns , enum hns3_reset_level new_level ) { struct hns3_hw * hw = & hns -> hw ; struct timeval tv_delta ; struct timeval tv ; int ret ; if ( hw -> reset . level == HNS3_NONE_RESET ) { hw -> reset . level = new_level ; hw -> reset . stats . exec_cnt ++ ; gettimeofday ( & hw -> reset . start_time , NULL ) ; hns3_warn ( hw , " " , reset_string [ hw -> reset . level ] , hw -> reset . start_time . tv_sec , hw -> reset . start_time . tv_usec ) ; } if ( is_reset_pending ( hns ) ) { gettimeofday ( & tv , NULL ) ; hns3_warn ( hw , " " , reset_string [ hw -> reset . level ] , tv . tv_sec , tv . tv_usec ) ; if ( hw -> reset . wait_data -> result == HNS3_WAIT_REQUEST ) rte_eal_alarm_cancel ( hns3_wait_callback , hw -> reset . wait_data ) ; goto err ; } ret = hns3_reset_pre ( hns ) ; if ( ret ) goto err ; if ( hw -> reset . stage == RESET_STAGE_REQ_HW_RESET ) { ret = hns3_reset_req_hw_reset ( hns ) ; if ( ret == - EAGAIN ) return ret ; gettimeofday ( & tv , NULL ) ; hns3_warn ( hw , " " , tv . tv_sec , tv . tv_usec ) ; hw -> reset . stage = RESET_STAGE_WAIT ; hw -> reset . wait_data -> result = HNS3_WAIT_UNKNOWN ; } if ( hw -> reset . stage == RESET_STAGE_WAIT ) { ret = hw -> reset . ops -> wait_hardware_ready ( hns ) ; if ( ret ) goto retry ; gettimeofday ( & tv , NULL ) ; hns3_warn ( hw , " " , tv . tv_sec , tv . tv_usec ) ; hw -> reset . stage = RESET_STAGE_DEV_INIT ; } ret = hns3_reset_post ( hns ) ; if ( ret ) goto retry ; return 0 ; retry : if ( ret == - EAGAIN ) return ret ; err : hns3_clear_reset_level ( hw , & hw -> reset . pending ) ; if ( hns3_reset_err_handle ( hns ) ) { hw -> reset . stage = RESET_STAGE_PREWAIT ; hns3_schedule_reset ( hns ) ; } else { rte_spinlock_lock ( & hw -> lock ) ; if ( hw -> reset . mbuf_deferred_free ) { hns3_dev_release_mbufs ( hns ) ; hw -> reset . mbuf_deferred_free = false ; } rte_spinlock_unlock ( & hw -> lock ) ; __atomic_store_n ( & hns -> hw . reset . resetting , 0 , __ATOMIC_RELAXED ) ; hw -> reset . stage = RESET_STAGE_NONE ; gettimeofday ( & tv , NULL ) ; timersub ( & tv , & hw -> reset . start_time , & tv_delta ) ; hns3_warn ( hw , " " , reset_string [ hw -> reset . level ] , tv_delta . tv_sec * MSEC_PER_SEC + tv_delta . tv_usec / USEC_PER_MSEC , tv . tv_sec , tv . tv_usec ) ; hw -> reset . level = HNS3_NONE_RESET ; } return - EIO ; }
There are three scenarios as follows:
 When the reset is not in progress, the reset process starts.
There are three scenarios as follows : When the reset is not in progress the reset process starts .