diff options
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r-- | include/linux/netdevice.h | 166 |
1 files changed, 95 insertions, 71 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 256419583d9d..b6262898ece0 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -54,6 +54,7 @@ | |||
54 | 54 | ||
55 | struct vlan_group; | 55 | struct vlan_group; |
56 | struct netpoll_info; | 56 | struct netpoll_info; |
57 | struct phy_device; | ||
57 | /* 802.11 specific */ | 58 | /* 802.11 specific */ |
58 | struct wireless_dev; | 59 | struct wireless_dev; |
59 | /* source back-compat hooks */ | 60 | /* source back-compat hooks */ |
@@ -159,45 +160,39 @@ static inline bool dev_xmit_complete(int rc) | |||
159 | #define MAX_HEADER (LL_MAX_HEADER + 48) | 160 | #define MAX_HEADER (LL_MAX_HEADER + 48) |
160 | #endif | 161 | #endif |
161 | 162 | ||
162 | #endif /* __KERNEL__ */ | ||
163 | |||
164 | /* | 163 | /* |
165 | * Network device statistics. Akin to the 2.0 ether stats but | 164 | * Old network device statistics. Fields are native words |
166 | * with byte counters. | 165 | * (unsigned long) so they can be read and written atomically. |
167 | */ | 166 | */ |
168 | 167 | ||
169 | struct net_device_stats { | 168 | struct net_device_stats { |
170 | unsigned long rx_packets; /* total packets received */ | 169 | unsigned long rx_packets; |
171 | unsigned long tx_packets; /* total packets transmitted */ | 170 | unsigned long tx_packets; |
172 | unsigned long rx_bytes; /* total bytes received */ | 171 | unsigned long rx_bytes; |
173 | unsigned long tx_bytes; /* total bytes transmitted */ | 172 | unsigned long tx_bytes; |
174 | unsigned long rx_errors; /* bad packets received */ | 173 | unsigned long rx_errors; |
175 | unsigned long tx_errors; /* packet transmit problems */ | 174 | unsigned long tx_errors; |
176 | unsigned long rx_dropped; /* no space in linux buffers */ | 175 | unsigned long rx_dropped; |
177 | unsigned long tx_dropped; /* no space available in linux */ | 176 | unsigned long tx_dropped; |
178 | unsigned long multicast; /* multicast packets received */ | 177 | unsigned long multicast; |
179 | unsigned long collisions; | 178 | unsigned long collisions; |
180 | |||
181 | /* detailed rx_errors: */ | ||
182 | unsigned long rx_length_errors; | 179 | unsigned long rx_length_errors; |
183 | unsigned long rx_over_errors; /* receiver ring buff overflow */ | 180 | unsigned long rx_over_errors; |
184 | unsigned long rx_crc_errors; /* recved pkt with crc error */ | 181 | unsigned long rx_crc_errors; |
185 | unsigned long rx_frame_errors; /* recv'd frame alignment error */ | 182 | unsigned long rx_frame_errors; |
186 | unsigned long rx_fifo_errors; /* recv'r fifo overrun */ | 183 | unsigned long rx_fifo_errors; |
187 | unsigned long rx_missed_errors; /* receiver missed packet */ | 184 | unsigned long rx_missed_errors; |
188 | |||
189 | /* detailed tx_errors */ | ||
190 | unsigned long tx_aborted_errors; | 185 | unsigned long tx_aborted_errors; |
191 | unsigned long tx_carrier_errors; | 186 | unsigned long tx_carrier_errors; |
192 | unsigned long tx_fifo_errors; | 187 | unsigned long tx_fifo_errors; |
193 | unsigned long tx_heartbeat_errors; | 188 | unsigned long tx_heartbeat_errors; |
194 | unsigned long tx_window_errors; | 189 | unsigned long tx_window_errors; |
195 | |||
196 | /* for cslip etc */ | ||
197 | unsigned long rx_compressed; | 190 | unsigned long rx_compressed; |
198 | unsigned long tx_compressed; | 191 | unsigned long tx_compressed; |
199 | }; | 192 | }; |
200 | 193 | ||
194 | #endif /* __KERNEL__ */ | ||
195 | |||
201 | 196 | ||
202 | /* Media selection options. */ | 197 | /* Media selection options. */ |
203 | enum { | 198 | enum { |
@@ -381,6 +376,8 @@ enum gro_result { | |||
381 | }; | 376 | }; |
382 | typedef enum gro_result gro_result_t; | 377 | typedef enum gro_result gro_result_t; |
383 | 378 | ||
379 | typedef struct sk_buff *rx_handler_func_t(struct sk_buff *skb); | ||
380 | |||
384 | extern void __napi_schedule(struct napi_struct *n); | 381 | extern void __napi_schedule(struct napi_struct *n); |
385 | 382 | ||
386 | static inline int napi_disable_pending(struct napi_struct *n) | 383 | static inline int napi_disable_pending(struct napi_struct *n) |
@@ -504,9 +501,9 @@ struct netdev_queue { | |||
504 | * please use this field instead of dev->trans_start | 501 | * please use this field instead of dev->trans_start |
505 | */ | 502 | */ |
506 | unsigned long trans_start; | 503 | unsigned long trans_start; |
507 | unsigned long tx_bytes; | 504 | u64 tx_bytes; |
508 | unsigned long tx_packets; | 505 | u64 tx_packets; |
509 | unsigned long tx_dropped; | 506 | u64 tx_dropped; |
510 | } ____cacheline_aligned_in_smp; | 507 | } ____cacheline_aligned_in_smp; |
511 | 508 | ||
512 | #ifdef CONFIG_RPS | 509 | #ifdef CONFIG_RPS |
@@ -660,10 +657,19 @@ struct netdev_rx_queue { | |||
660 | * Callback uses when the transmitter has not made any progress | 657 | * Callback uses when the transmitter has not made any progress |
661 | * for dev->watchdog ticks. | 658 | * for dev->watchdog ticks. |
662 | * | 659 | * |
660 | * struct rtnl_link_stats64* (*ndo_get_stats64)(struct net_device *dev, | ||
661 | * struct rtnl_link_stats64 *storage); | ||
663 | * struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); | 662 | * struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); |
664 | * Called when a user wants to get the network device usage | 663 | * Called when a user wants to get the network device usage |
665 | * statistics. If not defined, the counters in dev->stats will | 664 | * statistics. Drivers must do one of the following: |
666 | * be used. | 665 | * 1. Define @ndo_get_stats64 to fill in a zero-initialised |
666 | * rtnl_link_stats64 structure passed by the caller. | ||
667 | * 2. Define @ndo_get_stats to update a net_device_stats structure | ||
668 | * (which should normally be dev->stats) and return a pointer to | ||
669 | * it. The structure may be changed asynchronously only if each | ||
670 | * field is written atomically. | ||
671 | * 3. Update dev->stats asynchronously and atomically, and define | ||
672 | * neither operation. | ||
667 | * | 673 | * |
668 | * void (*ndo_vlan_rx_register)(struct net_device *dev, struct vlan_group *grp); | 674 | * void (*ndo_vlan_rx_register)(struct net_device *dev, struct vlan_group *grp); |
669 | * If device support VLAN receive accleration | 675 | * If device support VLAN receive accleration |
@@ -718,6 +724,8 @@ struct net_device_ops { | |||
718 | struct neigh_parms *); | 724 | struct neigh_parms *); |
719 | void (*ndo_tx_timeout) (struct net_device *dev); | 725 | void (*ndo_tx_timeout) (struct net_device *dev); |
720 | 726 | ||
727 | struct rtnl_link_stats64* (*ndo_get_stats64)(struct net_device *dev, | ||
728 | struct rtnl_link_stats64 *storage); | ||
721 | struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); | 729 | struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); |
722 | 730 | ||
723 | void (*ndo_vlan_rx_register)(struct net_device *dev, | 731 | void (*ndo_vlan_rx_register)(struct net_device *dev, |
@@ -728,6 +736,8 @@ struct net_device_ops { | |||
728 | unsigned short vid); | 736 | unsigned short vid); |
729 | #ifdef CONFIG_NET_POLL_CONTROLLER | 737 | #ifdef CONFIG_NET_POLL_CONTROLLER |
730 | void (*ndo_poll_controller)(struct net_device *dev); | 738 | void (*ndo_poll_controller)(struct net_device *dev); |
739 | int (*ndo_netpoll_setup)(struct net_device *dev, | ||
740 | struct netpoll_info *info); | ||
731 | void (*ndo_netpoll_cleanup)(struct net_device *dev); | 741 | void (*ndo_netpoll_cleanup)(struct net_device *dev); |
732 | #endif | 742 | #endif |
733 | int (*ndo_set_vf_mac)(struct net_device *dev, | 743 | int (*ndo_set_vf_mac)(struct net_device *dev, |
@@ -847,7 +857,8 @@ struct net_device { | |||
847 | #define NETIF_F_FSO (SKB_GSO_FCOE << NETIF_F_GSO_SHIFT) | 857 | #define NETIF_F_FSO (SKB_GSO_FCOE << NETIF_F_GSO_SHIFT) |
848 | 858 | ||
849 | /* List of features with software fallbacks. */ | 859 | /* List of features with software fallbacks. */ |
850 | #define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6) | 860 | #define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | \ |
861 | NETIF_F_TSO6 | NETIF_F_UFO) | ||
851 | 862 | ||
852 | 863 | ||
853 | #define NETIF_F_GEN_CSUM (NETIF_F_NO_CSUM | NETIF_F_HW_CSUM) | 864 | #define NETIF_F_GEN_CSUM (NETIF_F_NO_CSUM | NETIF_F_HW_CSUM) |
@@ -957,6 +968,8 @@ struct net_device { | |||
957 | #endif | 968 | #endif |
958 | 969 | ||
959 | struct netdev_queue rx_queue; | 970 | struct netdev_queue rx_queue; |
971 | rx_handler_func_t *rx_handler; | ||
972 | void *rx_handler_data; | ||
960 | 973 | ||
961 | struct netdev_queue *_tx ____cacheline_aligned_in_smp; | 974 | struct netdev_queue *_tx ____cacheline_aligned_in_smp; |
962 | 975 | ||
@@ -1024,10 +1037,6 @@ struct net_device { | |||
1024 | /* mid-layer private */ | 1037 | /* mid-layer private */ |
1025 | void *ml_priv; | 1038 | void *ml_priv; |
1026 | 1039 | ||
1027 | /* bridge stuff */ | ||
1028 | struct net_bridge_port *br_port; | ||
1029 | /* macvlan */ | ||
1030 | struct macvlan_port *macvlan_port; | ||
1031 | /* GARP */ | 1040 | /* GARP */ |
1032 | struct garp_port *garp_port; | 1041 | struct garp_port *garp_port; |
1033 | 1042 | ||
@@ -1057,6 +1066,9 @@ struct net_device { | |||
1057 | #endif | 1066 | #endif |
1058 | /* n-tuple filter list attached to this device */ | 1067 | /* n-tuple filter list attached to this device */ |
1059 | struct ethtool_rx_ntuple_list ethtool_ntuple_list; | 1068 | struct ethtool_rx_ntuple_list ethtool_ntuple_list; |
1069 | |||
1070 | /* phy device may attach itself for hardware timestamping */ | ||
1071 | struct phy_device *phydev; | ||
1060 | }; | 1072 | }; |
1061 | #define to_net_dev(d) container_of(d, struct net_device, dev) | 1073 | #define to_net_dev(d) container_of(d, struct net_device, dev) |
1062 | 1074 | ||
@@ -1087,11 +1099,7 @@ static inline void netdev_for_each_tx_queue(struct net_device *dev, | |||
1087 | static inline | 1099 | static inline |
1088 | struct net *dev_net(const struct net_device *dev) | 1100 | struct net *dev_net(const struct net_device *dev) |
1089 | { | 1101 | { |
1090 | #ifdef CONFIG_NET_NS | 1102 | return read_pnet(&dev->nd_net); |
1091 | return dev->nd_net; | ||
1092 | #else | ||
1093 | return &init_net; | ||
1094 | #endif | ||
1095 | } | 1103 | } |
1096 | 1104 | ||
1097 | static inline | 1105 | static inline |
@@ -1272,8 +1280,8 @@ extern void dev_add_pack(struct packet_type *pt); | |||
1272 | extern void dev_remove_pack(struct packet_type *pt); | 1280 | extern void dev_remove_pack(struct packet_type *pt); |
1273 | extern void __dev_remove_pack(struct packet_type *pt); | 1281 | extern void __dev_remove_pack(struct packet_type *pt); |
1274 | 1282 | ||
1275 | extern struct net_device *dev_get_by_flags(struct net *net, unsigned short flags, | 1283 | extern struct net_device *dev_get_by_flags_rcu(struct net *net, unsigned short flags, |
1276 | unsigned short mask); | 1284 | unsigned short mask); |
1277 | extern struct net_device *dev_get_by_name(struct net *net, const char *name); | 1285 | extern struct net_device *dev_get_by_name(struct net *net, const char *name); |
1278 | extern struct net_device *dev_get_by_name_rcu(struct net *net, const char *name); | 1286 | extern struct net_device *dev_get_by_name_rcu(struct net *net, const char *name); |
1279 | extern struct net_device *__dev_get_by_name(struct net *net, const char *name); | 1287 | extern struct net_device *__dev_get_by_name(struct net *net, const char *name); |
@@ -1656,6 +1664,9 @@ static inline int netif_is_multiqueue(const struct net_device *dev) | |||
1656 | return (dev->num_tx_queues > 1); | 1664 | return (dev->num_tx_queues > 1); |
1657 | } | 1665 | } |
1658 | 1666 | ||
1667 | extern void netif_set_real_num_tx_queues(struct net_device *dev, | ||
1668 | unsigned int txq); | ||
1669 | |||
1659 | /* Use this variant when it is known for sure that it | 1670 | /* Use this variant when it is known for sure that it |
1660 | * is executing from hardware interrupt context or with hardware interrupts | 1671 | * is executing from hardware interrupt context or with hardware interrupts |
1661 | * disabled. | 1672 | * disabled. |
@@ -1693,6 +1704,11 @@ static inline void napi_free_frags(struct napi_struct *napi) | |||
1693 | napi->skb = NULL; | 1704 | napi->skb = NULL; |
1694 | } | 1705 | } |
1695 | 1706 | ||
1707 | extern int netdev_rx_handler_register(struct net_device *dev, | ||
1708 | rx_handler_func_t *rx_handler, | ||
1709 | void *rx_handler_data); | ||
1710 | extern void netdev_rx_handler_unregister(struct net_device *dev); | ||
1711 | |||
1696 | extern void netif_nit_deliver(struct sk_buff *skb); | 1712 | extern void netif_nit_deliver(struct sk_buff *skb); |
1697 | extern int dev_valid_name(const char *name); | 1713 | extern int dev_valid_name(const char *name); |
1698 | extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); | 1714 | extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); |
@@ -1772,6 +1788,8 @@ extern void netif_carrier_on(struct net_device *dev); | |||
1772 | 1788 | ||
1773 | extern void netif_carrier_off(struct net_device *dev); | 1789 | extern void netif_carrier_off(struct net_device *dev); |
1774 | 1790 | ||
1791 | extern void netif_notify_peers(struct net_device *dev); | ||
1792 | |||
1775 | /** | 1793 | /** |
1776 | * netif_dormant_on - mark device as dormant. | 1794 | * netif_dormant_on - mark device as dormant. |
1777 | * @dev: network device | 1795 | * @dev: network device |
@@ -2116,8 +2134,10 @@ extern void netdev_features_change(struct net_device *dev); | |||
2116 | /* Load a device via the kmod */ | 2134 | /* Load a device via the kmod */ |
2117 | extern void dev_load(struct net *net, const char *name); | 2135 | extern void dev_load(struct net *net, const char *name); |
2118 | extern void dev_mcast_init(void); | 2136 | extern void dev_mcast_init(void); |
2119 | extern const struct net_device_stats *dev_get_stats(struct net_device *dev); | 2137 | extern struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev, |
2120 | extern void dev_txq_stats_fold(const struct net_device *dev, struct net_device_stats *stats); | 2138 | struct rtnl_link_stats64 *storage); |
2139 | extern void dev_txq_stats_fold(const struct net_device *dev, | ||
2140 | struct rtnl_link_stats64 *stats); | ||
2121 | 2141 | ||
2122 | extern int netdev_max_backlog; | 2142 | extern int netdev_max_backlog; |
2123 | extern int netdev_tstamp_prequeue; | 2143 | extern int netdev_tstamp_prequeue; |
@@ -2227,25 +2247,23 @@ static inline const char *netdev_name(const struct net_device *dev) | |||
2227 | return dev->name; | 2247 | return dev->name; |
2228 | } | 2248 | } |
2229 | 2249 | ||
2230 | #define netdev_printk(level, netdev, format, args...) \ | 2250 | extern int netdev_printk(const char *level, const struct net_device *dev, |
2231 | dev_printk(level, (netdev)->dev.parent, \ | 2251 | const char *format, ...) |
2232 | "%s: " format, \ | 2252 | __attribute__ ((format (printf, 3, 4))); |
2233 | netdev_name(netdev), ##args) | 2253 | extern int netdev_emerg(const struct net_device *dev, const char *format, ...) |
2234 | 2254 | __attribute__ ((format (printf, 2, 3))); | |
2235 | #define netdev_emerg(dev, format, args...) \ | 2255 | extern int netdev_alert(const struct net_device *dev, const char *format, ...) |
2236 | netdev_printk(KERN_EMERG, dev, format, ##args) | 2256 | __attribute__ ((format (printf, 2, 3))); |
2237 | #define netdev_alert(dev, format, args...) \ | 2257 | extern int netdev_crit(const struct net_device *dev, const char *format, ...) |
2238 | netdev_printk(KERN_ALERT, dev, format, ##args) | 2258 | __attribute__ ((format (printf, 2, 3))); |
2239 | #define netdev_crit(dev, format, args...) \ | 2259 | extern int netdev_err(const struct net_device *dev, const char *format, ...) |
2240 | netdev_printk(KERN_CRIT, dev, format, ##args) | 2260 | __attribute__ ((format (printf, 2, 3))); |
2241 | #define netdev_err(dev, format, args...) \ | 2261 | extern int netdev_warn(const struct net_device *dev, const char *format, ...) |
2242 | netdev_printk(KERN_ERR, dev, format, ##args) | 2262 | __attribute__ ((format (printf, 2, 3))); |
2243 | #define netdev_warn(dev, format, args...) \ | 2263 | extern int netdev_notice(const struct net_device *dev, const char *format, ...) |
2244 | netdev_printk(KERN_WARNING, dev, format, ##args) | 2264 | __attribute__ ((format (printf, 2, 3))); |
2245 | #define netdev_notice(dev, format, args...) \ | 2265 | extern int netdev_info(const struct net_device *dev, const char *format, ...) |
2246 | netdev_printk(KERN_NOTICE, dev, format, ##args) | 2266 | __attribute__ ((format (printf, 2, 3))); |
2247 | #define netdev_info(dev, format, args...) \ | ||
2248 | netdev_printk(KERN_INFO, dev, format, ##args) | ||
2249 | 2267 | ||
2250 | #if defined(DEBUG) | 2268 | #if defined(DEBUG) |
2251 | #define netdev_dbg(__dev, format, args...) \ | 2269 | #define netdev_dbg(__dev, format, args...) \ |
@@ -2293,20 +2311,26 @@ do { \ | |||
2293 | netdev_printk(level, (dev), fmt, ##args); \ | 2311 | netdev_printk(level, (dev), fmt, ##args); \ |
2294 | } while (0) | 2312 | } while (0) |
2295 | 2313 | ||
2314 | #define netif_level(level, priv, type, dev, fmt, args...) \ | ||
2315 | do { \ | ||
2316 | if (netif_msg_##type(priv)) \ | ||
2317 | netdev_##level(dev, fmt, ##args); \ | ||
2318 | } while (0) | ||
2319 | |||
2296 | #define netif_emerg(priv, type, dev, fmt, args...) \ | 2320 | #define netif_emerg(priv, type, dev, fmt, args...) \ |
2297 | netif_printk(priv, type, KERN_EMERG, dev, fmt, ##args) | 2321 | netif_level(emerg, priv, type, dev, fmt, ##args) |
2298 | #define netif_alert(priv, type, dev, fmt, args...) \ | 2322 | #define netif_alert(priv, type, dev, fmt, args...) \ |
2299 | netif_printk(priv, type, KERN_ALERT, dev, fmt, ##args) | 2323 | netif_level(alert, priv, type, dev, fmt, ##args) |
2300 | #define netif_crit(priv, type, dev, fmt, args...) \ | 2324 | #define netif_crit(priv, type, dev, fmt, args...) \ |
2301 | netif_printk(priv, type, KERN_CRIT, dev, fmt, ##args) | 2325 | netif_level(crit, priv, type, dev, fmt, ##args) |
2302 | #define netif_err(priv, type, dev, fmt, args...) \ | 2326 | #define netif_err(priv, type, dev, fmt, args...) \ |
2303 | netif_printk(priv, type, KERN_ERR, dev, fmt, ##args) | 2327 | netif_level(err, priv, type, dev, fmt, ##args) |
2304 | #define netif_warn(priv, type, dev, fmt, args...) \ | 2328 | #define netif_warn(priv, type, dev, fmt, args...) \ |
2305 | netif_printk(priv, type, KERN_WARNING, dev, fmt, ##args) | 2329 | netif_level(warn, priv, type, dev, fmt, ##args) |
2306 | #define netif_notice(priv, type, dev, fmt, args...) \ | 2330 | #define netif_notice(priv, type, dev, fmt, args...) \ |
2307 | netif_printk(priv, type, KERN_NOTICE, dev, fmt, ##args) | 2331 | netif_level(notice, priv, type, dev, fmt, ##args) |
2308 | #define netif_info(priv, type, dev, fmt, args...) \ | 2332 | #define netif_info(priv, type, dev, fmt, args...) \ |
2309 | netif_printk(priv, type, KERN_INFO, (dev), fmt, ##args) | 2333 | netif_level(info, priv, type, dev, fmt, ##args) |
2310 | 2334 | ||
2311 | #if defined(DEBUG) | 2335 | #if defined(DEBUG) |
2312 | #define netif_dbg(priv, type, dev, format, args...) \ | 2336 | #define netif_dbg(priv, type, dev, format, args...) \ |
@@ -2329,12 +2353,12 @@ do { \ | |||
2329 | #endif | 2353 | #endif |
2330 | 2354 | ||
2331 | #if defined(VERBOSE_DEBUG) | 2355 | #if defined(VERBOSE_DEBUG) |
2332 | #define netif_vdbg netdev_dbg | 2356 | #define netif_vdbg netif_dbg |
2333 | #else | 2357 | #else |
2334 | #define netif_vdbg(priv, type, dev, format, args...) \ | 2358 | #define netif_vdbg(priv, type, dev, format, args...) \ |
2335 | ({ \ | 2359 | ({ \ |
2336 | if (0) \ | 2360 | if (0) \ |
2337 | netif_printk(KERN_DEBUG, dev, format, ##args); \ | 2361 | netif_printk(priv, type, KERN_DEBUG, dev, format, ##args); \ |
2338 | 0; \ | 2362 | 0; \ |
2339 | }) | 2363 | }) |
2340 | #endif | 2364 | #endif |