diff options
Diffstat (limited to 'include/linux/netdevice.h')
| -rw-r--r-- | include/linux/netdevice.h | 194 |
1 files changed, 177 insertions, 17 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index a3fccc85b1a0..fa8b47637997 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #include <linux/if.h> | 28 | #include <linux/if.h> |
| 29 | #include <linux/if_ether.h> | 29 | #include <linux/if_ether.h> |
| 30 | #include <linux/if_packet.h> | 30 | #include <linux/if_packet.h> |
| 31 | #include <linux/if_link.h> | ||
| 31 | 32 | ||
| 32 | #ifdef __KERNEL__ | 33 | #ifdef __KERNEL__ |
| 33 | #include <linux/timer.h> | 34 | #include <linux/timer.h> |
| @@ -136,7 +137,7 @@ static inline bool dev_xmit_complete(int rc) | |||
| 136 | * used. | 137 | * used. |
| 137 | */ | 138 | */ |
| 138 | 139 | ||
| 139 | #if defined(CONFIG_WLAN_80211) || defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) | 140 | #if defined(CONFIG_WLAN) || defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) |
| 140 | # if defined(CONFIG_MAC80211_MESH) | 141 | # if defined(CONFIG_MAC80211_MESH) |
| 141 | # define LL_MAX_HEADER 128 | 142 | # define LL_MAX_HEADER 128 |
| 142 | # else | 143 | # else |
| @@ -263,6 +264,17 @@ struct netdev_hw_addr_list { | |||
| 263 | int count; | 264 | int count; |
| 264 | }; | 265 | }; |
| 265 | 266 | ||
| 267 | #define netdev_uc_count(dev) ((dev)->uc.count) | ||
| 268 | #define netdev_uc_empty(dev) ((dev)->uc.count == 0) | ||
| 269 | #define netdev_for_each_uc_addr(ha, dev) \ | ||
| 270 | list_for_each_entry(ha, &dev->uc.list, list) | ||
| 271 | |||
| 272 | #define netdev_mc_count(dev) ((dev)->mc_count) | ||
| 273 | #define netdev_mc_empty(dev) (netdev_mc_count(dev) == 0) | ||
| 274 | |||
| 275 | #define netdev_for_each_mc_addr(mclist, dev) \ | ||
| 276 | for (mclist = dev->mc_list; mclist; mclist = mclist->next) | ||
| 277 | |||
| 266 | struct hh_cache { | 278 | struct hh_cache { |
| 267 | struct hh_cache *hh_next; /* Next entry */ | 279 | struct hh_cache *hh_next; /* Next entry */ |
| 268 | atomic_t hh_refcnt; /* number of users */ | 280 | atomic_t hh_refcnt; /* number of users */ |
| @@ -610,6 +622,13 @@ struct netdev_queue { | |||
| 610 | * this function is called when a VLAN id is unregistered. | 622 | * this function is called when a VLAN id is unregistered. |
| 611 | * | 623 | * |
| 612 | * void (*ndo_poll_controller)(struct net_device *dev); | 624 | * void (*ndo_poll_controller)(struct net_device *dev); |
| 625 | * | ||
| 626 | * SR-IOV management functions. | ||
| 627 | * int (*ndo_set_vf_mac)(struct net_device *dev, int vf, u8* mac); | ||
| 628 | * int (*ndo_set_vf_vlan)(struct net_device *dev, int vf, u16 vlan, u8 qos); | ||
| 629 | * int (*ndo_set_vf_tx_rate)(struct net_device *dev, int vf, int rate); | ||
| 630 | * int (*ndo_get_vf_config)(struct net_device *dev, | ||
| 631 | * int vf, struct ifla_vf_info *ivf); | ||
| 613 | */ | 632 | */ |
| 614 | #define HAVE_NET_DEVICE_OPS | 633 | #define HAVE_NET_DEVICE_OPS |
| 615 | struct net_device_ops { | 634 | struct net_device_ops { |
| @@ -621,30 +640,21 @@ struct net_device_ops { | |||
| 621 | struct net_device *dev); | 640 | struct net_device *dev); |
| 622 | u16 (*ndo_select_queue)(struct net_device *dev, | 641 | u16 (*ndo_select_queue)(struct net_device *dev, |
| 623 | struct sk_buff *skb); | 642 | struct sk_buff *skb); |
| 624 | #define HAVE_CHANGE_RX_FLAGS | ||
| 625 | void (*ndo_change_rx_flags)(struct net_device *dev, | 643 | void (*ndo_change_rx_flags)(struct net_device *dev, |
| 626 | int flags); | 644 | int flags); |
| 627 | #define HAVE_SET_RX_MODE | ||
| 628 | void (*ndo_set_rx_mode)(struct net_device *dev); | 645 | void (*ndo_set_rx_mode)(struct net_device *dev); |
| 629 | #define HAVE_MULTICAST | ||
| 630 | void (*ndo_set_multicast_list)(struct net_device *dev); | 646 | void (*ndo_set_multicast_list)(struct net_device *dev); |
| 631 | #define HAVE_SET_MAC_ADDR | ||
| 632 | int (*ndo_set_mac_address)(struct net_device *dev, | 647 | int (*ndo_set_mac_address)(struct net_device *dev, |
| 633 | void *addr); | 648 | void *addr); |
| 634 | #define HAVE_VALIDATE_ADDR | ||
| 635 | int (*ndo_validate_addr)(struct net_device *dev); | 649 | int (*ndo_validate_addr)(struct net_device *dev); |
| 636 | #define HAVE_PRIVATE_IOCTL | ||
| 637 | int (*ndo_do_ioctl)(struct net_device *dev, | 650 | int (*ndo_do_ioctl)(struct net_device *dev, |
| 638 | struct ifreq *ifr, int cmd); | 651 | struct ifreq *ifr, int cmd); |
| 639 | #define HAVE_SET_CONFIG | ||
| 640 | int (*ndo_set_config)(struct net_device *dev, | 652 | int (*ndo_set_config)(struct net_device *dev, |
| 641 | struct ifmap *map); | 653 | struct ifmap *map); |
| 642 | #define HAVE_CHANGE_MTU | ||
| 643 | int (*ndo_change_mtu)(struct net_device *dev, | 654 | int (*ndo_change_mtu)(struct net_device *dev, |
| 644 | int new_mtu); | 655 | int new_mtu); |
| 645 | int (*ndo_neigh_setup)(struct net_device *dev, | 656 | int (*ndo_neigh_setup)(struct net_device *dev, |
| 646 | struct neigh_parms *); | 657 | struct neigh_parms *); |
| 647 | #define HAVE_TX_TIMEOUT | ||
| 648 | void (*ndo_tx_timeout) (struct net_device *dev); | 658 | void (*ndo_tx_timeout) (struct net_device *dev); |
| 649 | 659 | ||
| 650 | struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); | 660 | struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); |
| @@ -656,9 +666,17 @@ struct net_device_ops { | |||
| 656 | void (*ndo_vlan_rx_kill_vid)(struct net_device *dev, | 666 | void (*ndo_vlan_rx_kill_vid)(struct net_device *dev, |
| 657 | unsigned short vid); | 667 | unsigned short vid); |
| 658 | #ifdef CONFIG_NET_POLL_CONTROLLER | 668 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 659 | #define HAVE_NETDEV_POLL | ||
| 660 | void (*ndo_poll_controller)(struct net_device *dev); | 669 | void (*ndo_poll_controller)(struct net_device *dev); |
| 661 | #endif | 670 | #endif |
| 671 | int (*ndo_set_vf_mac)(struct net_device *dev, | ||
| 672 | int queue, u8 *mac); | ||
| 673 | int (*ndo_set_vf_vlan)(struct net_device *dev, | ||
| 674 | int queue, u16 vlan, u8 qos); | ||
| 675 | int (*ndo_set_vf_tx_rate)(struct net_device *dev, | ||
| 676 | int vf, int rate); | ||
| 677 | int (*ndo_get_vf_config)(struct net_device *dev, | ||
| 678 | int vf, | ||
| 679 | struct ifla_vf_info *ivf); | ||
| 662 | #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) | 680 | #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) |
| 663 | int (*ndo_fcoe_enable)(struct net_device *dev); | 681 | int (*ndo_fcoe_enable)(struct net_device *dev); |
| 664 | int (*ndo_fcoe_disable)(struct net_device *dev); | 682 | int (*ndo_fcoe_disable)(struct net_device *dev); |
| @@ -745,6 +763,7 @@ struct net_device { | |||
| 745 | #define NETIF_F_FCOE_CRC (1 << 24) /* FCoE CRC32 */ | 763 | #define NETIF_F_FCOE_CRC (1 << 24) /* FCoE CRC32 */ |
| 746 | #define NETIF_F_SCTP_CSUM (1 << 25) /* SCTP checksum offload */ | 764 | #define NETIF_F_SCTP_CSUM (1 << 25) /* SCTP checksum offload */ |
| 747 | #define NETIF_F_FCOE_MTU (1 << 26) /* Supports max FCoE MTU, 2158 bytes*/ | 765 | #define NETIF_F_FCOE_MTU (1 << 26) /* Supports max FCoE MTU, 2158 bytes*/ |
| 766 | #define NETIF_F_NTUPLE (1 << 27) /* N-tuple filters supported */ | ||
| 748 | 767 | ||
| 749 | /* Segmentation offload features */ | 768 | /* Segmentation offload features */ |
| 750 | #define NETIF_F_GSO_SHIFT 16 | 769 | #define NETIF_F_GSO_SHIFT 16 |
| @@ -905,7 +924,12 @@ struct net_device { | |||
| 905 | NETREG_UNREGISTERED, /* completed unregister todo */ | 924 | NETREG_UNREGISTERED, /* completed unregister todo */ |
| 906 | NETREG_RELEASED, /* called free_netdev */ | 925 | NETREG_RELEASED, /* called free_netdev */ |
| 907 | NETREG_DUMMY, /* dummy device for NAPI poll */ | 926 | NETREG_DUMMY, /* dummy device for NAPI poll */ |
| 908 | } reg_state; | 927 | } reg_state:16; |
| 928 | |||
| 929 | enum { | ||
| 930 | RTNL_LINK_INITIALIZED, | ||
| 931 | RTNL_LINK_INITIALIZING, | ||
| 932 | } rtnl_link_state:16; | ||
| 909 | 933 | ||
| 910 | /* Called from unregister, can be used to call free_netdev */ | 934 | /* Called from unregister, can be used to call free_netdev */ |
| 911 | void (*destructor)(struct net_device *dev); | 935 | void (*destructor)(struct net_device *dev); |
| @@ -953,6 +977,8 @@ struct net_device { | |||
| 953 | /* max exchange id for FCoE LRO by ddp */ | 977 | /* max exchange id for FCoE LRO by ddp */ |
| 954 | unsigned int fcoe_ddp_xid; | 978 | unsigned int fcoe_ddp_xid; |
| 955 | #endif | 979 | #endif |
| 980 | /* n-tuple filter list attached to this device */ | ||
| 981 | struct ethtool_rx_ntuple_list ethtool_ntuple_list; | ||
| 956 | }; | 982 | }; |
| 957 | #define to_net_dev(d) container_of(d, struct net_device, dev) | 983 | #define to_net_dev(d) container_of(d, struct net_device, dev) |
| 958 | 984 | ||
| @@ -1009,6 +1035,15 @@ static inline bool netdev_uses_dsa_tags(struct net_device *dev) | |||
| 1009 | return 0; | 1035 | return 0; |
| 1010 | } | 1036 | } |
| 1011 | 1037 | ||
| 1038 | #ifndef CONFIG_NET_NS | ||
| 1039 | static inline void skb_set_dev(struct sk_buff *skb, struct net_device *dev) | ||
| 1040 | { | ||
| 1041 | skb->dev = dev; | ||
| 1042 | } | ||
| 1043 | #else /* CONFIG_NET_NS */ | ||
| 1044 | void skb_set_dev(struct sk_buff *skb, struct net_device *dev); | ||
| 1045 | #endif | ||
| 1046 | |||
| 1012 | static inline bool netdev_uses_trailer_tags(struct net_device *dev) | 1047 | static inline bool netdev_uses_trailer_tags(struct net_device *dev) |
| 1013 | { | 1048 | { |
| 1014 | #ifdef CONFIG_NET_DSA_TAG_TRAILER | 1049 | #ifdef CONFIG_NET_DSA_TAG_TRAILER |
| @@ -1527,7 +1562,6 @@ extern int netif_rx(struct sk_buff *skb); | |||
| 1527 | extern int netif_rx_ni(struct sk_buff *skb); | 1562 | extern int netif_rx_ni(struct sk_buff *skb); |
| 1528 | #define HAVE_NETIF_RECEIVE_SKB 1 | 1563 | #define HAVE_NETIF_RECEIVE_SKB 1 |
| 1529 | extern int netif_receive_skb(struct sk_buff *skb); | 1564 | extern int netif_receive_skb(struct sk_buff *skb); |
| 1530 | extern void napi_gro_flush(struct napi_struct *napi); | ||
| 1531 | extern gro_result_t dev_gro_receive(struct napi_struct *napi, | 1565 | extern gro_result_t dev_gro_receive(struct napi_struct *napi, |
| 1532 | struct sk_buff *skb); | 1566 | struct sk_buff *skb); |
| 1533 | extern gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb); | 1567 | extern gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb); |
| @@ -1553,7 +1587,9 @@ extern int dev_valid_name(const char *name); | |||
| 1553 | extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); | 1587 | extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); |
| 1554 | extern int dev_ethtool(struct net *net, struct ifreq *); | 1588 | extern int dev_ethtool(struct net *net, struct ifreq *); |
| 1555 | extern unsigned dev_get_flags(const struct net_device *); | 1589 | extern unsigned dev_get_flags(const struct net_device *); |
| 1590 | extern int __dev_change_flags(struct net_device *, unsigned int flags); | ||
| 1556 | extern int dev_change_flags(struct net_device *, unsigned); | 1591 | extern int dev_change_flags(struct net_device *, unsigned); |
| 1592 | extern void __dev_notify_flags(struct net_device *, unsigned int old_flags); | ||
| 1557 | extern int dev_change_name(struct net_device *, const char *); | 1593 | extern int dev_change_name(struct net_device *, const char *); |
| 1558 | extern int dev_set_alias(struct net_device *, const char *, size_t); | 1594 | extern int dev_set_alias(struct net_device *, const char *, size_t); |
| 1559 | extern int dev_change_net_namespace(struct net_device *, | 1595 | extern int dev_change_net_namespace(struct net_device *, |
| @@ -2023,12 +2059,12 @@ static inline void skb_bond_set_mac_by_master(struct sk_buff *skb, | |||
| 2023 | * duplicates except for 802.3ad ETH_P_SLOW, alb non-mcast/bcast, and | 2059 | * duplicates except for 802.3ad ETH_P_SLOW, alb non-mcast/bcast, and |
| 2024 | * ARP on active-backup slaves with arp_validate enabled. | 2060 | * ARP on active-backup slaves with arp_validate enabled. |
| 2025 | */ | 2061 | */ |
| 2026 | static inline int skb_bond_should_drop(struct sk_buff *skb) | 2062 | static inline int skb_bond_should_drop(struct sk_buff *skb, |
| 2063 | struct net_device *master) | ||
| 2027 | { | 2064 | { |
| 2028 | struct net_device *dev = skb->dev; | ||
| 2029 | struct net_device *master = dev->master; | ||
| 2030 | |||
| 2031 | if (master) { | 2065 | if (master) { |
| 2066 | struct net_device *dev = skb->dev; | ||
| 2067 | |||
| 2032 | if (master->priv_flags & IFF_MASTER_ARPMON) | 2068 | if (master->priv_flags & IFF_MASTER_ARPMON) |
| 2033 | dev->last_rx = jiffies; | 2069 | dev->last_rx = jiffies; |
| 2034 | 2070 | ||
| @@ -2083,6 +2119,130 @@ static inline u32 dev_ethtool_get_flags(struct net_device *dev) | |||
| 2083 | return 0; | 2119 | return 0; |
| 2084 | return dev->ethtool_ops->get_flags(dev); | 2120 | return dev->ethtool_ops->get_flags(dev); |
| 2085 | } | 2121 | } |
| 2122 | |||
| 2123 | /* Logging, debugging and troubleshooting/diagnostic helpers. */ | ||
| 2124 | |||
| 2125 | /* netdev_printk helpers, similar to dev_printk */ | ||
| 2126 | |||
| 2127 | static inline const char *netdev_name(const struct net_device *dev) | ||
| 2128 | { | ||
| 2129 | if (dev->reg_state != NETREG_REGISTERED) | ||
| 2130 | return "(unregistered net_device)"; | ||
| 2131 | return dev->name; | ||
| 2132 | } | ||
| 2133 | |||
| 2134 | #define netdev_printk(level, netdev, format, args...) \ | ||
| 2135 | dev_printk(level, (netdev)->dev.parent, \ | ||
| 2136 | "%s: " format, \ | ||
| 2137 | netdev_name(netdev), ##args) | ||
| 2138 | |||
| 2139 | #define netdev_emerg(dev, format, args...) \ | ||
| 2140 | netdev_printk(KERN_EMERG, dev, format, ##args) | ||
| 2141 | #define netdev_alert(dev, format, args...) \ | ||
| 2142 | netdev_printk(KERN_ALERT, dev, format, ##args) | ||
| 2143 | #define netdev_crit(dev, format, args...) \ | ||
| 2144 | netdev_printk(KERN_CRIT, dev, format, ##args) | ||
| 2145 | #define netdev_err(dev, format, args...) \ | ||
| 2146 | netdev_printk(KERN_ERR, dev, format, ##args) | ||
| 2147 | #define netdev_warn(dev, format, args...) \ | ||
| 2148 | netdev_printk(KERN_WARNING, dev, format, ##args) | ||
| 2149 | #define netdev_notice(dev, format, args...) \ | ||
| 2150 | netdev_printk(KERN_NOTICE, dev, format, ##args) | ||
| 2151 | #define netdev_info(dev, format, args...) \ | ||
| 2152 | netdev_printk(KERN_INFO, dev, format, ##args) | ||
| 2153 | |||
| 2154 | #if defined(DEBUG) | ||
| 2155 | #define netdev_dbg(__dev, format, args...) \ | ||
| 2156 | netdev_printk(KERN_DEBUG, __dev, format, ##args) | ||
| 2157 | #elif defined(CONFIG_DYNAMIC_DEBUG) | ||
| 2158 | #define netdev_dbg(__dev, format, args...) \ | ||
| 2159 | do { \ | ||
| 2160 | dynamic_dev_dbg((__dev)->dev.parent, "%s: " format, \ | ||
| 2161 | netdev_name(__dev), ##args); \ | ||
| 2162 | } while (0) | ||
| 2163 | #else | ||
| 2164 | #define netdev_dbg(__dev, format, args...) \ | ||
| 2165 | ({ \ | ||
| 2166 | if (0) \ | ||
| 2167 | netdev_printk(KERN_DEBUG, __dev, format, ##args); \ | ||
| 2168 | 0; \ | ||
| 2169 | }) | ||
| 2170 | #endif | ||
| 2171 | |||
| 2172 | #if defined(VERBOSE_DEBUG) | ||
| 2173 | #define netdev_vdbg netdev_dbg | ||
| 2174 | #else | ||
| 2175 | |||
| 2176 | #define netdev_vdbg(dev, format, args...) \ | ||
| 2177 | ({ \ | ||
| 2178 | if (0) \ | ||
| 2179 | netdev_printk(KERN_DEBUG, dev, format, ##args); \ | ||
| 2180 | 0; \ | ||
| 2181 | }) | ||
| 2182 | #endif | ||
| 2183 | |||
| 2184 | /* | ||
| 2185 | * netdev_WARN() acts like dev_printk(), but with the key difference | ||
| 2186 | * of using a WARN/WARN_ON to get the message out, including the | ||
| 2187 | * file/line information and a backtrace. | ||
| 2188 | */ | ||
| 2189 | #define netdev_WARN(dev, format, args...) \ | ||
| 2190 | WARN(1, "netdevice: %s\n" format, netdev_name(dev), ##args); | ||
| 2191 | |||
| 2192 | /* netif printk helpers, similar to netdev_printk */ | ||
| 2193 | |||
| 2194 | #define netif_printk(priv, type, level, dev, fmt, args...) \ | ||
| 2195 | do { \ | ||
| 2196 | if (netif_msg_##type(priv)) \ | ||
| 2197 | netdev_printk(level, (dev), fmt, ##args); \ | ||
| 2198 | } while (0) | ||
| 2199 | |||
| 2200 | #define netif_emerg(priv, type, dev, fmt, args...) \ | ||
| 2201 | netif_printk(priv, type, KERN_EMERG, dev, fmt, ##args) | ||
| 2202 | #define netif_alert(priv, type, dev, fmt, args...) \ | ||
| 2203 | netif_printk(priv, type, KERN_ALERT, dev, fmt, ##args) | ||
| 2204 | #define netif_crit(priv, type, dev, fmt, args...) \ | ||
| 2205 | netif_printk(priv, type, KERN_CRIT, dev, fmt, ##args) | ||
| 2206 | #define netif_err(priv, type, dev, fmt, args...) \ | ||
| 2207 | netif_printk(priv, type, KERN_ERR, dev, fmt, ##args) | ||
| 2208 | #define netif_warn(priv, type, dev, fmt, args...) \ | ||
| 2209 | netif_printk(priv, type, KERN_WARNING, dev, fmt, ##args) | ||
| 2210 | #define netif_notice(priv, type, dev, fmt, args...) \ | ||
| 2211 | netif_printk(priv, type, KERN_NOTICE, dev, fmt, ##args) | ||
| 2212 | #define netif_info(priv, type, dev, fmt, args...) \ | ||
| 2213 | netif_printk(priv, type, KERN_INFO, (dev), fmt, ##args) | ||
| 2214 | |||
| 2215 | #if defined(DEBUG) | ||
| 2216 | #define netif_dbg(priv, type, dev, format, args...) \ | ||
| 2217 | netif_printk(priv, type, KERN_DEBUG, dev, format, ##args) | ||
| 2218 | #elif defined(CONFIG_DYNAMIC_DEBUG) | ||
| 2219 | #define netif_dbg(priv, type, netdev, format, args...) \ | ||
| 2220 | do { \ | ||
| 2221 | if (netif_msg_##type(priv)) \ | ||
| 2222 | dynamic_dev_dbg((netdev)->dev.parent, \ | ||
| 2223 | "%s: " format, \ | ||
| 2224 | netdev_name(netdev), ##args); \ | ||
| 2225 | } while (0) | ||
| 2226 | #else | ||
| 2227 | #define netif_dbg(priv, type, dev, format, args...) \ | ||
| 2228 | ({ \ | ||
| 2229 | if (0) \ | ||
| 2230 | netif_printk(priv, type, KERN_DEBUG, dev, format, ##args); \ | ||
| 2231 | 0; \ | ||
| 2232 | }) | ||
| 2233 | #endif | ||
| 2234 | |||
| 2235 | #if defined(VERBOSE_DEBUG) | ||
| 2236 | #define netif_vdbg netdev_dbg | ||
| 2237 | #else | ||
| 2238 | #define netif_vdbg(priv, type, dev, format, args...) \ | ||
| 2239 | ({ \ | ||
| 2240 | if (0) \ | ||
| 2241 | netif_printk(KERN_DEBUG, dev, format, ##args); \ | ||
| 2242 | 0; \ | ||
| 2243 | }) | ||
| 2244 | #endif | ||
| 2245 | |||
| 2086 | #endif /* __KERNEL__ */ | 2246 | #endif /* __KERNEL__ */ |
| 2087 | 2247 | ||
| 2088 | #endif /* _LINUX_NETDEVICE_H */ | 2248 | #endif /* _LINUX_NETDEVICE_H */ |
