forked from M-Labs/zynq-rs
eth: use UncachedSlice for both desc and buffers
This commit is contained in:
parent
8267acfcba
commit
7c8ec46c8f
@ -59,7 +59,7 @@ register_bit!(desc_word1, global_broadcast, 31);
|
||||
#[repr(C)]
|
||||
pub struct DescList {
|
||||
list: UncachedSlice<DescEntry>,
|
||||
buffers: Vec<Buffer>,
|
||||
buffers: UncachedSlice<Buffer>,
|
||||
next: usize,
|
||||
}
|
||||
|
||||
@ -67,7 +67,8 @@ impl DescList {
|
||||
pub fn new(size: usize) -> Self {
|
||||
let mut list = UncachedSlice::new(size, || DescEntry::zeroed())
|
||||
.unwrap();
|
||||
let mut buffers = vec![Buffer::new(); size];
|
||||
let mut buffers = UncachedSlice::new(size, || Buffer::new())
|
||||
.unwrap();
|
||||
|
||||
let last = list.len().min(buffers.len()) - 1;
|
||||
for (i, (entry, buffer)) in list.iter_mut().zip(buffers.iter_mut()).enumerate() {
|
||||
@ -83,8 +84,8 @@ impl DescList {
|
||||
entry.word1.write(
|
||||
DescWord1::zeroed()
|
||||
);
|
||||
l2cache().invalidate_slice(&mut buffer[..]);
|
||||
dcci_slice(&buffer[..]);
|
||||
// l2cache().invalidate_slice(&mut buffer[..]);
|
||||
// dcci_slice(&buffer[..]);
|
||||
}
|
||||
|
||||
DescList {
|
||||
@ -141,10 +142,10 @@ pub struct PktRef<'a> {
|
||||
|
||||
impl<'a> Drop for PktRef<'a> {
|
||||
fn drop(&mut self) {
|
||||
// Flush buffer from cache, to be filled by the peripheral
|
||||
// before next read
|
||||
l2cache().invalidate_slice(self.buffer);
|
||||
dcci_slice(self.buffer);
|
||||
// // Flush buffer from cache, to be filled by the peripheral
|
||||
// // before next read
|
||||
// l2cache().invalidate_slice(self.buffer);
|
||||
// dcci_slice(self.buffer);
|
||||
|
||||
self.entry.word0.modify(|_, w| w.used(false));
|
||||
dmb();
|
||||
|
@ -1,6 +1,7 @@
|
||||
use core::ops::{Deref, DerefMut};
|
||||
use alloc::{vec, vec::Vec};
|
||||
use libcortex_a9::{asm::dmb, cache::dcc_slice, UncachedSlice};
|
||||
//use libcortex_a9::{asm::*, cache::*, UncachedSlice};
|
||||
use libregister::*;
|
||||
use log::{debug, warn};
|
||||
use crate::l2cache;
|
||||
@ -46,7 +47,7 @@ pub const DESCS: usize = 8;
|
||||
#[repr(C)]
|
||||
pub struct DescList {
|
||||
list: UncachedSlice<DescEntry>,
|
||||
buffers: Vec<Buffer>,
|
||||
buffers: UncachedSlice<Buffer>,
|
||||
next: usize,
|
||||
}
|
||||
|
||||
@ -54,7 +55,8 @@ impl DescList {
|
||||
pub fn new(size: usize) -> Self {
|
||||
let mut list = UncachedSlice::new(size, || DescEntry::zeroed())
|
||||
.unwrap();
|
||||
let mut buffers = vec![Buffer::new(); size];
|
||||
let mut buffers = UncachedSlice::new(size, || Buffer::new())
|
||||
.unwrap();
|
||||
|
||||
let last = list.len().min(buffers.len()) - 1;
|
||||
// Sending seems to not work properly with only one packet
|
||||
@ -133,9 +135,9 @@ pub struct PktRef<'a> {
|
||||
|
||||
impl<'a> Drop for PktRef<'a> {
|
||||
fn drop(&mut self) {
|
||||
// Write back all dirty cachelines of packet buffer
|
||||
dcc_slice(self.buffer);
|
||||
l2cache().clean_slice(self.buffer);
|
||||
// // Write back all dirty cachelines of packet buffer
|
||||
// dcc_slice(self.buffer);
|
||||
// l2cache().clean_slice(self.buffer);
|
||||
|
||||
self.entry.word1.modify(|_, w| w.used(false));
|
||||
dmb();
|
||||
|
Loading…
Reference in New Issue
Block a user