6 * include linux/skbuff.h
8 - struct net\\_device *dev
9 * alloc\\_skb(len, gfp)
10 * dev\\_alloc\\_skb(len) - uses ATOMIC, reserves PAD
11 * netdev\\_alloc\\_skb(netdev, len) - uses ATOMIC, since 2.6.18
12 * kfree\\_skb, dev\\_kfree\\_skb
16 * head - start of allocated buffer
17 * end - end of allocated buffer
18 * data - start of data, giving space after headroom
19 * tail - end of used space
20 * headroom - space between head and data
21 * tailroom - space between tail and end
23 # Socket Buffers operations
25 * skb\\_put(skb, len) - adds data to end of skb
26 * skb\\_push(skb, len) - adds data to start of skb
27 * skb\\_pull(skb, len) - allocates headroom
28 * skb\\_headroom and skb\\_tailroom
29 * skb\\_reserve - only allowed for empty buffer, reserves headroom
30 * skb\\_orphan - release it from its socket holder
34 * include linux/netdevice.h
47 # Network Device Setup
49 * alloc\\_netdev(szpriv, name, setup)
51 * include linux/etherdevice.h
58 # Network Device Operations
60 * struct net\\_device\\_ops
63 - should call netif\\_start\\_queue
65 - should call netif\\_stop\\_queue
67 # Network Device Address
71 * random\\_ether\\_addr
72 * struct net\\_device\\_ops
73 - ndo\\_set\\_mac\\_address
79 * Called with softirqs disabled or in softirq context
80 * Called with a held lock
82 # Limits on transmission
84 * When TX buffers are full, xmit may call netif\\_stop\\_queue
85 * Should arrange to get netif\\_wake\\_queue called after TX buffers are free
88 # Transmission timeout
90 * Transmission may timeout after queue has been stopped
91 * Current code already updates last time packet was transmitted
92 * Driver should set watchdog\\_timeo and ndo\\_tx\\_timeout
96 * Usually happens in an interrupt handler
97 * Driver allocates skb: some drivers allocate it when setting up and arrange the
98 device to write into the buffers directly
99 * Must set skb field protocol: easily done for ethernet drivers with
101 * Finally, call netif\\_rx
105 * To allow more performance, NAPI introduces polling, avoiding too much
106 interrupts when load is high
107 * Driver disables interrupts and enables polling in its interrupt handler
109 * Network subsystem uses a softirq to do the polling
110 * The driver poll function disables polling and reenabled interrupts when it's
111 done with its hardware queue
115 * struct napi\\_struct
116 * netif\\_napi\\_add(dev, napi, poll\\_func, weight)
117 * napi\\_enable: called in open
118 * napi\\_disable: called in stop - awaits completion
120 - napi\\_schedule\\_prep
121 - \\_\\_napi\\_schedule
122 * napi\\_complete: called in poll when all is done
123 * Use netif\\_receive\\_skb instead of netif\\_rx
127 * In the interrupt handler:
128 - Checks that the interrupt received is RX
129 - Call napi\\_schedule\\_prep to check that napi isn't already scheduled
131 - Call \\_\\_napi\\_schedule
135 * The weight is the start budget for the interface, usually 16
136 * The poll function must not dequeue more frames than the budget
137 * It must call napi\\_complete if and only if it has exhausted the hardware
138 queues with less than the budget
139 * It must return the number of entries in the queue processed
141 # Changes in net device
143 * Use netdev\\_priv, no priv anymore
144 * struct net\\_device\\_ops introduced in 2.6.29, with compatibility provided
146 * Compatibility removed in 2.6.31
147 * netdev\\_tx\\_t: NETDEV\\_TX\\_OK, NETDEV\\_TX\\_BUSY, NETDEV\\_TX\\_LOCKED
149 # Other recent changes
151 * Some members moved to netdev\\_queue to increase cache-line usage
153 * Multi-queue support
154 * RPS - Packet Steering