Skip to content

Commit e34fac1

Browse files
Ben Hutchingsdavem330
authored andcommitted
doc, net: Update ndo_start_xmit return type and values
Commit dc1f8bf ('netdev: change transmit to limited range type') changed the required return type and 9a1654b ('net: Optimize hard_start_xmit() return checking') changed the valid numerical return values. Signed-off-by: Ben Hutchings <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent de7aca1 commit e34fac1

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Documentation/networking/driver.txt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ Document about softnet driver issues
22

33
Transmit path guidelines:
44

5-
1) The ndo_start_xmit method must never return '1' under any
6-
normal circumstances. It is considered a hard error unless
5+
1) The ndo_start_xmit method must not return NETDEV_TX_BUSY under
6+
any normal circumstances. It is considered a hard error unless
77
there is no way your device can tell ahead of time when it's
88
transmit function will become busy.
99

1010
Instead it must maintain the queue properly. For example,
1111
for a driver implementing scatter-gather this means:
1212

13-
static int drv_hard_start_xmit(struct sk_buff *skb,
14-
struct net_device *dev)
13+
static netdev_tx_t drv_hard_start_xmit(struct sk_buff *skb,
14+
struct net_device *dev)
1515
{
1616
struct drv *dp = netdev_priv(dev);
1717

@@ -23,7 +23,7 @@ Transmit path guidelines:
2323
unlock_tx(dp);
2424
printk(KERN_ERR PFX "%s: BUG! Tx Ring full when queue awake!\n",
2525
dev->name);
26-
return 1;
26+
return NETDEV_TX_BUSY;
2727
}
2828

2929
... queue packet to card ...
@@ -35,6 +35,7 @@ Transmit path guidelines:
3535
...
3636
unlock_tx(dp);
3737
...
38+
return NETDEV_TX_OK;
3839
}
3940

4041
And then at the end of your TX reclamation event handling:
@@ -61,18 +62,19 @@ Transmit path guidelines:
6162
2) An ndo_start_xmit method must not modify the shared parts of a
6263
cloned SKB.
6364

64-
3) Do not forget that once you return 0 from your ndo_start_xmit
65-
method, it is your driver's responsibility to free up the SKB
66-
and in some finite amount of time.
65+
3) Do not forget that once you return NETDEV_TX_OK from your
66+
ndo_start_xmit method, it is your driver's responsibility to free
67+
up the SKB and in some finite amount of time.
6768

6869
For example, this means that it is not allowed for your TX
6970
mitigation scheme to let TX packets "hang out" in the TX
7071
ring unreclaimed forever if no new TX packets are sent.
7172
This error can deadlock sockets waiting for send buffer room
7273
to be freed up.
7374

74-
If you return 1 from the ndo_start_xmit method, you must not keep
75-
any reference to that SKB and you must not attempt to free it up.
75+
If you return NETDEV_TX_BUSY from the ndo_start_xmit method, you
76+
must not keep any reference to that SKB and you must not attempt
77+
to free it up.
7678

7779
Probing guidelines:
7880

0 commit comments

Comments
 (0)