diff options
Diffstat (limited to 'include/linux/netdevice.h')
| -rw-r--r-- | include/linux/netdevice.h | 142 |
1 files changed, 128 insertions, 14 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 7ed3a3aa6604..66f9a04ec270 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
| @@ -56,9 +56,6 @@ struct device; | |||
| 56 | struct phy_device; | 56 | struct phy_device; |
| 57 | /* 802.11 specific */ | 57 | /* 802.11 specific */ |
| 58 | struct wireless_dev; | 58 | struct wireless_dev; |
| 59 | /* source back-compat hooks */ | ||
| 60 | #define SET_ETHTOOL_OPS(netdev,ops) \ | ||
| 61 | ( (netdev)->ethtool_ops = (ops) ) | ||
| 62 | 59 | ||
| 63 | void netdev_set_default_ethtool_ops(struct net_device *dev, | 60 | void netdev_set_default_ethtool_ops(struct net_device *dev, |
| 64 | const struct ethtool_ops *ops); | 61 | const struct ethtool_ops *ops); |
| @@ -493,7 +490,7 @@ static inline void napi_disable(struct napi_struct *n) | |||
| 493 | static inline void napi_enable(struct napi_struct *n) | 490 | static inline void napi_enable(struct napi_struct *n) |
| 494 | { | 491 | { |
| 495 | BUG_ON(!test_bit(NAPI_STATE_SCHED, &n->state)); | 492 | BUG_ON(!test_bit(NAPI_STATE_SCHED, &n->state)); |
| 496 | smp_mb__before_clear_bit(); | 493 | smp_mb__before_atomic(); |
| 497 | clear_bit(NAPI_STATE_SCHED, &n->state); | 494 | clear_bit(NAPI_STATE_SCHED, &n->state); |
| 498 | } | 495 | } |
| 499 | 496 | ||
| @@ -853,7 +850,8 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev, | |||
| 853 | * SR-IOV management functions. | 850 | * SR-IOV management functions. |
| 854 | * int (*ndo_set_vf_mac)(struct net_device *dev, int vf, u8* mac); | 851 | * int (*ndo_set_vf_mac)(struct net_device *dev, int vf, u8* mac); |
| 855 | * int (*ndo_set_vf_vlan)(struct net_device *dev, int vf, u16 vlan, u8 qos); | 852 | * int (*ndo_set_vf_vlan)(struct net_device *dev, int vf, u16 vlan, u8 qos); |
| 856 | * int (*ndo_set_vf_tx_rate)(struct net_device *dev, int vf, int rate); | 853 | * int (*ndo_set_vf_rate)(struct net_device *dev, int vf, int min_tx_rate, |
| 854 | * int max_tx_rate); | ||
| 857 | * int (*ndo_set_vf_spoofchk)(struct net_device *dev, int vf, bool setting); | 855 | * int (*ndo_set_vf_spoofchk)(struct net_device *dev, int vf, bool setting); |
| 858 | * int (*ndo_get_vf_config)(struct net_device *dev, | 856 | * int (*ndo_get_vf_config)(struct net_device *dev, |
| 859 | * int vf, struct ifla_vf_info *ivf); | 857 | * int vf, struct ifla_vf_info *ivf); |
| @@ -1047,8 +1045,9 @@ struct net_device_ops { | |||
| 1047 | int queue, u8 *mac); | 1045 | int queue, u8 *mac); |
| 1048 | int (*ndo_set_vf_vlan)(struct net_device *dev, | 1046 | int (*ndo_set_vf_vlan)(struct net_device *dev, |
| 1049 | int queue, u16 vlan, u8 qos); | 1047 | int queue, u16 vlan, u8 qos); |
| 1050 | int (*ndo_set_vf_tx_rate)(struct net_device *dev, | 1048 | int (*ndo_set_vf_rate)(struct net_device *dev, |
| 1051 | int vf, int rate); | 1049 | int vf, int min_tx_rate, |
| 1050 | int max_tx_rate); | ||
| 1052 | int (*ndo_set_vf_spoofchk)(struct net_device *dev, | 1051 | int (*ndo_set_vf_spoofchk)(struct net_device *dev, |
| 1053 | int vf, bool setting); | 1052 | int vf, bool setting); |
| 1054 | int (*ndo_get_vf_config)(struct net_device *dev, | 1053 | int (*ndo_get_vf_config)(struct net_device *dev, |
| @@ -1144,6 +1143,7 @@ struct net_device_ops { | |||
| 1144 | netdev_tx_t (*ndo_dfwd_start_xmit) (struct sk_buff *skb, | 1143 | netdev_tx_t (*ndo_dfwd_start_xmit) (struct sk_buff *skb, |
| 1145 | struct net_device *dev, | 1144 | struct net_device *dev, |
| 1146 | void *priv); | 1145 | void *priv); |
| 1146 | int (*ndo_get_lock_subclass)(struct net_device *dev); | ||
| 1147 | }; | 1147 | }; |
| 1148 | 1148 | ||
| 1149 | /** | 1149 | /** |
| @@ -2633,6 +2633,7 @@ int dev_get_phys_port_id(struct net_device *dev, | |||
| 2633 | struct netdev_phys_port_id *ppid); | 2633 | struct netdev_phys_port_id *ppid); |
| 2634 | int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, | 2634 | int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, |
| 2635 | struct netdev_queue *txq); | 2635 | struct netdev_queue *txq); |
| 2636 | int __dev_forward_skb(struct net_device *dev, struct sk_buff *skb); | ||
| 2636 | int dev_forward_skb(struct net_device *dev, struct sk_buff *skb); | 2637 | int dev_forward_skb(struct net_device *dev, struct sk_buff *skb); |
| 2637 | bool is_skb_forwardable(struct net_device *dev, struct sk_buff *skb); | 2638 | bool is_skb_forwardable(struct net_device *dev, struct sk_buff *skb); |
| 2638 | 2639 | ||
| @@ -2950,7 +2951,12 @@ static inline void netif_addr_lock(struct net_device *dev) | |||
| 2950 | 2951 | ||
| 2951 | static inline void netif_addr_lock_nested(struct net_device *dev) | 2952 | static inline void netif_addr_lock_nested(struct net_device *dev) |
| 2952 | { | 2953 | { |
| 2953 | spin_lock_nested(&dev->addr_list_lock, SINGLE_DEPTH_NESTING); | 2954 | int subclass = SINGLE_DEPTH_NESTING; |
| 2955 | |||
| 2956 | if (dev->netdev_ops->ndo_get_lock_subclass) | ||
| 2957 | subclass = dev->netdev_ops->ndo_get_lock_subclass(dev); | ||
| 2958 | |||
| 2959 | spin_lock_nested(&dev->addr_list_lock, subclass); | ||
| 2954 | } | 2960 | } |
| 2955 | 2961 | ||
| 2956 | static inline void netif_addr_lock_bh(struct net_device *dev) | 2962 | static inline void netif_addr_lock_bh(struct net_device *dev) |
| @@ -2997,6 +3003,15 @@ int __hw_addr_sync(struct netdev_hw_addr_list *to_list, | |||
| 2997 | struct netdev_hw_addr_list *from_list, int addr_len); | 3003 | struct netdev_hw_addr_list *from_list, int addr_len); |
| 2998 | void __hw_addr_unsync(struct netdev_hw_addr_list *to_list, | 3004 | void __hw_addr_unsync(struct netdev_hw_addr_list *to_list, |
| 2999 | struct netdev_hw_addr_list *from_list, int addr_len); | 3005 | struct netdev_hw_addr_list *from_list, int addr_len); |
| 3006 | int __hw_addr_sync_dev(struct netdev_hw_addr_list *list, | ||
| 3007 | struct net_device *dev, | ||
| 3008 | int (*sync)(struct net_device *, const unsigned char *), | ||
| 3009 | int (*unsync)(struct net_device *, | ||
| 3010 | const unsigned char *)); | ||
| 3011 | void __hw_addr_unsync_dev(struct netdev_hw_addr_list *list, | ||
| 3012 | struct net_device *dev, | ||
| 3013 | int (*unsync)(struct net_device *, | ||
| 3014 | const unsigned char *)); | ||
| 3000 | void __hw_addr_init(struct netdev_hw_addr_list *list); | 3015 | void __hw_addr_init(struct netdev_hw_addr_list *list); |
| 3001 | 3016 | ||
| 3002 | /* Functions used for device addresses handling */ | 3017 | /* Functions used for device addresses handling */ |
| @@ -3017,6 +3032,38 @@ void dev_uc_unsync(struct net_device *to, struct net_device *from); | |||
| 3017 | void dev_uc_flush(struct net_device *dev); | 3032 | void dev_uc_flush(struct net_device *dev); |
| 3018 | void dev_uc_init(struct net_device *dev); | 3033 | void dev_uc_init(struct net_device *dev); |
| 3019 | 3034 | ||
| 3035 | /** | ||
| 3036 | * __dev_uc_sync - Synchonize device's unicast list | ||
| 3037 | * @dev: device to sync | ||
| 3038 | * @sync: function to call if address should be added | ||
| 3039 | * @unsync: function to call if address should be removed | ||
| 3040 | * | ||
| 3041 | * Add newly added addresses to the interface, and release | ||
| 3042 | * addresses that have been deleted. | ||
| 3043 | **/ | ||
| 3044 | static inline int __dev_uc_sync(struct net_device *dev, | ||
| 3045 | int (*sync)(struct net_device *, | ||
| 3046 | const unsigned char *), | ||
| 3047 | int (*unsync)(struct net_device *, | ||
| 3048 | const unsigned char *)) | ||
| 3049 | { | ||
| 3050 | return __hw_addr_sync_dev(&dev->uc, dev, sync, unsync); | ||
| 3051 | } | ||
| 3052 | |||
| 3053 | /** | ||
| 3054 | * __dev_uc_unsync - Remove synchonized addresses from device | ||
| 3055 | * @dev: device to sync | ||
| 3056 | * @unsync: function to call if address should be removed | ||
| 3057 | * | ||
| 3058 | * Remove all addresses that were added to the device by dev_uc_sync(). | ||
| 3059 | **/ | ||
| 3060 | static inline void __dev_uc_unsync(struct net_device *dev, | ||
| 3061 | int (*unsync)(struct net_device *, | ||
| 3062 | const unsigned char *)) | ||
| 3063 | { | ||
| 3064 | __hw_addr_unsync_dev(&dev->uc, dev, unsync); | ||
| 3065 | } | ||
| 3066 | |||
| 3020 | /* Functions used for multicast addresses handling */ | 3067 | /* Functions used for multicast addresses handling */ |
| 3021 | int dev_mc_add(struct net_device *dev, const unsigned char *addr); | 3068 | int dev_mc_add(struct net_device *dev, const unsigned char *addr); |
| 3022 | int dev_mc_add_global(struct net_device *dev, const unsigned char *addr); | 3069 | int dev_mc_add_global(struct net_device *dev, const unsigned char *addr); |
| @@ -3029,6 +3076,38 @@ void dev_mc_unsync(struct net_device *to, struct net_device *from); | |||
| 3029 | void dev_mc_flush(struct net_device *dev); | 3076 | void dev_mc_flush(struct net_device *dev); |
| 3030 | void dev_mc_init(struct net_device *dev); | 3077 | void dev_mc_init(struct net_device *dev); |
| 3031 | 3078 | ||
| 3079 | /** | ||
| 3080 | * __dev_mc_sync - Synchonize device's multicast list | ||
| 3081 | * @dev: device to sync | ||
| 3082 | * @sync: function to call if address should be added | ||
| 3083 | * @unsync: function to call if address should be removed | ||
| 3084 | * | ||
| 3085 | * Add newly added addresses to the interface, and release | ||
| 3086 | * addresses that have been deleted. | ||
| 3087 | **/ | ||
| 3088 | static inline int __dev_mc_sync(struct net_device *dev, | ||
| 3089 | int (*sync)(struct net_device *, | ||
| 3090 | const unsigned char *), | ||
| 3091 | int (*unsync)(struct net_device *, | ||
| 3092 | const unsigned char *)) | ||
| 3093 | { | ||
| 3094 | return __hw_addr_sync_dev(&dev->mc, dev, sync, unsync); | ||
| 3095 | } | ||
| 3096 | |||
| 3097 | /** | ||
| 3098 | * __dev_mc_unsync - Remove synchonized addresses from device | ||
| 3099 | * @dev: device to sync | ||
| 3100 | * @unsync: function to call if address should be removed | ||
| 3101 | * | ||
| 3102 | * Remove all addresses that were added to the device by dev_mc_sync(). | ||
| 3103 | **/ | ||
| 3104 | static inline void __dev_mc_unsync(struct net_device *dev, | ||
| 3105 | int (*unsync)(struct net_device *, | ||
| 3106 | const unsigned char *)) | ||
| 3107 | { | ||
| 3108 | __hw_addr_unsync_dev(&dev->mc, dev, unsync); | ||
| 3109 | } | ||
| 3110 | |||
| 3032 | /* Functions used for secondary unicast and multicast support */ | 3111 | /* Functions used for secondary unicast and multicast support */ |
| 3033 | void dev_set_rx_mode(struct net_device *dev); | 3112 | void dev_set_rx_mode(struct net_device *dev); |
| 3034 | void __dev_set_rx_mode(struct net_device *dev); | 3113 | void __dev_set_rx_mode(struct net_device *dev); |
| @@ -3050,10 +3129,19 @@ extern int weight_p; | |||
| 3050 | extern int bpf_jit_enable; | 3129 | extern int bpf_jit_enable; |
| 3051 | 3130 | ||
| 3052 | bool netdev_has_upper_dev(struct net_device *dev, struct net_device *upper_dev); | 3131 | bool netdev_has_upper_dev(struct net_device *dev, struct net_device *upper_dev); |
| 3132 | struct net_device *netdev_upper_get_next_dev_rcu(struct net_device *dev, | ||
| 3133 | struct list_head **iter); | ||
| 3053 | struct net_device *netdev_all_upper_get_next_dev_rcu(struct net_device *dev, | 3134 | struct net_device *netdev_all_upper_get_next_dev_rcu(struct net_device *dev, |
| 3054 | struct list_head **iter); | 3135 | struct list_head **iter); |
| 3055 | 3136 | ||
| 3056 | /* iterate through upper list, must be called under RCU read lock */ | 3137 | /* iterate through upper list, must be called under RCU read lock */ |
| 3138 | #define netdev_for_each_upper_dev_rcu(dev, updev, iter) \ | ||
| 3139 | for (iter = &(dev)->adj_list.upper, \ | ||
| 3140 | updev = netdev_upper_get_next_dev_rcu(dev, &(iter)); \ | ||
| 3141 | updev; \ | ||
| 3142 | updev = netdev_upper_get_next_dev_rcu(dev, &(iter))) | ||
| 3143 | |||
| 3144 | /* iterate through upper list, must be called under RCU read lock */ | ||
| 3057 | #define netdev_for_each_all_upper_dev_rcu(dev, updev, iter) \ | 3145 | #define netdev_for_each_all_upper_dev_rcu(dev, updev, iter) \ |
| 3058 | for (iter = &(dev)->all_adj_list.upper, \ | 3146 | for (iter = &(dev)->all_adj_list.upper, \ |
| 3059 | updev = netdev_all_upper_get_next_dev_rcu(dev, &(iter)); \ | 3147 | updev = netdev_all_upper_get_next_dev_rcu(dev, &(iter)); \ |
| @@ -3077,6 +3165,14 @@ void *netdev_lower_get_next_private_rcu(struct net_device *dev, | |||
| 3077 | priv; \ | 3165 | priv; \ |
| 3078 | priv = netdev_lower_get_next_private_rcu(dev, &(iter))) | 3166 | priv = netdev_lower_get_next_private_rcu(dev, &(iter))) |
| 3079 | 3167 | ||
| 3168 | void *netdev_lower_get_next(struct net_device *dev, | ||
| 3169 | struct list_head **iter); | ||
| 3170 | #define netdev_for_each_lower_dev(dev, ldev, iter) \ | ||
| 3171 | for (iter = &(dev)->adj_list.lower, \ | ||
| 3172 | ldev = netdev_lower_get_next(dev, &(iter)); \ | ||
| 3173 | ldev; \ | ||
| 3174 | ldev = netdev_lower_get_next(dev, &(iter))) | ||
| 3175 | |||
| 3080 | void *netdev_adjacent_get_private(struct list_head *adj_list); | 3176 | void *netdev_adjacent_get_private(struct list_head *adj_list); |
| 3081 | void *netdev_lower_get_first_private_rcu(struct net_device *dev); | 3177 | void *netdev_lower_get_first_private_rcu(struct net_device *dev); |
| 3082 | struct net_device *netdev_master_upper_dev_get(struct net_device *dev); | 3178 | struct net_device *netdev_master_upper_dev_get(struct net_device *dev); |
| @@ -3092,6 +3188,8 @@ void netdev_upper_dev_unlink(struct net_device *dev, | |||
| 3092 | void netdev_adjacent_rename_links(struct net_device *dev, char *oldname); | 3188 | void netdev_adjacent_rename_links(struct net_device *dev, char *oldname); |
| 3093 | void *netdev_lower_dev_get_private(struct net_device *dev, | 3189 | void *netdev_lower_dev_get_private(struct net_device *dev, |
| 3094 | struct net_device *lower_dev); | 3190 | struct net_device *lower_dev); |
| 3191 | int dev_get_nest_level(struct net_device *dev, | ||
| 3192 | bool (*type_check)(struct net_device *dev)); | ||
| 3095 | int skb_checksum_help(struct sk_buff *skb); | 3193 | int skb_checksum_help(struct sk_buff *skb); |
| 3096 | struct sk_buff *__skb_gso_segment(struct sk_buff *skb, | 3194 | struct sk_buff *__skb_gso_segment(struct sk_buff *skb, |
| 3097 | netdev_features_t features, bool tx_path); | 3195 | netdev_features_t features, bool tx_path); |
| @@ -3155,6 +3253,20 @@ const char *netdev_drivername(const struct net_device *dev); | |||
| 3155 | 3253 | ||
| 3156 | void linkwatch_run_queue(void); | 3254 | void linkwatch_run_queue(void); |
| 3157 | 3255 | ||
| 3256 | static inline netdev_features_t netdev_intersect_features(netdev_features_t f1, | ||
| 3257 | netdev_features_t f2) | ||
| 3258 | { | ||
| 3259 | if (f1 & NETIF_F_GEN_CSUM) | ||
| 3260 | f1 |= (NETIF_F_ALL_CSUM & ~NETIF_F_GEN_CSUM); | ||
| 3261 | if (f2 & NETIF_F_GEN_CSUM) | ||
| 3262 | f2 |= (NETIF_F_ALL_CSUM & ~NETIF_F_GEN_CSUM); | ||
| 3263 | f1 &= f2; | ||
| 3264 | if (f1 & NETIF_F_GEN_CSUM) | ||
| 3265 | f1 &= ~(NETIF_F_ALL_CSUM & ~NETIF_F_GEN_CSUM); | ||
| 3266 | |||
| 3267 | return f1; | ||
| 3268 | } | ||
| 3269 | |||
| 3158 | static inline netdev_features_t netdev_get_wanted_features( | 3270 | static inline netdev_features_t netdev_get_wanted_features( |
| 3159 | struct net_device *dev) | 3271 | struct net_device *dev) |
| 3160 | { | 3272 | { |
| @@ -3180,12 +3292,7 @@ void netdev_change_features(struct net_device *dev); | |||
| 3180 | void netif_stacked_transfer_operstate(const struct net_device *rootdev, | 3292 | void netif_stacked_transfer_operstate(const struct net_device *rootdev, |
| 3181 | struct net_device *dev); | 3293 | struct net_device *dev); |
| 3182 | 3294 | ||
| 3183 | netdev_features_t netif_skb_dev_features(struct sk_buff *skb, | 3295 | netdev_features_t netif_skb_features(struct sk_buff *skb); |
| 3184 | const struct net_device *dev); | ||
| 3185 | static inline netdev_features_t netif_skb_features(struct sk_buff *skb) | ||
| 3186 | { | ||
| 3187 | return netif_skb_dev_features(skb, skb->dev); | ||
| 3188 | } | ||
| 3189 | 3296 | ||
| 3190 | static inline bool net_gso_ok(netdev_features_t features, int gso_type) | 3297 | static inline bool net_gso_ok(netdev_features_t features, int gso_type) |
| 3191 | { | 3298 | { |
| @@ -3198,6 +3305,13 @@ static inline bool net_gso_ok(netdev_features_t features, int gso_type) | |||
| 3198 | BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT)); | 3305 | BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT)); |
| 3199 | BUILD_BUG_ON(SKB_GSO_TCPV6 != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT)); | 3306 | BUILD_BUG_ON(SKB_GSO_TCPV6 != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT)); |
| 3200 | BUILD_BUG_ON(SKB_GSO_FCOE != (NETIF_F_FSO >> NETIF_F_GSO_SHIFT)); | 3307 | BUILD_BUG_ON(SKB_GSO_FCOE != (NETIF_F_FSO >> NETIF_F_GSO_SHIFT)); |
| 3308 | BUILD_BUG_ON(SKB_GSO_GRE != (NETIF_F_GSO_GRE >> NETIF_F_GSO_SHIFT)); | ||
| 3309 | BUILD_BUG_ON(SKB_GSO_GRE_CSUM != (NETIF_F_GSO_GRE_CSUM >> NETIF_F_GSO_SHIFT)); | ||
| 3310 | BUILD_BUG_ON(SKB_GSO_IPIP != (NETIF_F_GSO_IPIP >> NETIF_F_GSO_SHIFT)); | ||
| 3311 | BUILD_BUG_ON(SKB_GSO_SIT != (NETIF_F_GSO_SIT >> NETIF_F_GSO_SHIFT)); | ||
| 3312 | BUILD_BUG_ON(SKB_GSO_UDP_TUNNEL != (NETIF_F_GSO_UDP_TUNNEL >> NETIF_F_GSO_SHIFT)); | ||
| 3313 | BUILD_BUG_ON(SKB_GSO_UDP_TUNNEL_CSUM != (NETIF_F_GSO_UDP_TUNNEL_CSUM >> NETIF_F_GSO_SHIFT)); | ||
| 3314 | BUILD_BUG_ON(SKB_GSO_MPLS != (NETIF_F_GSO_MPLS >> NETIF_F_GSO_SHIFT)); | ||
| 3201 | 3315 | ||
| 3202 | return (features & feature) == feature; | 3316 | return (features & feature) == feature; |
| 3203 | } | 3317 | } |
