Refactor virtio drivers with DMA APIs

This commit is contained in:
Jianfeng Jiang
2024-03-12 11:01:50 +00:00
committed by Tate, Hongliang Tian
parent 5e127b2da0
commit cd1575bc6d
22 changed files with 853 additions and 311 deletions

View File

@ -1,6 +1,7 @@
// SPDX-License-Identifier: MPL-2.0
use aster_frame::vm::{DmaCoherent, DmaStream, DmaStreamSlice, HasDaddr};
use aster_network::{DmaSegment, RxBuffer, TxBuffer};
/// A DMA-capable buffer.
///
@ -29,3 +30,21 @@ impl DmaBuf for DmaCoherent {
self.nbytes()
}
}
impl DmaBuf for DmaSegment {
fn len(&self) -> usize {
self.size()
}
}
impl DmaBuf for TxBuffer {
fn len(&self) -> usize {
self.nbytes()
}
}
impl DmaBuf for RxBuffer {
fn len(&self) -> usize {
self.buf_len()
}
}