int e1000_transmit(struct mbuf *m) { // // Your code here. // // the mbuf contains an ethernet frame; program it into // the TX descriptor ring so that the e1000 sends it. Stash // a pointer so that it can be freed after sending. // acquire(&e1000_lock); // 找到ring中下一个放packet的下标 int idx = regs[E1000_TDT];
static void e1000_recv(void) { // // Your code here. // // Check for packets that have arrived from the e1000 // Create and deliver an mbuf for each packet (using net_rx()). // for (;;) { // 现在所有的packet都在memory里面了,我们需要把它们传递到application上去 int idx = (regs[E1000_RDT] + 1) % RX_RING_SIZE;
if ((rx_ring[idx].status & E1000_RXD_STAT_DD) == 0) return; // 如果没有需要读取的packet,那么就返回