aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/networking/driver.txt
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /Documentation/networking/driver.txt
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'Documentation/networking/driver.txt')
-rw-r--r--Documentation/networking/driver.txt94
1 files changed, 94 insertions, 0 deletions
diff --git a/Documentation/networking/driver.txt b/Documentation/networking/driver.txt
new file mode 100644
index 000000000000..11fd0ef5ff57
--- /dev/null
+++ b/Documentation/networking/driver.txt
@@ -0,0 +1,94 @@
1Documents about softnet driver issues in general can be found
2at:
3
4 http://www.firstfloor.org/~andi/softnet/
5
6Transmit path guidelines:
7
81) The hard_start_xmit method must never return '1' under any
9 normal circumstances. It is considered a hard error unless
10 there is no way your device can tell ahead of time when it's
11 transmit function will become busy.
12
13 Instead it must maintain the queue properly. For example,
14 for a driver implementing scatter-gather this means:
15
16 static int drv_hard_start_xmit(struct sk_buff *skb,
17 struct net_device *dev)
18 {
19 struct drv *dp = dev->priv;
20
21 lock_tx(dp);
22 ...
23 /* This is a hard error log it. */
24 if (TX_BUFFS_AVAIL(dp) <= (skb_shinfo(skb)->nr_frags + 1)) {
25 netif_stop_queue(dev);
26 unlock_tx(dp);
27 printk(KERN_ERR PFX "%s: BUG! Tx Ring full when queue awake!\n",
28 dev->name);
29 return 1;
30 }
31
32 ... queue packet to card ...
33 ... update tx consumer index ...
34
35 if (TX_BUFFS_AVAIL(dp) <= (MAX_SKB_FRAGS + 1))
36 netif_stop_queue(dev);
37
38 ...
39 unlock_tx(dp);
40 ...
41 }
42
43 And then at the end of your TX reclaimation event handling:
44
45 if (netif_queue_stopped(dp->dev) &&
46 TX_BUFFS_AVAIL(dp) > (MAX_SKB_FRAGS + 1))
47 netif_wake_queue(dp->dev);
48
49 For a non-scatter-gather supporting card, the three tests simply become:
50
51 /* This is a hard error log it. */
52 if (TX_BUFFS_AVAIL(dp) <= 0)
53
54 and:
55
56 if (TX_BUFFS_AVAIL(dp) == 0)
57
58 and:
59
60 if (netif_queue_stopped(dp->dev) &&
61 TX_BUFFS_AVAIL(dp) > 0)
62 netif_wake_queue(dp->dev);
63
642) Do not forget to update netdev->trans_start to jiffies after
65 each new tx packet is given to the hardware.
66
673) Do not forget that once you return 0 from your hard_start_xmit
68 method, it is your driver's responsibility to free up the SKB
69 and in some finite amount of time.
70
71 For example, this means that it is not allowed for your TX
72 mitigation scheme to let TX packets "hang out" in the TX
73 ring unreclaimed forever if no new TX packets are sent.
74 This error can deadlock sockets waiting for send buffer room
75 to be freed up.
76
77 If you return 1 from the hard_start_xmit method, you must not keep
78 any reference to that SKB and you must not attempt to free it up.
79
80Probing guidelines:
81
821) Any hardware layer address you obtain for your device should
83 be verified. For example, for ethernet check it with
84 linux/etherdevice.h:is_valid_ether_addr()
85
86Close/stop guidelines:
87
881) After the dev->stop routine has been called, the hardware must
89 not receive or transmit any data. All in flight packets must
90 be aborted. If necessary, poll or wait for completion of
91 any reset commands.
92
932) The dev->stop routine will be called by unregister_netdevice
94 if device is still UP.