Hi,
I found em's receiving queue handling will have the following problems if
system mbuf is used up.
1. NIC will hang because receive ring's tail pointer will not be updated (in
em_rxeof).
2. "ifconfig up/down" may cause system panic because
em_setup_receive_ring will free already-freed mbufs.
So I made some changes:
1. NIC's recieve ring's head/tail pointer is updated according to
rxr's next_to_check/next_to_refresh.
So, on the position of next_to_refresh, no need to fill free mbuf because
datasheet says
"When the head pointer(s) is equal to the tail pointer(s), the
queue(s) is empty.
Hardware stops storing packets in system memory until software advances
the tail
pointer(s), making more receive buffers available."
And (next_to_refresh + 1) % num_rx_desc == next_to_check means ring queue is
full.
2. no need to reallocate the mbufs on receive queue when em re-initialize.
3. The mbufs on the queue are also freed according to these two indexs.
4. If ring queue is empty, em_refresh_mbufs is also called even if it
doesn't handle any packet.
Any comment?
Thanks
2010-09-10
beezarliu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: if_em.c.patch
Type: application/octet-stream
Size: 4182 bytes
Desc: not available
Url :
http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20100910/1f80f0be/if_em.c.obj