netdev
[Top] [All Lists]

Re: reminder to netdriver authors

To: hadi@xxxxxxxxxx
Subject: Re: reminder to netdriver authors
From: Jeff Garzik <jgarzik@xxxxxxxxx>
Date: Sun, 04 Jul 2004 11:05:21 -0400
Cc: netdev@xxxxxxxxxxx
In-reply-to: <1088910801.1041.818.camel@jzny.localdomain>
References: <1088910801.1041.818.camel@jzny.localdomain>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040510
jamal wrote:
1) When you have no space in your DMA

Do NOT stash the packet in your ring
a) netif_stop_queue()
b) return 1

A _lot_ of drivers dont follow this rule. A good driver to copy
from if you are into cutnpaste is the e1000.
If you stash the packet in your ring then return 1 you are in deep doodoo friend.


2) return a 0 only when you have succesfully put things on DMA.
Returning 0 always is not a BadThing. Most drivers do this.
It is a little less efficient at the top layer for each batch of packets
sent to the driver and you end up stopping the netif at this point.

3) In case of error probably return a 1 and dont try anything funny
with the skb. Dont put on your DMA or try to free it or muck with it in
any way. You probably should whine if you have too many errors in
sequence.


Someone with more time than myself can audit the drivers - I have seen
these issues.

FWIW some of this is related to my own lack of knowledge, long long ago, and mistakes made long ago get cut-n-pasted into the present.


I will edit this email, and add it to Documentation/networking/netdevices.txt.

Please (to all) consider netdevices.txt as a general text describing how to (or how not to) write net drivers. Any patches -- or even random comments you would like me to turn into patches -- are accepted. Share the knowledge!

        Jeff





<Prev in Thread] Current Thread [Next in Thread>