Blame view
Documentation/networking/netdevices.txt
3.8 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 8 9 10 11 12 |
Network Devices, the Kernel, and You! Introduction ============ The following is a random collection of documentation regarding network devices. struct net_device allocation rules ================================== Network device structures need to persist even after module is unloaded and |
74d332c13 net: extend net_d... |
13 14 15 16 |
must be allocated with alloc_netdev_mqs() and friends. If device has registered successfully, it will be freed on last use by free_netdev(). This is required to handle the pathologic case cleanly (example: rmmod mydriver </sys/class/net/myeth/mtu ) |
1da177e4c Linux-2.6.12-rc2 |
17 |
|
74d332c13 net: extend net_d... |
18 |
alloc_netdev_mqs()/alloc_netdev() reserve extra space for driver |
1da177e4c Linux-2.6.12-rc2 |
19 20 |
private data which gets freed when the network device is freed. If separately allocated data is attached to the network device |
b74ca3a89 netdevice: Kill n... |
21 |
(netdev_priv(dev)) then it is up to the module exit handler to free that. |
1da177e4c Linux-2.6.12-rc2 |
22 |
|
1c8c7d641 [NET]: netdevice ... |
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
MTU === Each network device has a Maximum Transfer Unit. The MTU does not include any link layer protocol overhead. Upper layer protocols must not pass a socket buffer (skb) to a device to transmit with more data than the mtu. The MTU does not include link layer header overhead, so for example on Ethernet if the standard MTU is 1500 bytes used, the actual skb will contain up to 1514 bytes because of the Ethernet header. Devices should allow for the 4 byte VLAN header as well. Segmentation Offload (GSO, TSO) is an exception to this rule. The upper layer protocol may pass a large socket buffer to the device transmit routine, and the device will break that up into separate packets based on the current MTU. MTU is symmetrical and applies both to receive and transmit. A device must be able to receive at least the maximum size packet allowed by the MTU. A network device may use the MTU as mechanism to size receive buffers, but the device should allow packets with VLAN header. With standard Ethernet mtu of 1500 bytes, the device should allow up to 1518 byte packets (1500 + 14 header + 4 tag). The device may either: drop, truncate, or pass up oversize packets, but dropping oversize packets is preferred. |
1da177e4c Linux-2.6.12-rc2 |
46 47 |
struct net_device synchronization rules ======================================= |
b3cf65457 doc, net: Update ... |
48 |
ndo_open: |
1da177e4c Linux-2.6.12-rc2 |
49 50 |
Synchronization: rtnl_lock() semaphore. Context: process |
b3cf65457 doc, net: Update ... |
51 |
ndo_stop: |
1da177e4c Linux-2.6.12-rc2 |
52 53 |
Synchronization: rtnl_lock() semaphore. Context: process |
93b6a3adb doc, net: Remove ... |
54 |
Note: netif_running() is guaranteed false |
1da177e4c Linux-2.6.12-rc2 |
55 |
|
b3cf65457 doc, net: Update ... |
56 |
ndo_do_ioctl: |
1da177e4c Linux-2.6.12-rc2 |
57 58 |
Synchronization: rtnl_lock() semaphore. Context: process |
b3cf65457 doc, net: Update ... |
59 |
ndo_get_stats: |
1da177e4c Linux-2.6.12-rc2 |
60 61 |
Synchronization: dev_base_lock rwlock. Context: nominally process, but don't sleep inside an rwlock |
b3cf65457 doc, net: Update ... |
62 |
ndo_start_xmit: |
04fd3d351 doc, net: Update ... |
63 |
Synchronization: __netif_tx_lock spinlock. |
172293332 [NET]: netdevice ... |
64 |
|
1da177e4c Linux-2.6.12-rc2 |
65 |
When the driver sets NETIF_F_LLTX in dev->features this will be |
932ff279a [NET]: Add netif_... |
66 |
called without holding netif_tx_lock. In this case the driver |
f0cdf76c1 net: remove NETDE... |
67 68 69 |
has to lock by itself when needed. The locking there should also properly protect against set_rx_mode. WARNING: use of NETIF_F_LLTX is deprecated. |
19f594600 trivial: Miscella... |
70 |
Don't use it for new drivers. |
172293332 [NET]: netdevice ... |
71 72 73 |
Context: Process with BHs disabled or BH (timer), will be called with interrupts disabled by netconsole. |
1da177e4c Linux-2.6.12-rc2 |
74 75 76 77 78 |
Return codes: o NETDEV_TX_OK everything ok. o NETDEV_TX_BUSY Cannot transmit packet, try later Usually a bug, means queue start/stop flow control is broken in the driver. Note: the driver must NOT put the skb in its DMA ring. |
1da177e4c Linux-2.6.12-rc2 |
79 |
|
b3cf65457 doc, net: Update ... |
80 |
ndo_tx_timeout: |
04fd3d351 doc, net: Update ... |
81 |
Synchronization: netif_tx_lock spinlock; all TX queues frozen. |
1da177e4c Linux-2.6.12-rc2 |
82 83 |
Context: BHs disabled Notes: netif_queue_stopped() is guaranteed true |
b3cf65457 doc, net: Update ... |
84 |
ndo_set_rx_mode: |
04fd3d351 doc, net: Update ... |
85 |
Synchronization: netif_addr_lock spinlock. |
1da177e4c Linux-2.6.12-rc2 |
86 |
Context: BHs disabled |
bea3348ee [NET]: Make NAPI ... |
87 88 89 90 |
struct napi_struct synchronization rules ======================================== napi->poll: Synchronization: NAPI_STATE_SCHED bit in napi->state. Device |
b3cf65457 doc, net: Update ... |
91 |
driver's ndo_stop method will invoke napi_disable() on |
bea3348ee [NET]: Make NAPI ... |
92 93 94 |
all NAPI instances which will do a sleeping poll on the NAPI_STATE_SCHED napi->state bit, waiting for all pending NAPI activity to cease. |
1da177e4c Linux-2.6.12-rc2 |
95 |
Context: softirq |
172293332 [NET]: netdevice ... |
96 |
will be called with interrupts disabled by netconsole. |