aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladislav Zolotarov <vladz@broadcom.com>2010-12-13 01:27:10 -0500
committerDavid S. Miller <davem@davemloft.net>2010-12-16 16:15:53 -0500
commita3d22a68d752ccc1a01bb0a64dd70b7a98bf9e23 (patch)
treee51c231b29d8e285acb8196b6b893c718febd2b1
parentd33e455337ea2c71d09d7f4367d6ad6dd32b6965 (diff)
bnx2x: Take the distribution range definition out of skb_tx_hash()
Move the calcualation of the Tx hash for a given hash range into a separate function and define the skb_tx_hash(), which calculates a Tx hash for a [0; dev->real_num_tx_queues - 1] hash values range, using this function (__skb_tx_hash()). Signed-off-by: Vladislav Zolotarov <vladz@broadcom.com> Signed-off-by: Eilon Greenstein <eilong@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/netdevice.h10
-rw-r--r--include/linux/skbuff.h5
-rw-r--r--net/core/dev.c15
3 files changed, 23 insertions, 7 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index d31bc3c94717..445e6825f8eb 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1747,6 +1747,16 @@ static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
1747 __netif_schedule(txq->qdisc); 1747 __netif_schedule(txq->qdisc);
1748} 1748}
1749 1749
1750/*
1751 * Returns a Tx hash for the given packet when dev->real_num_tx_queues is used
1752 * as a distribution range limit for the returned value.
1753 */
1754static inline u16 skb_tx_hash(const struct net_device *dev,
1755 const struct sk_buff *skb)
1756{
1757 return __skb_tx_hash(dev, skb, dev->real_num_tx_queues);
1758}
1759
1750/** 1760/**
1751 * netif_is_multiqueue - test if device has multiple transmit queues 1761 * netif_is_multiqueue - test if device has multiple transmit queues
1752 * @dev: network device 1762 * @dev: network device
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 19f37a6ee6c4..4c4bec6316d9 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2165,8 +2165,9 @@ static inline bool skb_rx_queue_recorded(const struct sk_buff *skb)
2165 return skb->queue_mapping != 0; 2165 return skb->queue_mapping != 0;
2166} 2166}
2167 2167
2168extern u16 skb_tx_hash(const struct net_device *dev, 2168extern u16 __skb_tx_hash(const struct net_device *dev,
2169 const struct sk_buff *skb); 2169 const struct sk_buff *skb,
2170 unsigned int num_tx_queues);
2170 2171
2171#ifdef CONFIG_XFRM 2172#ifdef CONFIG_XFRM
2172static inline struct sec_path *skb_sec_path(struct sk_buff *skb) 2173static inline struct sec_path *skb_sec_path(struct sk_buff *skb)
diff --git a/net/core/dev.c b/net/core/dev.c
index d28b3a023bb2..b25dd087f06a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2112,14 +2112,19 @@ out:
2112 2112
2113static u32 hashrnd __read_mostly; 2113static u32 hashrnd __read_mostly;
2114 2114
2115u16 skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb) 2115/*
2116 * Returns a Tx hash based on the given packet descriptor a Tx queues' number
2117 * to be used as a distribution range.
2118 */
2119u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb,
2120 unsigned int num_tx_queues)
2116{ 2121{
2117 u32 hash; 2122 u32 hash;
2118 2123
2119 if (skb_rx_queue_recorded(skb)) { 2124 if (skb_rx_queue_recorded(skb)) {
2120 hash = skb_get_rx_queue(skb); 2125 hash = skb_get_rx_queue(skb);
2121 while (unlikely(hash >= dev->real_num_tx_queues)) 2126 while (unlikely(hash >= num_tx_queues))
2122 hash -= dev->real_num_tx_queues; 2127 hash -= num_tx_queues;
2123 return hash; 2128 return hash;
2124 } 2129 }
2125 2130
@@ -2129,9 +2134,9 @@ u16 skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb)
2129 hash = (__force u16) skb->protocol ^ skb->rxhash; 2134 hash = (__force u16) skb->protocol ^ skb->rxhash;
2130 hash = jhash_1word(hash, hashrnd); 2135 hash = jhash_1word(hash, hashrnd);
2131 2136
2132 return (u16) (((u64) hash * dev->real_num_tx_queues) >> 32); 2137 return (u16) (((u64) hash * num_tx_queues) >> 32);
2133} 2138}
2134EXPORT_SYMBOL(skb_tx_hash); 2139EXPORT_SYMBOL(__skb_tx_hash);
2135 2140
2136static inline u16 dev_cap_txqueue(struct net_device *dev, u16 queue_index) 2141static inline u16 dev_cap_txqueue(struct net_device *dev, u16 queue_index)
2137{ 2142{