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 /net/core/dev.c | |
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 'net/core/dev.c')
-rw-r--r-- | net/core/dev.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 185e246d61fd..f1cca59c4638 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -1914,7 +1914,8 @@ EXPORT_SYMBOL(skb_checksum_help); | |||
1914 | * It may return NULL if the skb requires no segmentation. This is | 1914 | * It may return NULL if the skb requires no segmentation. This is |
1915 | * only possible when GSO is used for verifying header integrity. | 1915 | * only possible when GSO is used for verifying header integrity. |
1916 | */ | 1916 | */ |
1917 | struct sk_buff *skb_gso_segment(struct sk_buff *skb, u32 features) | 1917 | struct sk_buff *skb_gso_segment(struct sk_buff *skb, |
1918 | netdev_features_t features) | ||
1918 | { | 1919 | { |
1919 | struct sk_buff *segs = ERR_PTR(-EPROTONOSUPPORT); | 1920 | struct sk_buff *segs = ERR_PTR(-EPROTONOSUPPORT); |
1920 | struct packet_type *ptype; | 1921 | struct packet_type *ptype; |
@@ -1944,9 +1945,9 @@ struct sk_buff *skb_gso_segment(struct sk_buff *skb, u32 features) | |||
1944 | if (dev && dev->ethtool_ops && dev->ethtool_ops->get_drvinfo) | 1945 | if (dev && dev->ethtool_ops && dev->ethtool_ops->get_drvinfo) |
1945 | dev->ethtool_ops->get_drvinfo(dev, &info); | 1946 | dev->ethtool_ops->get_drvinfo(dev, &info); |
1946 | 1947 | ||
1947 | WARN(1, "%s: caps=(0x%lx, 0x%lx) len=%d data_len=%d ip_summed=%d\n", | 1948 | WARN(1, "%s: caps=(%pNF, %pNF) len=%d data_len=%d ip_summed=%d\n", |
1948 | info.driver, dev ? dev->features : 0L, | 1949 | info.driver, dev ? &dev->features : NULL, |
1949 | skb->sk ? skb->sk->sk_route_caps : 0L, | 1950 | skb->sk ? &skb->sk->sk_route_caps : NULL, |
1950 | skb->len, skb->data_len, skb->ip_summed); | 1951 | skb->len, skb->data_len, skb->ip_summed); |
1951 | 1952 | ||
1952 | if (skb_header_cloned(skb) && | 1953 | if (skb_header_cloned(skb) && |
@@ -2055,7 +2056,7 @@ static void dev_gso_skb_destructor(struct sk_buff *skb) | |||
2055 | * This function segments the given skb and stores the list of segments | 2056 | * This function segments the given skb and stores the list of segments |
2056 | * in skb->next. | 2057 | * in skb->next. |
2057 | */ | 2058 | */ |
2058 | static int dev_gso_segment(struct sk_buff *skb, int features) | 2059 | static int dev_gso_segment(struct sk_buff *skb, netdev_features_t features) |
2059 | { | 2060 | { |
2060 | struct sk_buff *segs; | 2061 | struct sk_buff *segs; |
2061 | 2062 | ||
@@ -2094,7 +2095,7 @@ static inline void skb_orphan_try(struct sk_buff *skb) | |||
2094 | } | 2095 | } |
2095 | } | 2096 | } |
2096 | 2097 | ||
2097 | static bool can_checksum_protocol(unsigned long features, __be16 protocol) | 2098 | static bool can_checksum_protocol(netdev_features_t features, __be16 protocol) |
2098 | { | 2099 | { |
2099 | return ((features & NETIF_F_GEN_CSUM) || | 2100 | return ((features & NETIF_F_GEN_CSUM) || |
2100 | ((features & NETIF_F_V4_CSUM) && | 2101 | ((features & NETIF_F_V4_CSUM) && |
@@ -2105,7 +2106,8 @@ static bool can_checksum_protocol(unsigned long features, __be16 protocol) | |||
2105 | protocol == htons(ETH_P_FCOE))); | 2106 | protocol == htons(ETH_P_FCOE))); |
2106 | } | 2107 | } |
2107 | 2108 | ||
2108 | static u32 harmonize_features(struct sk_buff *skb, __be16 protocol, u32 features) | 2109 | static netdev_features_t harmonize_features(struct sk_buff *skb, |
2110 | __be16 protocol, netdev_features_t features) | ||
2109 | { | 2111 | { |
2110 | if (!can_checksum_protocol(features, protocol)) { | 2112 | if (!can_checksum_protocol(features, protocol)) { |
2111 | features &= ~NETIF_F_ALL_CSUM; | 2113 | features &= ~NETIF_F_ALL_CSUM; |
@@ -2117,10 +2119,10 @@ static u32 harmonize_features(struct sk_buff *skb, __be16 protocol, u32 features | |||
2117 | return features; | 2119 | return features; |
2118 | } | 2120 | } |
2119 | 2121 | ||
2120 | u32 netif_skb_features(struct sk_buff *skb) | 2122 | netdev_features_t netif_skb_features(struct sk_buff *skb) |
2121 | { | 2123 | { |
2122 | __be16 protocol = skb->protocol; | 2124 | __be16 protocol = skb->protocol; |
2123 | u32 features = skb->dev->features; | 2125 | netdev_features_t features = skb->dev->features; |
2124 | 2126 | ||
2125 | if (protocol == htons(ETH_P_8021Q)) { | 2127 | if (protocol == htons(ETH_P_8021Q)) { |
2126 | struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data; | 2128 | struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data; |
@@ -2166,7 +2168,7 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, | |||
2166 | unsigned int skb_len; | 2168 | unsigned int skb_len; |
2167 | 2169 | ||
2168 | if (likely(!skb->next)) { | 2170 | if (likely(!skb->next)) { |
2169 | u32 features; | 2171 | netdev_features_t features; |
2170 | 2172 | ||
2171 | /* | 2173 | /* |
2172 | * If device doesn't need skb->dst, release it right now while | 2174 | * If device doesn't need skb->dst, release it right now while |
@@ -5350,7 +5352,8 @@ static void rollback_registered(struct net_device *dev) | |||
5350 | list_del(&single); | 5352 | list_del(&single); |
5351 | } | 5353 | } |
5352 | 5354 | ||
5353 | static u32 netdev_fix_features(struct net_device *dev, u32 features) | 5355 | static netdev_features_t netdev_fix_features(struct net_device *dev, |
5356 | netdev_features_t features) | ||
5354 | { | 5357 | { |
5355 | /* Fix illegal checksum combinations */ | 5358 | /* Fix illegal checksum combinations */ |
5356 | if ((features & NETIF_F_HW_CSUM) && | 5359 | if ((features & NETIF_F_HW_CSUM) && |
@@ -5412,7 +5415,7 @@ static u32 netdev_fix_features(struct net_device *dev, u32 features) | |||
5412 | 5415 | ||
5413 | int __netdev_update_features(struct net_device *dev) | 5416 | int __netdev_update_features(struct net_device *dev) |
5414 | { | 5417 | { |
5415 | u32 features; | 5418 | netdev_features_t features; |
5416 | int err = 0; | 5419 | int err = 0; |
5417 | 5420 | ||
5418 | ASSERT_RTNL(); | 5421 | ASSERT_RTNL(); |
@@ -5428,16 +5431,16 @@ int __netdev_update_features(struct net_device *dev) | |||
5428 | if (dev->features == features) | 5431 | if (dev->features == features) |
5429 | return 0; | 5432 | return 0; |
5430 | 5433 | ||
5431 | netdev_dbg(dev, "Features changed: 0x%08x -> 0x%08x\n", | 5434 | netdev_dbg(dev, "Features changed: %pNF -> %pNF\n", |
5432 | dev->features, features); | 5435 | &dev->features, &features); |
5433 | 5436 | ||
5434 | if (dev->netdev_ops->ndo_set_features) | 5437 | if (dev->netdev_ops->ndo_set_features) |
5435 | err = dev->netdev_ops->ndo_set_features(dev, features); | 5438 | err = dev->netdev_ops->ndo_set_features(dev, features); |
5436 | 5439 | ||
5437 | if (unlikely(err < 0)) { | 5440 | if (unlikely(err < 0)) { |
5438 | netdev_err(dev, | 5441 | netdev_err(dev, |
5439 | "set_features() failed (%d); wanted 0x%08x, left 0x%08x\n", | 5442 | "set_features() failed (%d); wanted %pNF, left %pNF\n", |
5440 | err, features, dev->features); | 5443 | err, &features, &dev->features); |
5441 | return -1; | 5444 | return -1; |
5442 | } | 5445 | } |
5443 | 5446 | ||
@@ -6361,7 +6364,8 @@ static int dev_cpu_callback(struct notifier_block *nfb, | |||
6361 | * @one to the master device with current feature set @all. Will not | 6364 | * @one to the master device with current feature set @all. Will not |
6362 | * enable anything that is off in @mask. Returns the new feature set. | 6365 | * enable anything that is off in @mask. Returns the new feature set. |
6363 | */ | 6366 | */ |
6364 | u32 netdev_increment_features(u32 all, u32 one, u32 mask) | 6367 | netdev_features_t netdev_increment_features(netdev_features_t all, |
6368 | netdev_features_t one, netdev_features_t mask) | ||
6365 | { | 6369 | { |
6366 | if (mask & NETIF_F_GEN_CSUM) | 6370 | if (mask & NETIF_F_GEN_CSUM) |
6367 | mask |= NETIF_F_ALL_CSUM; | 6371 | mask |= NETIF_F_ALL_CSUM; |