aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/netdevice.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r--include/linux/netdevice.h169
1 files changed, 98 insertions, 71 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index b21e4054c12c..46c36ffe20ee 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -54,6 +54,7 @@
54 54
55struct vlan_group; 55struct vlan_group;
56struct netpoll_info; 56struct netpoll_info;
57struct phy_device;
57/* 802.11 specific */ 58/* 802.11 specific */
58struct wireless_dev; 59struct wireless_dev;
59 /* source back-compat hooks */ 60 /* source back-compat hooks */
@@ -65,6 +66,11 @@ struct wireless_dev;
65#define HAVE_FREE_NETDEV /* free_netdev() */ 66#define HAVE_FREE_NETDEV /* free_netdev() */
66#define HAVE_NETDEV_PRIV /* netdev_priv() */ 67#define HAVE_NETDEV_PRIV /* netdev_priv() */
67 68
69/* hardware address assignment types */
70#define NET_ADDR_PERM 0 /* address is permanent (default) */
71#define NET_ADDR_RANDOM 1 /* address is generated randomly */
72#define NET_ADDR_STOLEN 2 /* address is stolen from other device */
73
68/* Backlog congestion levels */ 74/* Backlog congestion levels */
69#define NET_RX_SUCCESS 0 /* keep 'em coming, baby */ 75#define NET_RX_SUCCESS 0 /* keep 'em coming, baby */
70#define NET_RX_DROP 1 /* packet dropped */ 76#define NET_RX_DROP 1 /* packet dropped */
@@ -159,45 +165,39 @@ static inline bool dev_xmit_complete(int rc)
159#define MAX_HEADER (LL_MAX_HEADER + 48) 165#define MAX_HEADER (LL_MAX_HEADER + 48)
160#endif 166#endif
161 167
162#endif /* __KERNEL__ */
163
164/* 168/*
165 * Network device statistics. Akin to the 2.0 ether stats but 169 * Old network device statistics. Fields are native words
166 * with byte counters. 170 * (unsigned long) so they can be read and written atomically.
167 */ 171 */
168 172
169struct net_device_stats { 173struct net_device_stats {
170 unsigned long rx_packets; /* total packets received */ 174 unsigned long rx_packets;
171 unsigned long tx_packets; /* total packets transmitted */ 175 unsigned long tx_packets;
172 unsigned long rx_bytes; /* total bytes received */ 176 unsigned long rx_bytes;
173 unsigned long tx_bytes; /* total bytes transmitted */ 177 unsigned long tx_bytes;
174 unsigned long rx_errors; /* bad packets received */ 178 unsigned long rx_errors;
175 unsigned long tx_errors; /* packet transmit problems */ 179 unsigned long tx_errors;
176 unsigned long rx_dropped; /* no space in linux buffers */ 180 unsigned long rx_dropped;
177 unsigned long tx_dropped; /* no space available in linux */ 181 unsigned long tx_dropped;
178 unsigned long multicast; /* multicast packets received */ 182 unsigned long multicast;
179 unsigned long collisions; 183 unsigned long collisions;
180
181 /* detailed rx_errors: */
182 unsigned long rx_length_errors; 184 unsigned long rx_length_errors;
183 unsigned long rx_over_errors; /* receiver ring buff overflow */ 185 unsigned long rx_over_errors;
184 unsigned long rx_crc_errors; /* recved pkt with crc error */ 186 unsigned long rx_crc_errors;
185 unsigned long rx_frame_errors; /* recv'd frame alignment error */ 187 unsigned long rx_frame_errors;
186 unsigned long rx_fifo_errors; /* recv'r fifo overrun */ 188 unsigned long rx_fifo_errors;
187 unsigned long rx_missed_errors; /* receiver missed packet */ 189 unsigned long rx_missed_errors;
188
189 /* detailed tx_errors */
190 unsigned long tx_aborted_errors; 190 unsigned long tx_aborted_errors;
191 unsigned long tx_carrier_errors; 191 unsigned long tx_carrier_errors;
192 unsigned long tx_fifo_errors; 192 unsigned long tx_fifo_errors;
193 unsigned long tx_heartbeat_errors; 193 unsigned long tx_heartbeat_errors;
194 unsigned long tx_window_errors; 194 unsigned long tx_window_errors;
195
196 /* for cslip etc */
197 unsigned long rx_compressed; 195 unsigned long rx_compressed;
198 unsigned long tx_compressed; 196 unsigned long tx_compressed;
199}; 197};
200 198
199#endif /* __KERNEL__ */
200
201 201
202/* Media selection options. */ 202/* Media selection options. */
203enum { 203enum {
@@ -381,6 +381,8 @@ enum gro_result {
381}; 381};
382typedef enum gro_result gro_result_t; 382typedef enum gro_result gro_result_t;
383 383
384typedef struct sk_buff *rx_handler_func_t(struct sk_buff *skb);
385
384extern void __napi_schedule(struct napi_struct *n); 386extern void __napi_schedule(struct napi_struct *n);
385 387
386static inline int napi_disable_pending(struct napi_struct *n) 388static inline int napi_disable_pending(struct napi_struct *n)
@@ -504,9 +506,9 @@ struct netdev_queue {
504 * please use this field instead of dev->trans_start 506 * please use this field instead of dev->trans_start
505 */ 507 */
506 unsigned long trans_start; 508 unsigned long trans_start;
507 unsigned long tx_bytes; 509 u64 tx_bytes;
508 unsigned long tx_packets; 510 u64 tx_packets;
509 unsigned long tx_dropped; 511 u64 tx_dropped;
510} ____cacheline_aligned_in_smp; 512} ____cacheline_aligned_in_smp;
511 513
512#ifdef CONFIG_RPS 514#ifdef CONFIG_RPS
@@ -660,10 +662,19 @@ struct netdev_rx_queue {
660 * Callback uses when the transmitter has not made any progress 662 * Callback uses when the transmitter has not made any progress
661 * for dev->watchdog ticks. 663 * for dev->watchdog ticks.
662 * 664 *
665 * struct rtnl_link_stats64* (*ndo_get_stats64)(struct net_device *dev,
666 * struct rtnl_link_stats64 *storage);
663 * struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); 667 * struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
664 * Called when a user wants to get the network device usage 668 * Called when a user wants to get the network device usage
665 * statistics. If not defined, the counters in dev->stats will 669 * statistics. Drivers must do one of the following:
666 * be used. 670 * 1. Define @ndo_get_stats64 to fill in a zero-initialised
671 * rtnl_link_stats64 structure passed by the caller.
672 * 2. Define @ndo_get_stats to update a net_device_stats structure
673 * (which should normally be dev->stats) and return a pointer to
674 * it. The structure may be changed asynchronously only if each
675 * field is written atomically.
676 * 3. Update dev->stats asynchronously and atomically, and define
677 * neither operation.
667 * 678 *
668 * void (*ndo_vlan_rx_register)(struct net_device *dev, struct vlan_group *grp); 679 * void (*ndo_vlan_rx_register)(struct net_device *dev, struct vlan_group *grp);
669 * If device support VLAN receive accleration 680 * If device support VLAN receive accleration
@@ -718,6 +729,8 @@ struct net_device_ops {
718 struct neigh_parms *); 729 struct neigh_parms *);
719 void (*ndo_tx_timeout) (struct net_device *dev); 730 void (*ndo_tx_timeout) (struct net_device *dev);
720 731
732 struct rtnl_link_stats64* (*ndo_get_stats64)(struct net_device *dev,
733 struct rtnl_link_stats64 *storage);
721 struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); 734 struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
722 735
723 void (*ndo_vlan_rx_register)(struct net_device *dev, 736 void (*ndo_vlan_rx_register)(struct net_device *dev,
@@ -728,6 +741,8 @@ struct net_device_ops {
728 unsigned short vid); 741 unsigned short vid);
729#ifdef CONFIG_NET_POLL_CONTROLLER 742#ifdef CONFIG_NET_POLL_CONTROLLER
730 void (*ndo_poll_controller)(struct net_device *dev); 743 void (*ndo_poll_controller)(struct net_device *dev);
744 int (*ndo_netpoll_setup)(struct net_device *dev,
745 struct netpoll_info *info);
731 void (*ndo_netpoll_cleanup)(struct net_device *dev); 746 void (*ndo_netpoll_cleanup)(struct net_device *dev);
732#endif 747#endif
733 int (*ndo_set_vf_mac)(struct net_device *dev, 748 int (*ndo_set_vf_mac)(struct net_device *dev,
@@ -775,11 +790,11 @@ struct net_device {
775 /* 790 /*
776 * This is the first field of the "visible" part of this structure 791 * This is the first field of the "visible" part of this structure
777 * (i.e. as seen by users in the "Space.c" file). It is the name 792 * (i.e. as seen by users in the "Space.c" file). It is the name
778 * the interface. 793 * of the interface.
779 */ 794 */
780 char name[IFNAMSIZ]; 795 char name[IFNAMSIZ];
781 796
782 struct pm_qos_request_list *pm_qos_req; 797 struct pm_qos_request_list pm_qos_req;
783 798
784 /* device name hash chain */ 799 /* device name hash chain */
785 struct hlist_node name_hlist; 800 struct hlist_node name_hlist;
@@ -847,7 +862,8 @@ struct net_device {
847#define NETIF_F_FSO (SKB_GSO_FCOE << NETIF_F_GSO_SHIFT) 862#define NETIF_F_FSO (SKB_GSO_FCOE << NETIF_F_GSO_SHIFT)
848 863
849 /* List of features with software fallbacks. */ 864 /* List of features with software fallbacks. */
850#define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6) 865#define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | \
866 NETIF_F_TSO6 | NETIF_F_UFO)
851 867
852 868
853#define NETIF_F_GEN_CSUM (NETIF_F_NO_CSUM | NETIF_F_HW_CSUM) 869#define NETIF_F_GEN_CSUM (NETIF_F_NO_CSUM | NETIF_F_HW_CSUM)
@@ -908,6 +924,7 @@ struct net_device {
908 924
909 /* Interface address info. */ 925 /* Interface address info. */
910 unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */ 926 unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */
927 unsigned char addr_assign_type; /* hw address assignment type */
911 unsigned char addr_len; /* hardware address length */ 928 unsigned char addr_len; /* hardware address length */
912 unsigned short dev_id; /* for shared network cards */ 929 unsigned short dev_id; /* for shared network cards */
913 930
@@ -957,6 +974,8 @@ struct net_device {
957#endif 974#endif
958 975
959 struct netdev_queue rx_queue; 976 struct netdev_queue rx_queue;
977 rx_handler_func_t *rx_handler;
978 void *rx_handler_data;
960 979
961 struct netdev_queue *_tx ____cacheline_aligned_in_smp; 980 struct netdev_queue *_tx ____cacheline_aligned_in_smp;
962 981
@@ -1024,10 +1043,6 @@ struct net_device {
1024 /* mid-layer private */ 1043 /* mid-layer private */
1025 void *ml_priv; 1044 void *ml_priv;
1026 1045
1027 /* bridge stuff */
1028 struct net_bridge_port *br_port;
1029 /* macvlan */
1030 struct macvlan_port *macvlan_port;
1031 /* GARP */ 1046 /* GARP */
1032 struct garp_port *garp_port; 1047 struct garp_port *garp_port;
1033 1048
@@ -1057,6 +1072,9 @@ struct net_device {
1057#endif 1072#endif
1058 /* n-tuple filter list attached to this device */ 1073 /* n-tuple filter list attached to this device */
1059 struct ethtool_rx_ntuple_list ethtool_ntuple_list; 1074 struct ethtool_rx_ntuple_list ethtool_ntuple_list;
1075
1076 /* phy device may attach itself for hardware timestamping */
1077 struct phy_device *phydev;
1060}; 1078};
1061#define to_net_dev(d) container_of(d, struct net_device, dev) 1079#define to_net_dev(d) container_of(d, struct net_device, dev)
1062 1080
@@ -1087,11 +1105,7 @@ static inline void netdev_for_each_tx_queue(struct net_device *dev,
1087static inline 1105static inline
1088struct net *dev_net(const struct net_device *dev) 1106struct net *dev_net(const struct net_device *dev)
1089{ 1107{
1090#ifdef CONFIG_NET_NS 1108 return read_pnet(&dev->nd_net);
1091 return dev->nd_net;
1092#else
1093 return &init_net;
1094#endif
1095} 1109}
1096 1110
1097static inline 1111static inline
@@ -1272,8 +1286,8 @@ extern void dev_add_pack(struct packet_type *pt);
1272extern void dev_remove_pack(struct packet_type *pt); 1286extern void dev_remove_pack(struct packet_type *pt);
1273extern void __dev_remove_pack(struct packet_type *pt); 1287extern void __dev_remove_pack(struct packet_type *pt);
1274 1288
1275extern struct net_device *dev_get_by_flags(struct net *net, unsigned short flags, 1289extern struct net_device *dev_get_by_flags_rcu(struct net *net, unsigned short flags,
1276 unsigned short mask); 1290 unsigned short mask);
1277extern struct net_device *dev_get_by_name(struct net *net, const char *name); 1291extern 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); 1292extern 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); 1293extern struct net_device *__dev_get_by_name(struct net *net, const char *name);
@@ -1696,6 +1710,11 @@ static inline void napi_free_frags(struct napi_struct *napi)
1696 napi->skb = NULL; 1710 napi->skb = NULL;
1697} 1711}
1698 1712
1713extern int netdev_rx_handler_register(struct net_device *dev,
1714 rx_handler_func_t *rx_handler,
1715 void *rx_handler_data);
1716extern void netdev_rx_handler_unregister(struct net_device *dev);
1717
1699extern void netif_nit_deliver(struct sk_buff *skb); 1718extern void netif_nit_deliver(struct sk_buff *skb);
1700extern int dev_valid_name(const char *name); 1719extern int dev_valid_name(const char *name);
1701extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); 1720extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *);
@@ -1775,6 +1794,8 @@ extern void netif_carrier_on(struct net_device *dev);
1775 1794
1776extern void netif_carrier_off(struct net_device *dev); 1795extern void netif_carrier_off(struct net_device *dev);
1777 1796
1797extern void netif_notify_peers(struct net_device *dev);
1798
1778/** 1799/**
1779 * netif_dormant_on - mark device as dormant. 1800 * netif_dormant_on - mark device as dormant.
1780 * @dev: network device 1801 * @dev: network device
@@ -2119,8 +2140,10 @@ extern void netdev_features_change(struct net_device *dev);
2119/* Load a device via the kmod */ 2140/* Load a device via the kmod */
2120extern void dev_load(struct net *net, const char *name); 2141extern void dev_load(struct net *net, const char *name);
2121extern void dev_mcast_init(void); 2142extern void dev_mcast_init(void);
2122extern const struct net_device_stats *dev_get_stats(struct net_device *dev); 2143extern struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
2123extern void dev_txq_stats_fold(const struct net_device *dev, struct net_device_stats *stats); 2144 struct rtnl_link_stats64 *storage);
2145extern void dev_txq_stats_fold(const struct net_device *dev,
2146 struct rtnl_link_stats64 *stats);
2124 2147
2125extern int netdev_max_backlog; 2148extern int netdev_max_backlog;
2126extern int netdev_tstamp_prequeue; 2149extern int netdev_tstamp_prequeue;
@@ -2230,25 +2253,23 @@ static inline const char *netdev_name(const struct net_device *dev)
2230 return dev->name; 2253 return dev->name;
2231} 2254}
2232 2255
2233#define netdev_printk(level, netdev, format, args...) \ 2256extern int netdev_printk(const char *level, const struct net_device *dev,
2234 dev_printk(level, (netdev)->dev.parent, \ 2257 const char *format, ...)
2235 "%s: " format, \ 2258 __attribute__ ((format (printf, 3, 4)));
2236 netdev_name(netdev), ##args) 2259extern int netdev_emerg(const struct net_device *dev, const char *format, ...)
2237 2260 __attribute__ ((format (printf, 2, 3)));
2238#define netdev_emerg(dev, format, args...) \ 2261extern int netdev_alert(const struct net_device *dev, const char *format, ...)
2239 netdev_printk(KERN_EMERG, dev, format, ##args) 2262 __attribute__ ((format (printf, 2, 3)));
2240#define netdev_alert(dev, format, args...) \ 2263extern int netdev_crit(const struct net_device *dev, const char *format, ...)
2241 netdev_printk(KERN_ALERT, dev, format, ##args) 2264 __attribute__ ((format (printf, 2, 3)));
2242#define netdev_crit(dev, format, args...) \ 2265extern int netdev_err(const struct net_device *dev, const char *format, ...)
2243 netdev_printk(KERN_CRIT, dev, format, ##args) 2266 __attribute__ ((format (printf, 2, 3)));
2244#define netdev_err(dev, format, args...) \ 2267extern int netdev_warn(const struct net_device *dev, const char *format, ...)
2245 netdev_printk(KERN_ERR, dev, format, ##args) 2268 __attribute__ ((format (printf, 2, 3)));
2246#define netdev_warn(dev, format, args...) \ 2269extern int netdev_notice(const struct net_device *dev, const char *format, ...)
2247 netdev_printk(KERN_WARNING, dev, format, ##args) 2270 __attribute__ ((format (printf, 2, 3)));
2248#define netdev_notice(dev, format, args...) \ 2271extern int netdev_info(const struct net_device *dev, const char *format, ...)
2249 netdev_printk(KERN_NOTICE, dev, format, ##args) 2272 __attribute__ ((format (printf, 2, 3)));
2250#define netdev_info(dev, format, args...) \
2251 netdev_printk(KERN_INFO, dev, format, ##args)
2252 2273
2253#if defined(DEBUG) 2274#if defined(DEBUG)
2254#define netdev_dbg(__dev, format, args...) \ 2275#define netdev_dbg(__dev, format, args...) \
@@ -2296,20 +2317,26 @@ do { \
2296 netdev_printk(level, (dev), fmt, ##args); \ 2317 netdev_printk(level, (dev), fmt, ##args); \
2297} while (0) 2318} while (0)
2298 2319
2320#define netif_level(level, priv, type, dev, fmt, args...) \
2321do { \
2322 if (netif_msg_##type(priv)) \
2323 netdev_##level(dev, fmt, ##args); \
2324} while (0)
2325
2299#define netif_emerg(priv, type, dev, fmt, args...) \ 2326#define netif_emerg(priv, type, dev, fmt, args...) \
2300 netif_printk(priv, type, KERN_EMERG, dev, fmt, ##args) 2327 netif_level(emerg, priv, type, dev, fmt, ##args)
2301#define netif_alert(priv, type, dev, fmt, args...) \ 2328#define netif_alert(priv, type, dev, fmt, args...) \
2302 netif_printk(priv, type, KERN_ALERT, dev, fmt, ##args) 2329 netif_level(alert, priv, type, dev, fmt, ##args)
2303#define netif_crit(priv, type, dev, fmt, args...) \ 2330#define netif_crit(priv, type, dev, fmt, args...) \
2304 netif_printk(priv, type, KERN_CRIT, dev, fmt, ##args) 2331 netif_level(crit, priv, type, dev, fmt, ##args)
2305#define netif_err(priv, type, dev, fmt, args...) \ 2332#define netif_err(priv, type, dev, fmt, args...) \
2306 netif_printk(priv, type, KERN_ERR, dev, fmt, ##args) 2333 netif_level(err, priv, type, dev, fmt, ##args)
2307#define netif_warn(priv, type, dev, fmt, args...) \ 2334#define netif_warn(priv, type, dev, fmt, args...) \
2308 netif_printk(priv, type, KERN_WARNING, dev, fmt, ##args) 2335 netif_level(warn, priv, type, dev, fmt, ##args)
2309#define netif_notice(priv, type, dev, fmt, args...) \ 2336#define netif_notice(priv, type, dev, fmt, args...) \
2310 netif_printk(priv, type, KERN_NOTICE, dev, fmt, ##args) 2337 netif_level(notice, priv, type, dev, fmt, ##args)
2311#define netif_info(priv, type, dev, fmt, args...) \ 2338#define netif_info(priv, type, dev, fmt, args...) \
2312 netif_printk(priv, type, KERN_INFO, (dev), fmt, ##args) 2339 netif_level(info, priv, type, dev, fmt, ##args)
2313 2340
2314#if defined(DEBUG) 2341#if defined(DEBUG)
2315#define netif_dbg(priv, type, dev, format, args...) \ 2342#define netif_dbg(priv, type, dev, format, args...) \