Skip to content

Commit

Permalink
doc, net: Update ndo_start_xmit return type and values
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Ben Hutchings authored and davem330 committed Apr 6, 2012
1 parent de7aca1 commit e34fac1
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions Documentation/networking/driver.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ Document about softnet driver issues

Transmit path guidelines:

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

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

static int drv_hard_start_xmit(struct sk_buff *skb,
struct net_device *dev)
static netdev_tx_t drv_hard_start_xmit(struct sk_buff *skb,
struct net_device *dev)
{
struct drv *dp = netdev_priv(dev);

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

... queue packet to card ...
Expand All @@ -35,6 +35,7 @@ Transmit path guidelines:
...
unlock_tx(dp);
...
return NETDEV_TX_OK;
}

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

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

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

If you return 1 from the ndo_start_xmit method, you must not keep
any reference to that SKB and you must not attempt to free it up.
If you return NETDEV_TX_BUSY from the ndo_start_xmit method, you
must not keep any reference to that SKB and you must not attempt
to free it up.

Probing guidelines:

Expand Down

0 comments on commit e34fac1

Please sign in to comment.