Skip to content

Commit

Permalink
netkvm: issue poll request from poll handler when needed
Browse files Browse the repository at this point in the history
One of problems in HCK tests is that we often come to
state when poll handler is not called when this would
be expected and nothing happens that can trigger the polllng.
Issue 'request from self' to resume polling when RX or TX
needs service.

Signed-off-by: Yuri Benditovich <[email protected]>
  • Loading branch information
ybendito authored and YanVugenfirer committed May 5, 2024
1 parent dffd27a commit 5fd4ffb
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion NetKVM/wlh/ParaNdis_Poll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,22 @@ void NdisPollHandler::EnableNotification(BOOLEAN Enable)
}
}

// normal cycle of polling is (<= is callback, => is call):
// <= enable notification
// notify ... trigger ... => request poll
// <= disable notification
// <= handle poll
// <= enable notification
// <= handle poll
void NdisPollHandler::HandlePoll(NDIS_POLL_DATA* PollData)
{
DPrintf(POLL_PRINT_LEVEL, "[%s] #%d\n", __FUNCTION__, m_Index);
CDpcIrqlRaiser raise;

// RX
RxPoll(m_AdapterContext, m_Index, PollData->Receive);
if (PollData->Receive.NumberOfIndicatedNbls)
if (PollData->Receive.NumberOfIndicatedNbls ||
PollData->Receive.NumberOfRemainingNbls)
{
DPrintf(POLL_PRINT_LEVEL, "[%s] RX #%d indicated %d, max %d, still here %d\n",
__FUNCTION__, m_Index, PollData->Receive.NumberOfIndicatedNbls,
Expand All @@ -111,8 +119,22 @@ void NdisPollHandler::HandlePoll(NDIS_POLL_DATA* PollData)
if (bundle->txPath.DoPendingTasks(NULL))
{
PollData->Transmit.NumberOfRemainingNbls = NDIS_ANY_NUMBER_OF_NBLS;
DPrintf(POLL_PRINT_LEVEL, "[%s] TX #%d requests attention\n",
__FUNCTION__, bundle->txPath.getQueueIndex());
}
}
// There are various cases when RX returns 0 NBLs and NumberOfRemainingNbls != 0.
// TX currently always returns 0 NBLs and sometimes NumberOfRemainingNbls != 0.
// In these cases poll thread still may decide that there is no progress and then
// start waiting for notifications but they may never come.
// When there is a reason to resume polling - issue notification.
// It will trigger the polling if notifications are enabled (m_EnableNotify==0)
// Otherwise (m_EnableNotify>0) this has no effect and that's ok, this means
// the handler will be invoked anyway
if (PollData->Receive.NumberOfRemainingNbls || PollData->Transmit.NumberOfRemainingNbls)
{
ParaNdisPollNotify(m_AdapterContext, m_Index, "Self");
}
}

#else
Expand Down

0 comments on commit 5fd4ffb

Please sign in to comment.