After booted, my driver does not work correctly sometimes when I sent one packet to it. It can get my 80-byte test packet (sent from another machine) in some runs. The success rate is about 50%! During failing runs, I can see that the Ethernet card moves RDH more than one slot forward, although I send one packet each time. The error/status of each rx descriptors seem to be arbitrary values, while length is the total length of the packet buffer I set up in the descriptor. I don't understand why my card has so weird behavior. It treats one small packet as several packets and uses more than one descriptor to deal with it. Those packets are not the one I originally sent. I suspect there are some initialization routine I missed, so I get this nondeterministic behaviors. What I did for receiving is quite simple
Code: Select all
mmio_write32(E1000_RCTL, (RDMTS_HALF | RCTL_BSIZE_2048 | RCTL_SECRC | RCTL_EN));
mmio_write32(E1000_CTRL, (mmio_read32(E1000_CTRL) | CTRL_SLU));
Is that enough?
For the descriptor setup, I have checked so many times. Only one place I am not sure, that is RDT setting.
I am not sure it should be
Code: Select all
mmio_write32(E1000_RDT(0), NUM_RX_DESCRIPTORS);
Code: Select all
mmio_write32(E1000_RDT(0), NUM_RX_DESCRIPTORS-1);
But I tried both, none is helpful. Anybody can help me?