aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/netdevice.h
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2010-06-15 11:31:06 -0400
committerPatrick McHardy <kaber@trash.net>2010-06-15 11:31:06 -0400
commitf9181f4ffc71d7b7dd1906c9a11d51d6659220ae (patch)
tree194f22e8216a1b9ee2c0dd019142202d73a7dc87 /include/linux/netdevice.h
parent0902b469bd25065aa0688c3cee6f11744c817e7c (diff)
parent1ab6c163dee279559e3a62d774af7e4c4c9b4c67 (diff)
Merge branch 'master' of /repos/git/net-next-2.6
Conflicts: include/net/netfilter/xt_rateest.h net/bridge/br_netfilter.c net/netfilter/nf_conntrack_core.c Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r--include/linux/netdevice.h108
1 files changed, 64 insertions, 44 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index a24916156f4e..4fbccc5f609a 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -159,45 +159,49 @@ static inline bool dev_xmit_complete(int rc)
159#define MAX_HEADER (LL_MAX_HEADER + 48) 159#define MAX_HEADER (LL_MAX_HEADER + 48)
160#endif 160#endif
161 161
162#endif /* __KERNEL__ */
163
164/* 162/*
165 * Network device statistics. Akin to the 2.0 ether stats but 163 * Old network device statistics. Fields are native words
166 * with byte counters. 164 * (unsigned long) so they can be read and written atomically.
165 * Each field is padded to 64 bits for compatibility with
166 * rtnl_link_stats64.
167 */ 167 */
168 168
169#if BITS_PER_LONG == 64
170#define NET_DEVICE_STATS_DEFINE(name) unsigned long name
171#elif defined(__LITTLE_ENDIAN)
172#define NET_DEVICE_STATS_DEFINE(name) unsigned long name, pad_ ## name
173#else
174#define NET_DEVICE_STATS_DEFINE(name) unsigned long pad_ ## name, name
175#endif
176
169struct net_device_stats { 177struct net_device_stats {
170 unsigned long rx_packets; /* total packets received */ 178 NET_DEVICE_STATS_DEFINE(rx_packets);
171 unsigned long tx_packets; /* total packets transmitted */ 179 NET_DEVICE_STATS_DEFINE(tx_packets);
172 unsigned long rx_bytes; /* total bytes received */ 180 NET_DEVICE_STATS_DEFINE(rx_bytes);
173 unsigned long tx_bytes; /* total bytes transmitted */ 181 NET_DEVICE_STATS_DEFINE(tx_bytes);
174 unsigned long rx_errors; /* bad packets received */ 182 NET_DEVICE_STATS_DEFINE(rx_errors);
175 unsigned long tx_errors; /* packet transmit problems */ 183 NET_DEVICE_STATS_DEFINE(tx_errors);
176 unsigned long rx_dropped; /* no space in linux buffers */ 184 NET_DEVICE_STATS_DEFINE(rx_dropped);
177 unsigned long tx_dropped; /* no space available in linux */ 185 NET_DEVICE_STATS_DEFINE(tx_dropped);
178 unsigned long multicast; /* multicast packets received */ 186 NET_DEVICE_STATS_DEFINE(multicast);
179 unsigned long collisions; 187 NET_DEVICE_STATS_DEFINE(collisions);
180 188 NET_DEVICE_STATS_DEFINE(rx_length_errors);
181 /* detailed rx_errors: */ 189 NET_DEVICE_STATS_DEFINE(rx_over_errors);
182 unsigned long rx_length_errors; 190 NET_DEVICE_STATS_DEFINE(rx_crc_errors);
183 unsigned long rx_over_errors; /* receiver ring buff overflow */ 191 NET_DEVICE_STATS_DEFINE(rx_frame_errors);
184 unsigned long rx_crc_errors; /* recved pkt with crc error */ 192 NET_DEVICE_STATS_DEFINE(rx_fifo_errors);
185 unsigned long rx_frame_errors; /* recv'd frame alignment error */ 193 NET_DEVICE_STATS_DEFINE(rx_missed_errors);
186 unsigned long rx_fifo_errors; /* recv'r fifo overrun */ 194 NET_DEVICE_STATS_DEFINE(tx_aborted_errors);
187 unsigned long rx_missed_errors; /* receiver missed packet */ 195 NET_DEVICE_STATS_DEFINE(tx_carrier_errors);
188 196 NET_DEVICE_STATS_DEFINE(tx_fifo_errors);
189 /* detailed tx_errors */ 197 NET_DEVICE_STATS_DEFINE(tx_heartbeat_errors);
190 unsigned long tx_aborted_errors; 198 NET_DEVICE_STATS_DEFINE(tx_window_errors);
191 unsigned long tx_carrier_errors; 199 NET_DEVICE_STATS_DEFINE(rx_compressed);
192 unsigned long tx_fifo_errors; 200 NET_DEVICE_STATS_DEFINE(tx_compressed);
193 unsigned long tx_heartbeat_errors;
194 unsigned long tx_window_errors;
195
196 /* for cslip etc */
197 unsigned long rx_compressed;
198 unsigned long tx_compressed;
199}; 201};
200 202
203#endif /* __KERNEL__ */
204
201 205
202/* Media selection options. */ 206/* Media selection options. */
203enum { 207enum {
@@ -381,6 +385,8 @@ enum gro_result {
381}; 385};
382typedef enum gro_result gro_result_t; 386typedef enum gro_result gro_result_t;
383 387
388typedef struct sk_buff *rx_handler_func_t(struct sk_buff *skb);
389
384extern void __napi_schedule(struct napi_struct *n); 390extern void __napi_schedule(struct napi_struct *n);
385 391
386static inline int napi_disable_pending(struct napi_struct *n) 392static inline int napi_disable_pending(struct napi_struct *n)
@@ -660,10 +666,19 @@ struct netdev_rx_queue {
660 * Callback uses when the transmitter has not made any progress 666 * Callback uses when the transmitter has not made any progress
661 * for dev->watchdog ticks. 667 * for dev->watchdog ticks.
662 * 668 *
669 * struct rtnl_link_stats64* (*ndo_get_stats64)(struct net_device *dev);
663 * struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); 670 * struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
664 * Called when a user wants to get the network device usage 671 * Called when a user wants to get the network device usage
665 * statistics. If not defined, the counters in dev->stats will 672 * statistics. Drivers must do one of the following:
666 * be used. 673 * 1. Define @ndo_get_stats64 to update a rtnl_link_stats64 structure
674 * (which should normally be dev->stats64) and return a ponter to
675 * it. The structure must not be changed asynchronously.
676 * 2. Define @ndo_get_stats to update a net_device_stats64 structure
677 * (which should normally be dev->stats) and return a pointer to
678 * it. The structure may be changed asynchronously only if each
679 * field is written atomically.
680 * 3. Update dev->stats asynchronously and atomically, and define
681 * neither operation.
667 * 682 *
668 * void (*ndo_vlan_rx_register)(struct net_device *dev, struct vlan_group *grp); 683 * void (*ndo_vlan_rx_register)(struct net_device *dev, struct vlan_group *grp);
669 * If device support VLAN receive accleration 684 * If device support VLAN receive accleration
@@ -718,6 +733,7 @@ struct net_device_ops {
718 struct neigh_parms *); 733 struct neigh_parms *);
719 void (*ndo_tx_timeout) (struct net_device *dev); 734 void (*ndo_tx_timeout) (struct net_device *dev);
720 735
736 struct rtnl_link_stats64* (*ndo_get_stats64)(struct net_device *dev);
721 struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); 737 struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
722 738
723 void (*ndo_vlan_rx_register)(struct net_device *dev, 739 void (*ndo_vlan_rx_register)(struct net_device *dev,
@@ -867,7 +883,10 @@ struct net_device {
867 int ifindex; 883 int ifindex;
868 int iflink; 884 int iflink;
869 885
870 struct net_device_stats stats; 886 union {
887 struct rtnl_link_stats64 stats64;
888 struct net_device_stats stats;
889 };
871 890
872#ifdef CONFIG_WIRELESS_EXT 891#ifdef CONFIG_WIRELESS_EXT
873 /* List of functions to handle Wireless Extensions (instead of ioctl). 892 /* List of functions to handle Wireless Extensions (instead of ioctl).
@@ -957,6 +976,7 @@ struct net_device {
957#endif 976#endif
958 977
959 struct netdev_queue rx_queue; 978 struct netdev_queue rx_queue;
979 rx_handler_func_t *rx_handler;
960 980
961 struct netdev_queue *_tx ____cacheline_aligned_in_smp; 981 struct netdev_queue *_tx ____cacheline_aligned_in_smp;
962 982
@@ -1087,11 +1107,7 @@ static inline void netdev_for_each_tx_queue(struct net_device *dev,
1087static inline 1107static inline
1088struct net *dev_net(const struct net_device *dev) 1108struct net *dev_net(const struct net_device *dev)
1089{ 1109{
1090#ifdef CONFIG_NET_NS 1110 return read_pnet(&dev->nd_net);
1091 return dev->nd_net;
1092#else
1093 return &init_net;
1094#endif
1095} 1111}
1096 1112
1097static inline 1113static inline
@@ -1272,8 +1288,8 @@ extern void dev_add_pack(struct packet_type *pt);
1272extern void dev_remove_pack(struct packet_type *pt); 1288extern void dev_remove_pack(struct packet_type *pt);
1273extern void __dev_remove_pack(struct packet_type *pt); 1289extern void __dev_remove_pack(struct packet_type *pt);
1274 1290
1275extern struct net_device *dev_get_by_flags(struct net *net, unsigned short flags, 1291extern struct net_device *dev_get_by_flags_rcu(struct net *net, unsigned short flags,
1276 unsigned short mask); 1292 unsigned short mask);
1277extern struct net_device *dev_get_by_name(struct net *net, const char *name); 1293extern struct net_device *dev_get_by_name(struct net *net, const char *name);
1278extern struct net_device *dev_get_by_name_rcu(struct net *net, const char *name); 1294extern struct net_device *dev_get_by_name_rcu(struct net *net, const char *name);
1279extern struct net_device *__dev_get_by_name(struct net *net, const char *name); 1295extern struct net_device *__dev_get_by_name(struct net *net, const char *name);
@@ -1693,6 +1709,10 @@ static inline void napi_free_frags(struct napi_struct *napi)
1693 napi->skb = NULL; 1709 napi->skb = NULL;
1694} 1710}
1695 1711
1712extern int netdev_rx_handler_register(struct net_device *dev,
1713 rx_handler_func_t *rx_handler);
1714extern void netdev_rx_handler_unregister(struct net_device *dev);
1715
1696extern void netif_nit_deliver(struct sk_buff *skb); 1716extern void netif_nit_deliver(struct sk_buff *skb);
1697extern int dev_valid_name(const char *name); 1717extern int dev_valid_name(const char *name);
1698extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); 1718extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *);
@@ -2118,7 +2138,7 @@ extern void netdev_features_change(struct net_device *dev);
2118/* Load a device via the kmod */ 2138/* Load a device via the kmod */
2119extern void dev_load(struct net *net, const char *name); 2139extern void dev_load(struct net *net, const char *name);
2120extern void dev_mcast_init(void); 2140extern void dev_mcast_init(void);
2121extern const struct net_device_stats *dev_get_stats(struct net_device *dev); 2141extern const struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev);
2122extern void dev_txq_stats_fold(const struct net_device *dev, struct net_device_stats *stats); 2142extern void dev_txq_stats_fold(const struct net_device *dev, struct net_device_stats *stats);
2123 2143
2124extern int netdev_max_backlog; 2144extern int netdev_max_backlog;