OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [Documentation/] [networking/] [driver.txt] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
Documents about softnet driver issues in general can be found
2
at:
3
 
4
        http://www.firstfloor.org/~andi/softnet/
5
 
6
Transmit path guidelines:
7
 
8
1) 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
 
64
2) Do not forget to update netdev->trans_start to jiffies after
65
   each new tx packet is given to the hardware.
66
 
67
3) 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
 
80
Probing guidelines:
81
 
82
1) 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()

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.