mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-21 16:33:24 +00:00
Notify virtqueue in a batch manner
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
acc10376e6
commit
9a540d0fb6
@ -18,3 +18,9 @@ pub trait WithDevice: Send + Sync {
|
||||
where
|
||||
F: FnOnce(&mut Self::Device) -> R;
|
||||
}
|
||||
|
||||
/// A trait for notifying device drivers about the polling process.
|
||||
pub trait NotifyDevice {
|
||||
/// Notifies the device driver that polling has ended.
|
||||
fn notify_poll_end(&mut self);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ use smoltcp::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
device::WithDevice,
|
||||
device::{NotifyDevice, WithDevice},
|
||||
ext::Ext,
|
||||
iface::{
|
||||
common::IfaceCommon, iface::internal::IfaceInternal, time::get_network_timestamp, Iface,
|
||||
@ -70,7 +70,10 @@ impl<D, E: Ext> IfaceInternal<E> for EtherIface<D, E> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D: WithDevice + 'static, E: Ext> Iface<E> for EtherIface<D, E> {
|
||||
impl<D: WithDevice + 'static, E: Ext> Iface<E> for EtherIface<D, E>
|
||||
where
|
||||
D::Device: NotifyDevice,
|
||||
{
|
||||
fn poll(&self) {
|
||||
self.driver.with(|device| {
|
||||
let next_poll = self.common.poll(
|
||||
@ -78,6 +81,7 @@ impl<D: WithDevice + 'static, E: Ext> Iface<E> for EtherIface<D, E> {
|
||||
|data, iface_cx, tx_token| self.process(data, iface_cx, tx_token),
|
||||
|pkt, iface_cx, tx_token| self.dispatch(pkt, iface_cx, tx_token),
|
||||
);
|
||||
device.notify_poll_end();
|
||||
self.common.sched_poll().schedule_next_poll(next_poll);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user