Skip to content

Commit b736c91

Browse files
committed
e1000: Optimize recv to avoid MMIO writes
1 parent 4ebd930 commit b736c91

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/drivers/e1000.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ void e1000::event_handler()
216216

217217
void e1000::recv_handler()
218218
{
219+
uint16_t old_idx = 0xffff;
220+
219221
while (rx.desc[rx.current].status & 1)
220222
{
221223
auto& tk = rx.desc[rx.current];
@@ -229,10 +231,11 @@ void e1000::recv_handler()
229231
tk.addr = (uint64_t) this->new_rx_packet();
230232
tk.status = 0;
231233
// go to next index
232-
uint16_t old_idx = rx.current;
234+
old_idx = rx.current;
233235
rx.current = (rx.current + 1) % NUM_RX_DESC;
234-
write_cmd(REG_RXDESCTAIL, old_idx);
235236
}
237+
if (old_idx != 0xffff)
238+
write_cmd(REG_RXDESCTAIL, old_idx);
236239
}
237240

238241
void e1000::transmit(net::Packet_ptr pckt)

0 commit comments

Comments
 (0)