[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cdi-devel] [PATCH 3/5] e1000: Initialise status field in Rx Descriptors
Checking whether bit 0 has been set in the status field only works for
determining whether a descriptor has been used by the NIC if the bit is
properly cleared before handing it to the device.
Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
e1000/device.c | 4 ++++
include/cdi/misc.h | 2 ++
2 files changed, 6 insertions(+)
diff --git a/e1000/device.c b/e1000/device.c
index ac9bc2d..cf5bc81 100644
--- a/e1000/device.c
+++ b/e1000/device.c
@@ -384,6 +384,7 @@ static void reset_nic(struct e1000_device* netcard)
for (i = 0; i < RX_BUFFER_NUM; i++) {
netcard->rx_desc[i].length = RX_BUFFER_SIZE;
netcard->rx_desc[i].buffer = PHYS(netcard, rx_buffer[i * RX_BUFFER_SIZE]);
+ netcard->rx_desc[i].status = 0;
#ifdef DEBUG
printf("e1000: [%d] Rx: Buffer @ phys %08llx, Desc @ phys %08x\n",
@@ -626,6 +627,9 @@ static void e1000_handle_interrupt(struct cdi_device* device)
&netcard->rx_buffer[netcard->rx_cur_buffer * RX_BUFFER_SIZE],
size);
+ cdi_barrier();
+ netcard->rx_desc[netcard->rx_cur_buffer].status = 0;
+
netcard->rx_cur_buffer++;
netcard->rx_cur_buffer %= RX_BUFFER_NUM;
}
diff --git a/include/cdi/misc.h b/include/cdi/misc.h
index 9676b4a..2f0f500 100644
--- a/include/cdi/misc.h
+++ b/include/cdi/misc.h
@@ -25,6 +25,8 @@
extern "C" {
#endif
+#define cdi_barrier() do { asm volatile("" ::: "memory"); } while(0)
+
/**
* Registiert einen neuen IRQ-Handler.
*
--
2.1.4