diff options
author | Michał Mirosław <mirq-linux@rere.qmqm.pl> | 2011-11-15 10:29:55 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-11-16 17:43:10 -0500 |
commit | c8f44affb7244f2ac3e703cab13d55ede27621bb (patch) | |
tree | 62e7aea2916a8d7cab825fe500670c5113854c0f /include | |
parent | a59e2ecb859f2ab03bb2e230709f8039472ad2c3 (diff) |
net: introduce and use netdev_features_t for device features sets
v2: add couple missing conversions in drivers
split unexporting netdev_fix_features()
implemented %pNF
convert sock::sk_route_(no?)caps
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/netdev_features.h | 4 | ||||
-rw-r--r-- | include/linux/netdevice.h | 41 | ||||
-rw-r--r-- | include/linux/skbuff.h | 4 | ||||
-rw-r--r-- | include/net/protocol.h | 4 | ||||
-rw-r--r-- | include/net/sock.h | 6 | ||||
-rw-r--r-- | include/net/tcp.h | 3 | ||||
-rw-r--r-- | include/net/udp.h | 3 |
7 files changed, 39 insertions, 26 deletions
diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h index 32640edf4d78..af5238121826 100644 --- a/include/linux/netdev_features.h +++ b/include/linux/netdev_features.h | |||
@@ -10,6 +10,10 @@ | |||
10 | #ifndef _LINUX_NETDEV_FEATURES_H | 10 | #ifndef _LINUX_NETDEV_FEATURES_H |
11 | #define _LINUX_NETDEV_FEATURES_H | 11 | #define _LINUX_NETDEV_FEATURES_H |
12 | 12 | ||
13 | #include <linux/types.h> | ||
14 | |||
15 | typedef u32 netdev_features_t; | ||
16 | |||
13 | /* Net device feature bits; if you change something, | 17 | /* Net device feature bits; if you change something, |
14 | * also update netdev_features_strings[] in ethtool.c */ | 18 | * also update netdev_features_strings[] in ethtool.c */ |
15 | 19 | ||
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 9cf6e90b171d..b35ffd735ecc 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -847,12 +847,13 @@ struct netdev_tc_txq { | |||
847 | * Called to release previously enslaved netdev. | 847 | * Called to release previously enslaved netdev. |
848 | * | 848 | * |
849 | * Feature/offload setting functions. | 849 | * Feature/offload setting functions. |
850 | * u32 (*ndo_fix_features)(struct net_device *dev, u32 features); | 850 | * netdev_features_t (*ndo_fix_features)(struct net_device *dev, |
851 | * netdev_features_t features); | ||
851 | * Adjusts the requested feature flags according to device-specific | 852 | * Adjusts the requested feature flags according to device-specific |
852 | * constraints, and returns the resulting flags. Must not modify | 853 | * constraints, and returns the resulting flags. Must not modify |
853 | * the device state. | 854 | * the device state. |
854 | * | 855 | * |
855 | * int (*ndo_set_features)(struct net_device *dev, u32 features); | 856 | * int (*ndo_set_features)(struct net_device *dev, netdev_features_t features); |
856 | * Called to update device configuration to new features. Passed | 857 | * Called to update device configuration to new features. Passed |
857 | * feature set might be less than what was returned by ndo_fix_features()). | 858 | * feature set might be less than what was returned by ndo_fix_features()). |
858 | * Must return >0 or -errno if it changed dev->features itself. | 859 | * Must return >0 or -errno if it changed dev->features itself. |
@@ -946,10 +947,10 @@ struct net_device_ops { | |||
946 | struct net_device *slave_dev); | 947 | struct net_device *slave_dev); |
947 | int (*ndo_del_slave)(struct net_device *dev, | 948 | int (*ndo_del_slave)(struct net_device *dev, |
948 | struct net_device *slave_dev); | 949 | struct net_device *slave_dev); |
949 | u32 (*ndo_fix_features)(struct net_device *dev, | 950 | netdev_features_t (*ndo_fix_features)(struct net_device *dev, |
950 | u32 features); | 951 | netdev_features_t features); |
951 | int (*ndo_set_features)(struct net_device *dev, | 952 | int (*ndo_set_features)(struct net_device *dev, |
952 | u32 features); | 953 | netdev_features_t features); |
953 | }; | 954 | }; |
954 | 955 | ||
955 | /* | 956 | /* |
@@ -999,13 +1000,13 @@ struct net_device { | |||
999 | struct list_head unreg_list; | 1000 | struct list_head unreg_list; |
1000 | 1001 | ||
1001 | /* currently active device features */ | 1002 | /* currently active device features */ |
1002 | u32 features; | 1003 | netdev_features_t features; |
1003 | /* user-changeable features */ | 1004 | /* user-changeable features */ |
1004 | u32 hw_features; | 1005 | netdev_features_t hw_features; |
1005 | /* user-requested features */ | 1006 | /* user-requested features */ |
1006 | u32 wanted_features; | 1007 | netdev_features_t wanted_features; |
1007 | /* mask of features inheritable by VLAN devices */ | 1008 | /* mask of features inheritable by VLAN devices */ |
1008 | u32 vlan_features; | 1009 | netdev_features_t vlan_features; |
1009 | 1010 | ||
1010 | /* Interface index. Unique device identifier */ | 1011 | /* Interface index. Unique device identifier */ |
1011 | int ifindex; | 1012 | int ifindex; |
@@ -1439,7 +1440,7 @@ struct packet_type { | |||
1439 | struct packet_type *, | 1440 | struct packet_type *, |
1440 | struct net_device *); | 1441 | struct net_device *); |
1441 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, | 1442 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, |
1442 | u32 features); | 1443 | netdev_features_t features); |
1443 | int (*gso_send_check)(struct sk_buff *skb); | 1444 | int (*gso_send_check)(struct sk_buff *skb); |
1444 | struct sk_buff **(*gro_receive)(struct sk_buff **head, | 1445 | struct sk_buff **(*gro_receive)(struct sk_buff **head, |
1445 | struct sk_buff *skb); | 1446 | struct sk_buff *skb); |
@@ -2444,7 +2445,8 @@ extern int netdev_set_master(struct net_device *dev, struct net_device *master) | |||
2444 | extern int netdev_set_bond_master(struct net_device *dev, | 2445 | extern int netdev_set_bond_master(struct net_device *dev, |
2445 | struct net_device *master); | 2446 | struct net_device *master); |
2446 | extern int skb_checksum_help(struct sk_buff *skb); | 2447 | extern int skb_checksum_help(struct sk_buff *skb); |
2447 | extern struct sk_buff *skb_gso_segment(struct sk_buff *skb, u32 features); | 2448 | extern struct sk_buff *skb_gso_segment(struct sk_buff *skb, |
2449 | netdev_features_t features); | ||
2448 | #ifdef CONFIG_BUG | 2450 | #ifdef CONFIG_BUG |
2449 | extern void netdev_rx_csum_fault(struct net_device *dev); | 2451 | extern void netdev_rx_csum_fault(struct net_device *dev); |
2450 | #else | 2452 | #else |
@@ -2471,11 +2473,13 @@ extern const char *netdev_drivername(const struct net_device *dev); | |||
2471 | 2473 | ||
2472 | extern void linkwatch_run_queue(void); | 2474 | extern void linkwatch_run_queue(void); |
2473 | 2475 | ||
2474 | static inline u32 netdev_get_wanted_features(struct net_device *dev) | 2476 | static inline netdev_features_t netdev_get_wanted_features( |
2477 | struct net_device *dev) | ||
2475 | { | 2478 | { |
2476 | return (dev->features & ~dev->hw_features) | dev->wanted_features; | 2479 | return (dev->features & ~dev->hw_features) | dev->wanted_features; |
2477 | } | 2480 | } |
2478 | u32 netdev_increment_features(u32 all, u32 one, u32 mask); | 2481 | netdev_features_t netdev_increment_features(netdev_features_t all, |
2482 | netdev_features_t one, netdev_features_t mask); | ||
2479 | int __netdev_update_features(struct net_device *dev); | 2483 | int __netdev_update_features(struct net_device *dev); |
2480 | void netdev_update_features(struct net_device *dev); | 2484 | void netdev_update_features(struct net_device *dev); |
2481 | void netdev_change_features(struct net_device *dev); | 2485 | void netdev_change_features(struct net_device *dev); |
@@ -2483,21 +2487,22 @@ void netdev_change_features(struct net_device *dev); | |||
2483 | void netif_stacked_transfer_operstate(const struct net_device *rootdev, | 2487 | void netif_stacked_transfer_operstate(const struct net_device *rootdev, |
2484 | struct net_device *dev); | 2488 | struct net_device *dev); |
2485 | 2489 | ||
2486 | u32 netif_skb_features(struct sk_buff *skb); | 2490 | netdev_features_t netif_skb_features(struct sk_buff *skb); |
2487 | 2491 | ||
2488 | static inline int net_gso_ok(u32 features, int gso_type) | 2492 | static inline int net_gso_ok(netdev_features_t features, int gso_type) |
2489 | { | 2493 | { |
2490 | int feature = gso_type << NETIF_F_GSO_SHIFT; | 2494 | netdev_features_t feature = gso_type << NETIF_F_GSO_SHIFT; |
2491 | return (features & feature) == feature; | 2495 | return (features & feature) == feature; |
2492 | } | 2496 | } |
2493 | 2497 | ||
2494 | static inline int skb_gso_ok(struct sk_buff *skb, u32 features) | 2498 | static inline int skb_gso_ok(struct sk_buff *skb, netdev_features_t features) |
2495 | { | 2499 | { |
2496 | return net_gso_ok(features, skb_shinfo(skb)->gso_type) && | 2500 | return net_gso_ok(features, skb_shinfo(skb)->gso_type) && |
2497 | (!skb_has_frag_list(skb) || (features & NETIF_F_FRAGLIST)); | 2501 | (!skb_has_frag_list(skb) || (features & NETIF_F_FRAGLIST)); |
2498 | } | 2502 | } |
2499 | 2503 | ||
2500 | static inline int netif_needs_gso(struct sk_buff *skb, int features) | 2504 | static inline int netif_needs_gso(struct sk_buff *skb, |
2505 | netdev_features_t features) | ||
2501 | { | 2506 | { |
2502 | return skb_is_gso(skb) && (!skb_gso_ok(skb, features) || | 2507 | return skb_is_gso(skb) && (!skb_gso_ok(skb, features) || |
2503 | unlikely(skb->ip_summed != CHECKSUM_PARTIAL)); | 2508 | unlikely(skb->ip_summed != CHECKSUM_PARTIAL)); |
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index abad8a0941e8..a10e487c0864 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/dmaengine.h> | 30 | #include <linux/dmaengine.h> |
31 | #include <linux/hrtimer.h> | 31 | #include <linux/hrtimer.h> |
32 | #include <linux/dma-mapping.h> | 32 | #include <linux/dma-mapping.h> |
33 | #include <linux/netdev_features.h> | ||
33 | 34 | ||
34 | /* Don't change this without changing skb_csum_unnecessary! */ | 35 | /* Don't change this without changing skb_csum_unnecessary! */ |
35 | #define CHECKSUM_NONE 0 | 36 | #define CHECKSUM_NONE 0 |
@@ -2106,7 +2107,8 @@ extern void skb_split(struct sk_buff *skb, | |||
2106 | extern int skb_shift(struct sk_buff *tgt, struct sk_buff *skb, | 2107 | extern int skb_shift(struct sk_buff *tgt, struct sk_buff *skb, |
2107 | int shiftlen); | 2108 | int shiftlen); |
2108 | 2109 | ||
2109 | extern struct sk_buff *skb_segment(struct sk_buff *skb, u32 features); | 2110 | extern struct sk_buff *skb_segment(struct sk_buff *skb, |
2111 | netdev_features_t features); | ||
2110 | 2112 | ||
2111 | static inline void *skb_header_pointer(const struct sk_buff *skb, int offset, | 2113 | static inline void *skb_header_pointer(const struct sk_buff *skb, int offset, |
2112 | int len, void *buffer) | 2114 | int len, void *buffer) |
diff --git a/include/net/protocol.h b/include/net/protocol.h index 6f7eb800974a..e182e13d6391 100644 --- a/include/net/protocol.h +++ b/include/net/protocol.h | |||
@@ -38,7 +38,7 @@ struct net_protocol { | |||
38 | void (*err_handler)(struct sk_buff *skb, u32 info); | 38 | void (*err_handler)(struct sk_buff *skb, u32 info); |
39 | int (*gso_send_check)(struct sk_buff *skb); | 39 | int (*gso_send_check)(struct sk_buff *skb); |
40 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, | 40 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, |
41 | u32 features); | 41 | netdev_features_t features); |
42 | struct sk_buff **(*gro_receive)(struct sk_buff **head, | 42 | struct sk_buff **(*gro_receive)(struct sk_buff **head, |
43 | struct sk_buff *skb); | 43 | struct sk_buff *skb); |
44 | int (*gro_complete)(struct sk_buff *skb); | 44 | int (*gro_complete)(struct sk_buff *skb); |
@@ -57,7 +57,7 @@ struct inet6_protocol { | |||
57 | 57 | ||
58 | int (*gso_send_check)(struct sk_buff *skb); | 58 | int (*gso_send_check)(struct sk_buff *skb); |
59 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, | 59 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, |
60 | u32 features); | 60 | netdev_features_t features); |
61 | struct sk_buff **(*gro_receive)(struct sk_buff **head, | 61 | struct sk_buff **(*gro_receive)(struct sk_buff **head, |
62 | struct sk_buff *skb); | 62 | struct sk_buff *skb); |
63 | int (*gro_complete)(struct sk_buff *skb); | 63 | int (*gro_complete)(struct sk_buff *skb); |
diff --git a/include/net/sock.h b/include/net/sock.h index 67cd4581b6da..1331008ad885 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -306,8 +306,8 @@ struct sock { | |||
306 | kmemcheck_bitfield_end(flags); | 306 | kmemcheck_bitfield_end(flags); |
307 | int sk_wmem_queued; | 307 | int sk_wmem_queued; |
308 | gfp_t sk_allocation; | 308 | gfp_t sk_allocation; |
309 | int sk_route_caps; | 309 | netdev_features_t sk_route_caps; |
310 | int sk_route_nocaps; | 310 | netdev_features_t sk_route_nocaps; |
311 | int sk_gso_type; | 311 | int sk_gso_type; |
312 | unsigned int sk_gso_max_size; | 312 | unsigned int sk_gso_max_size; |
313 | int sk_rcvlowat; | 313 | int sk_rcvlowat; |
@@ -1393,7 +1393,7 @@ static inline int sk_can_gso(const struct sock *sk) | |||
1393 | 1393 | ||
1394 | extern void sk_setup_caps(struct sock *sk, struct dst_entry *dst); | 1394 | extern void sk_setup_caps(struct sock *sk, struct dst_entry *dst); |
1395 | 1395 | ||
1396 | static inline void sk_nocaps_add(struct sock *sk, int flags) | 1396 | static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags) |
1397 | { | 1397 | { |
1398 | sk->sk_route_nocaps |= flags; | 1398 | sk->sk_route_nocaps |= flags; |
1399 | sk->sk_route_caps &= ~flags; | 1399 | sk->sk_route_caps &= ~flags; |
diff --git a/include/net/tcp.h b/include/net/tcp.h index bb18c4d69aba..113160b84588 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -1430,7 +1430,8 @@ extern struct request_sock_ops tcp6_request_sock_ops; | |||
1430 | extern void tcp_v4_destroy_sock(struct sock *sk); | 1430 | extern void tcp_v4_destroy_sock(struct sock *sk); |
1431 | 1431 | ||
1432 | extern int tcp_v4_gso_send_check(struct sk_buff *skb); | 1432 | extern int tcp_v4_gso_send_check(struct sk_buff *skb); |
1433 | extern struct sk_buff *tcp_tso_segment(struct sk_buff *skb, u32 features); | 1433 | extern struct sk_buff *tcp_tso_segment(struct sk_buff *skb, |
1434 | netdev_features_t features); | ||
1434 | extern struct sk_buff **tcp_gro_receive(struct sk_buff **head, | 1435 | extern struct sk_buff **tcp_gro_receive(struct sk_buff **head, |
1435 | struct sk_buff *skb); | 1436 | struct sk_buff *skb); |
1436 | extern struct sk_buff **tcp4_gro_receive(struct sk_buff **head, | 1437 | extern struct sk_buff **tcp4_gro_receive(struct sk_buff **head, |
diff --git a/include/net/udp.h b/include/net/udp.h index 3b285f402f48..f54a5156b248 100644 --- a/include/net/udp.h +++ b/include/net/udp.h | |||
@@ -258,5 +258,6 @@ extern void udp4_proc_exit(void); | |||
258 | extern void udp_init(void); | 258 | extern void udp_init(void); |
259 | 259 | ||
260 | extern int udp4_ufo_send_check(struct sk_buff *skb); | 260 | extern int udp4_ufo_send_check(struct sk_buff *skb); |
261 | extern struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, u32 features); | 261 | extern struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, |
262 | netdev_features_t features); | ||
262 | #endif /* _UDP_H */ | 263 | #endif /* _UDP_H */ |