aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Herbert <therbert@google.com>2014-07-02 00:32:27 -0400
committerDavid S. Miller <davem@davemloft.net>2014-07-08 00:14:21 -0400
commit0e001614e849b68cff94cda8db8b550569d3dba6 (patch)
tree270c7f51c6bbe62c662793729199afdcb4304759
parentb73c3d0e4f0e1961e15bec18720e48aabebe2109 (diff)
net: Call skb_get_hash in get_xps_queue and __skb_tx_hash
Call standard function to get a packet hash instead of taking this from skb->sk->sk_hash or only using skb->protocol. Signed-off-by: Tom Herbert <therbert@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/netdevice.h2
-rw-r--r--include/linux/skbuff.h2
-rw-r--r--net/core/flow_dissector.c29
3 files changed, 7 insertions, 26 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 66f9a04ec270..8b43a28ee0bc 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2486,7 +2486,7 @@ static inline int netif_set_xps_queue(struct net_device *dev,
2486 * as a distribution range limit for the returned value. 2486 * as a distribution range limit for the returned value.
2487 */ 2487 */
2488static inline u16 skb_tx_hash(const struct net_device *dev, 2488static inline u16 skb_tx_hash(const struct net_device *dev,
2489 const struct sk_buff *skb) 2489 struct sk_buff *skb)
2490{ 2490{
2491 return __skb_tx_hash(dev, skb, dev->real_num_tx_queues); 2491 return __skb_tx_hash(dev, skb, dev->real_num_tx_queues);
2492} 2492}
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index ec89301ada41..b297af70ac30 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3005,7 +3005,7 @@ static inline bool skb_rx_queue_recorded(const struct sk_buff *skb)
3005 return skb->queue_mapping != 0; 3005 return skb->queue_mapping != 0;
3006} 3006}
3007 3007
3008u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb, 3008u16 __skb_tx_hash(const struct net_device *dev, struct sk_buff *skb,
3009 unsigned int num_tx_queues); 3009 unsigned int num_tx_queues);
3010 3010
3011static inline struct sec_path *skb_sec_path(struct sk_buff *skb) 3011static inline struct sec_path *skb_sec_path(struct sk_buff *skb)
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index 2ff8cd4dfc5f..62d1cb624f53 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -196,12 +196,6 @@ static __always_inline u32 __flow_hash_3words(u32 a, u32 b, u32 c)
196 return jhash_3words(a, b, c, hashrnd); 196 return jhash_3words(a, b, c, hashrnd);
197} 197}
198 198
199static __always_inline u32 __flow_hash_1word(u32 a)
200{
201 __flow_hash_secret_init();
202 return jhash_1word(a, hashrnd);
203}
204
205static inline u32 __flow_hash_from_keys(struct flow_keys *keys) 199static inline u32 __flow_hash_from_keys(struct flow_keys *keys)
206{ 200{
207 u32 hash; 201 u32 hash;
@@ -253,7 +247,7 @@ EXPORT_SYMBOL(__skb_get_hash);
253 * Returns a Tx hash based on the given packet descriptor a Tx queues' number 247 * Returns a Tx hash based on the given packet descriptor a Tx queues' number
254 * to be used as a distribution range. 248 * to be used as a distribution range.
255 */ 249 */
256u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb, 250u16 __skb_tx_hash(const struct net_device *dev, struct sk_buff *skb,
257 unsigned int num_tx_queues) 251 unsigned int num_tx_queues)
258{ 252{
259 u32 hash; 253 u32 hash;
@@ -273,13 +267,7 @@ u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb,
273 qcount = dev->tc_to_txq[tc].count; 267 qcount = dev->tc_to_txq[tc].count;
274 } 268 }
275 269
276 if (skb->sk && skb->sk->sk_hash) 270 return (u16) (((u64)skb_get_hash(skb) * qcount) >> 32) + qoffset;
277 hash = skb->sk->sk_hash;
278 else
279 hash = (__force u16) skb->protocol;
280 hash = __flow_hash_1word(hash);
281
282 return (u16) (((u64) hash * qcount) >> 32) + qoffset;
283} 271}
284EXPORT_SYMBOL(__skb_tx_hash); 272EXPORT_SYMBOL(__skb_tx_hash);
285 273
@@ -351,17 +339,10 @@ static inline int get_xps_queue(struct net_device *dev, struct sk_buff *skb)
351 if (map) { 339 if (map) {
352 if (map->len == 1) 340 if (map->len == 1)
353 queue_index = map->queues[0]; 341 queue_index = map->queues[0];
354 else { 342 else
355 u32 hash;
356 if (skb->sk && skb->sk->sk_hash)
357 hash = skb->sk->sk_hash;
358 else
359 hash = (__force u16) skb->protocol ^
360 skb->hash;
361 hash = __flow_hash_1word(hash);
362 queue_index = map->queues[ 343 queue_index = map->queues[
363 ((u64)hash * map->len) >> 32]; 344 ((u64)skb_get_hash(skb) * map->len) >> 32];
364 } 345
365 if (unlikely(queue_index >= dev->real_num_tx_queues)) 346 if (unlikely(queue_index >= dev->real_num_tx_queues))
366 queue_index = -1; 347 queue_index = -1;
367 } 348 }