diff options
author | Patrick McHardy <kaber@trash.net> | 2009-11-10 01:14:14 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-13 17:07:32 -0500 |
commit | 572a9d7b6fc7f20f573664063324c086be310c42 (patch) | |
tree | 0ab3655fdfa923b0b9c6c1ee51a2e31e97e9549f /include/linux/netdevice.h | |
parent | 9ea2bdab11da97b2ac6f87d79976d25fa6d27295 (diff) |
net: allow to propagate errors through ->ndo_hard_start_xmit()
Currently the ->ndo_hard_start_xmit() callbacks are only permitted to return
one of the NETDEV_TX codes. This prevents any kind of error propagation for
virtual devices, like queue congestion of the underlying device in case of
layered devices, or unreachability in case of tunnels.
This patches changes the NET_XMIT codes to avoid clashes with the NETDEV_TX
codes and changes the two callers of dev_hard_start_xmit() to expect either
errno codes, NET_XMIT codes or NETDEV_TX codes as return value.
In case of qdisc_restart(), all non NETDEV_TX codes are mapped to NETDEV_TX_OK
since no error propagation is possible when using qdiscs. In case of
dev_queue_xmit(), the error is propagated upwards.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r-- | include/linux/netdevice.h | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 083b5989cecb..8b266390b9e2 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -63,27 +63,48 @@ struct wireless_dev; | |||
63 | #define HAVE_FREE_NETDEV /* free_netdev() */ | 63 | #define HAVE_FREE_NETDEV /* free_netdev() */ |
64 | #define HAVE_NETDEV_PRIV /* netdev_priv() */ | 64 | #define HAVE_NETDEV_PRIV /* netdev_priv() */ |
65 | 65 | ||
66 | #define NET_XMIT_SUCCESS 0 | 66 | /* |
67 | #define NET_XMIT_DROP 1 /* skb dropped */ | 67 | * Transmit return codes: transmit return codes originate from three different |
68 | #define NET_XMIT_CN 2 /* congestion notification */ | 68 | * namespaces: |
69 | #define NET_XMIT_POLICED 3 /* skb is shot by police */ | 69 | * |
70 | #define NET_XMIT_MASK 0xFFFF /* qdisc flags in net/sch_generic.h */ | 70 | * - qdisc return codes |
71 | * - driver transmit return codes | ||
72 | * - errno values | ||
73 | * | ||
74 | * Drivers are allowed to return any one of those in their hard_start_xmit() | ||
75 | * function. Real network devices commonly used with qdiscs should only return | ||
76 | * the driver transmit return codes though - when qdiscs are used, the actual | ||
77 | * transmission happens asynchronously, so the value is not propagated to | ||
78 | * higher layers. Virtual network devices transmit synchronously, in this case | ||
79 | * the driver transmit return codes are consumed by dev_queue_xmit(), all | ||
80 | * others are propagated to higher layers. | ||
81 | */ | ||
82 | |||
83 | /* qdisc ->enqueue() return codes. */ | ||
84 | #define NET_XMIT_SUCCESS 0x00 | ||
85 | #define NET_XMIT_DROP 0x10 /* skb dropped */ | ||
86 | #define NET_XMIT_CN 0x20 /* congestion notification */ | ||
87 | #define NET_XMIT_POLICED 0x30 /* skb is shot by police */ | ||
88 | #define NET_XMIT_MASK 0xf0 /* qdisc flags in net/sch_generic.h */ | ||
71 | 89 | ||
72 | /* Backlog congestion levels */ | 90 | /* Backlog congestion levels */ |
73 | #define NET_RX_SUCCESS 0 /* keep 'em coming, baby */ | 91 | #define NET_RX_SUCCESS 0 /* keep 'em coming, baby */ |
74 | #define NET_RX_DROP 1 /* packet dropped */ | 92 | #define NET_RX_DROP 1 /* packet dropped */ |
75 | 93 | ||
76 | /* NET_XMIT_CN is special. It does not guarantee that this packet is lost. It | 94 | /* NET_XMIT_CN is special. It does not guarantee that this packet is lost. It |
77 | * indicates that the device will soon be dropping packets, or already drops | 95 | * indicates that the device will soon be dropping packets, or already drops |
78 | * some packets of the same priority; prompting us to send less aggressively. */ | 96 | * some packets of the same priority; prompting us to send less aggressively. */ |
79 | #define net_xmit_eval(e) ((e) == NET_XMIT_CN? 0 : (e)) | 97 | #define net_xmit_eval(e) ((e) == NET_XMIT_CN ? 0 : (e)) |
80 | #define net_xmit_errno(e) ((e) != NET_XMIT_CN ? -ENOBUFS : 0) | 98 | #define net_xmit_errno(e) ((e) != NET_XMIT_CN ? -ENOBUFS : 0) |
81 | 99 | ||
82 | /* Driver transmit return codes */ | 100 | /* Driver transmit return codes */ |
101 | #define NETDEV_TX_MASK 0xf | ||
102 | |||
83 | enum netdev_tx { | 103 | enum netdev_tx { |
84 | NETDEV_TX_OK = 0, /* driver took care of packet */ | 104 | __NETDEV_TX_MIN = INT_MIN, /* make sure enum is signed */ |
85 | NETDEV_TX_BUSY, /* driver tx path was busy*/ | 105 | NETDEV_TX_OK = 0, /* driver took care of packet */ |
86 | NETDEV_TX_LOCKED = -1, /* driver tx lock was already taken */ | 106 | NETDEV_TX_BUSY = 1, /* driver tx path was busy*/ |
107 | NETDEV_TX_LOCKED = 2, /* driver tx lock was already taken */ | ||
87 | }; | 108 | }; |
88 | typedef enum netdev_tx netdev_tx_t; | 109 | typedef enum netdev_tx netdev_tx_t; |
89 | 110 | ||