Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 225163
b: refs/heads/master
c: a3d22a6
h: refs/heads/master
i:
  225161: e166597
  225159: fcc88b1
v: v3
  • Loading branch information
Vladislav Zolotarov authored and David S. Miller committed Dec 16, 2010
1 parent 0cd1bfc commit c629c43
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d33e455337ea2c71d09d7f4367d6ad6dd32b6965
refs/heads/master: a3d22a68d752ccc1a01bb0a64dd70b7a98bf9e23
10 changes: 10 additions & 0 deletions trunk/include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -1747,6 +1747,16 @@ static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
__netif_schedule(txq->qdisc);
}

/*
* Returns a Tx hash for the given packet when dev->real_num_tx_queues is used
* as a distribution range limit for the returned value.
*/
static inline u16 skb_tx_hash(const struct net_device *dev,
const struct sk_buff *skb)
{
return __skb_tx_hash(dev, skb, dev->real_num_tx_queues);
}

/**
* netif_is_multiqueue - test if device has multiple transmit queues
* @dev: network device
Expand Down
5 changes: 3 additions & 2 deletions trunk/include/linux/skbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -2165,8 +2165,9 @@ static inline bool skb_rx_queue_recorded(const struct sk_buff *skb)
return skb->queue_mapping != 0;
}

extern u16 skb_tx_hash(const struct net_device *dev,
const struct sk_buff *skb);
extern u16 __skb_tx_hash(const struct net_device *dev,
const struct sk_buff *skb,
unsigned int num_tx_queues);

#ifdef CONFIG_XFRM
static inline struct sec_path *skb_sec_path(struct sk_buff *skb)
Expand Down
15 changes: 10 additions & 5 deletions trunk/net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2112,14 +2112,19 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,

static u32 hashrnd __read_mostly;

u16 skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb)
/*
* 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, const struct sk_buff *skb,
unsigned int num_tx_queues)
{
u32 hash;

if (skb_rx_queue_recorded(skb)) {
hash = skb_get_rx_queue(skb);
while (unlikely(hash >= dev->real_num_tx_queues))
hash -= dev->real_num_tx_queues;
while (unlikely(hash >= num_tx_queues))
hash -= num_tx_queues;
return hash;
}

Expand All @@ -2129,9 +2134,9 @@ u16 skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb)
hash = (__force u16) skb->protocol ^ skb->rxhash;
hash = jhash_1word(hash, hashrnd);

return (u16) (((u64) hash * dev->real_num_tx_queues) >> 32);
return (u16) (((u64) hash * num_tx_queues) >> 32);
}
EXPORT_SYMBOL(skb_tx_hash);
EXPORT_SYMBOL(__skb_tx_hash);

static inline u16 dev_cap_txqueue(struct net_device *dev, u16 queue_index)
{
Expand Down

0 comments on commit c629c43

Please sign in to comment.