net_util: Use value returned from Queue::enable_notification()

This indicates if anything has been added to the available queue since
it was last iterated through. If it returns true then it is necessary to
iterate through the queue again otherwise it is appropriate to break out
from the loop.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2022-03-14 15:52:10 +00:00
parent 2ed0338da8
commit 1fc3fef642
2 changed files with 93 additions and 81 deletions

View File

@ -62,6 +62,7 @@ impl CtrlQueue {
access_platform: Option<&Arc<dyn AccessPlatform>>,
) -> Result<bool> {
let mut used_desc_heads = Vec::new();
loop {
for mut desc_chain in queue.iter().map_err(Error::QueueIterator)? {
let ctrl_desc = desc_chain.next().ok_or(Error::NoControlHeaderDescriptor)?;
@ -145,9 +146,14 @@ impl CtrlQueue {
queue
.add_used(*desc_index, *len)
.map_err(Error::QueueAddUsed)?;
queue
}
if !queue
.enable_notification()
.map_err(Error::QueueEnableNotification)?;
.map_err(Error::QueueEnableNotification)?
{
break;
}
}
Ok(!used_desc_heads.is_empty())

View File

@ -130,9 +130,12 @@ impl TxVirtio {
queue
.add_used(used_desc_head.0, used_desc_head.1)
.map_err(NetQueuePairError::QueueAddUsed)?;
queue
if !queue
.enable_notification()
.map_err(NetQueuePairError::QueueEnableNotification)?;
.map_err(NetQueuePairError::QueueEnableNotification)?
{
break;
}
}
Ok(retry_write)
@ -275,9 +278,12 @@ impl RxVirtio {
queue
.add_used(used_desc_head.0, used_desc_head.1)
.map_err(NetQueuePairError::QueueAddUsed)?;
queue
if !queue
.enable_notification()
.map_err(NetQueuePairError::QueueEnableNotification)?;
.map_err(NetQueuePairError::QueueEnableNotification)?
{
break;
}
}
Ok(exhausted_descs)