iavf: extract iavf_watchdog_step() out of iavf_watchdog_task()
Finish up easy refactor of watchdog_task, total for this + prev two commits is: 1 file changed, 47 insertions(+), 82 deletions(-) Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Tested-by: Rafal Romanowski <rafal.romanowski@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
This commit is contained in:
committed by
Tony Nguyen
parent
ecb4cd0461
commit
257a8241ad
@@ -2913,30 +2913,14 @@ err:
|
||||
|
||||
static const int IAVF_NO_RESCHED = -1;
|
||||
|
||||
/**
|
||||
* iavf_watchdog_task - Periodic call-back task
|
||||
* @work: pointer to work_struct
|
||||
**/
|
||||
static void iavf_watchdog_task(struct work_struct *work)
|
||||
/* return: msec delay for requeueing itself */
|
||||
static int iavf_watchdog_step(struct iavf_adapter *adapter)
|
||||
{
|
||||
struct iavf_adapter *adapter = container_of(work,
|
||||
struct iavf_adapter,
|
||||
watchdog_task.work);
|
||||
struct net_device *netdev = adapter->netdev;
|
||||
struct iavf_hw *hw = &adapter->hw;
|
||||
int msec_delay;
|
||||
u32 reg_val;
|
||||
|
||||
netdev_lock(netdev);
|
||||
if (!mutex_trylock(&adapter->crit_lock)) {
|
||||
if (adapter->state == __IAVF_REMOVE) {
|
||||
netdev_unlock(netdev);
|
||||
return;
|
||||
}
|
||||
|
||||
msec_delay = 20;
|
||||
goto restart_watchdog;
|
||||
}
|
||||
netdev_assert_locked(adapter->netdev);
|
||||
lockdep_assert_held(&adapter->crit_lock);
|
||||
|
||||
if (adapter->flags & IAVF_FLAG_PF_COMMS_FAILED)
|
||||
iavf_change_state(adapter, __IAVF_COMM_FAILED);
|
||||
@@ -2944,24 +2928,19 @@ static void iavf_watchdog_task(struct work_struct *work)
|
||||
switch (adapter->state) {
|
||||
case __IAVF_STARTUP:
|
||||
iavf_startup(adapter);
|
||||
msec_delay = 30;
|
||||
goto watchdog_done;
|
||||
return 30;
|
||||
case __IAVF_INIT_VERSION_CHECK:
|
||||
iavf_init_version_check(adapter);
|
||||
msec_delay = 30;
|
||||
goto watchdog_done;
|
||||
return 30;
|
||||
case __IAVF_INIT_GET_RESOURCES:
|
||||
iavf_init_get_resources(adapter);
|
||||
msec_delay = 1;
|
||||
goto watchdog_done;
|
||||
return 1;
|
||||
case __IAVF_INIT_EXTENDED_CAPS:
|
||||
iavf_init_process_extended_caps(adapter);
|
||||
msec_delay = 1;
|
||||
goto watchdog_done;
|
||||
return 1;
|
||||
case __IAVF_INIT_CONFIG_ADAPTER:
|
||||
iavf_init_config_adapter(adapter);
|
||||
msec_delay = 1;
|
||||
goto watchdog_done;
|
||||
return 1;
|
||||
case __IAVF_INIT_FAILED:
|
||||
if (test_bit(__IAVF_IN_REMOVE_TASK,
|
||||
&adapter->crit_section)) {
|
||||
@@ -2969,21 +2948,18 @@ static void iavf_watchdog_task(struct work_struct *work)
|
||||
* watchdog task, iavf_remove should handle this state
|
||||
* as it can loop forever
|
||||
*/
|
||||
msec_delay = IAVF_NO_RESCHED;
|
||||
goto watchdog_done;
|
||||
return IAVF_NO_RESCHED;
|
||||
}
|
||||
if (++adapter->aq_wait_count > IAVF_AQ_MAX_ERR) {
|
||||
dev_err(&adapter->pdev->dev,
|
||||
"Failed to communicate with PF; waiting before retry\n");
|
||||
adapter->flags |= IAVF_FLAG_PF_COMMS_FAILED;
|
||||
iavf_shutdown_adminq(hw);
|
||||
msec_delay = 5000;
|
||||
goto watchdog_done;
|
||||
return 5000;
|
||||
}
|
||||
/* Try again from failed step*/
|
||||
iavf_change_state(adapter, adapter->last_state);
|
||||
msec_delay = 1000;
|
||||
goto watchdog_done;
|
||||
return 1000;
|
||||
case __IAVF_COMM_FAILED:
|
||||
if (test_bit(__IAVF_IN_REMOVE_TASK,
|
||||
&adapter->crit_section)) {
|
||||
@@ -2993,8 +2969,7 @@ static void iavf_watchdog_task(struct work_struct *work)
|
||||
*/
|
||||
iavf_change_state(adapter, __IAVF_INIT_FAILED);
|
||||
adapter->flags &= ~IAVF_FLAG_PF_COMMS_FAILED;
|
||||
msec_delay = IAVF_NO_RESCHED;
|
||||
goto watchdog_done;
|
||||
return IAVF_NO_RESCHED;
|
||||
}
|
||||
reg_val = rd32(hw, IAVF_VFGEN_RSTAT) &
|
||||
IAVF_VFGEN_RSTAT_VFR_STATE_MASK;
|
||||
@@ -3012,11 +2987,9 @@ static void iavf_watchdog_task(struct work_struct *work)
|
||||
}
|
||||
adapter->aq_required = 0;
|
||||
adapter->current_op = VIRTCHNL_OP_UNKNOWN;
|
||||
msec_delay = 10;
|
||||
goto watchdog_done;
|
||||
return 10;
|
||||
case __IAVF_RESETTING:
|
||||
msec_delay = 2000;
|
||||
goto watchdog_done;
|
||||
return 2000;
|
||||
case __IAVF_DOWN:
|
||||
case __IAVF_DOWN_PENDING:
|
||||
case __IAVF_TESTING:
|
||||
@@ -3043,8 +3016,7 @@ static void iavf_watchdog_task(struct work_struct *work)
|
||||
break;
|
||||
case __IAVF_REMOVE:
|
||||
default:
|
||||
msec_delay = IAVF_NO_RESCHED;
|
||||
goto watchdog_done;
|
||||
return IAVF_NO_RESCHED;
|
||||
}
|
||||
|
||||
/* check for hw reset */
|
||||
@@ -3055,12 +3027,31 @@ static void iavf_watchdog_task(struct work_struct *work)
|
||||
dev_err(&adapter->pdev->dev, "Hardware reset detected\n");
|
||||
iavf_schedule_reset(adapter, IAVF_FLAG_RESET_PENDING);
|
||||
}
|
||||
if (adapter->aq_required)
|
||||
msec_delay = 20;
|
||||
else
|
||||
msec_delay = 2000;
|
||||
|
||||
watchdog_done:
|
||||
return adapter->aq_required ? 20 : 2000;
|
||||
}
|
||||
|
||||
static void iavf_watchdog_task(struct work_struct *work)
|
||||
{
|
||||
struct iavf_adapter *adapter = container_of(work,
|
||||
struct iavf_adapter,
|
||||
watchdog_task.work);
|
||||
struct net_device *netdev = adapter->netdev;
|
||||
int msec_delay;
|
||||
|
||||
netdev_lock(netdev);
|
||||
if (!mutex_trylock(&adapter->crit_lock)) {
|
||||
if (adapter->state == __IAVF_REMOVE) {
|
||||
netdev_unlock(netdev);
|
||||
return;
|
||||
}
|
||||
|
||||
msec_delay = 20;
|
||||
goto restart_watchdog;
|
||||
}
|
||||
|
||||
msec_delay = iavf_watchdog_step(adapter);
|
||||
|
||||
mutex_unlock(&adapter->crit_lock);
|
||||
restart_watchdog:
|
||||
netdev_unlock(netdev);
|
||||
|
||||
Reference in New Issue
Block a user