summaryrefslogtreecommitdiffstats
path: root/net/core/dev.c
diff options
context:
space:
mode:
authorJiri Pirko <jiri@resnulli.us>2015-05-12 14:56:12 +0200
committerDavid S. Miller <davem@davemloft.net>2015-05-13 15:19:46 -0400
commit5605c76240aadc823e3d46ac9afde2f26fbcf019 (patch)
treeeff41815ae63634daf67035e71fec38d546e4d1b /net/core/dev.c
parent9c684b5083bc191c4b7b189c73d75587e167a474 (diff)
downloadlinux-stable-5605c76240aadc823e3d46ac9afde2f26fbcf019.tar.gz
linux-stable-5605c76240aadc823e3d46ac9afde2f26fbcf019.tar.bz2
linux-stable-5605c76240aadc823e3d46ac9afde2f26fbcf019.zip
net: move __skb_tx_hash to dev.c
__skb_tx_hash function has no relation to flow_dissect so just move it to dev.c Signed-off-by: Jiri Pirko <jiri@resnulli.us> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 90a568a150b4..d044d2f8532b 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2350,6 +2350,34 @@ void netif_device_attach(struct net_device *dev)
}
EXPORT_SYMBOL(netif_device_attach);
+/*
+ * Returns a Tx hash based on the given packet descriptor a Tx queues' number
+ * to be used as a distribution range.
+ */
+u16 __skb_tx_hash(const struct net_device *dev, struct sk_buff *skb,
+ unsigned int num_tx_queues)
+{
+ u32 hash;
+ u16 qoffset = 0;
+ u16 qcount = num_tx_queues;
+
+ if (skb_rx_queue_recorded(skb)) {
+ hash = skb_get_rx_queue(skb);
+ while (unlikely(hash >= num_tx_queues))
+ hash -= num_tx_queues;
+ return hash;
+ }
+
+ if (dev->num_tc) {
+ u8 tc = netdev_get_prio_tc_map(dev, skb->priority);
+ qoffset = dev->tc_to_txq[tc].offset;
+ qcount = dev->tc_to_txq[tc].count;
+ }
+
+ return (u16) reciprocal_scale(skb_get_hash(skb), qcount) + qoffset;
+}
+EXPORT_SYMBOL(__skb_tx_hash);
+
static void skb_warn_bad_offload(const struct sk_buff *skb)
{
static const netdev_features_t null_features = 0;