提交 d5a9e24a 编写于 作者: D David S. Miller

net: Allow RX queue selection to seed TX queue hashing.

The idea is that drivers which implement multiqueue RX
pre-seed the SKB by recording the RX queue selected by
the hardware.

If such a seed is found on TX, we'll use that to select
the outgoing TX queue.

This helps get more consistent load balancing on router
and firewall loads.
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 a73efd0a
...@@ -1904,6 +1904,21 @@ static inline void skb_copy_queue_mapping(struct sk_buff *to, const struct sk_bu ...@@ -1904,6 +1904,21 @@ static inline void skb_copy_queue_mapping(struct sk_buff *to, const struct sk_bu
to->queue_mapping = from->queue_mapping; to->queue_mapping = from->queue_mapping;
} }
static inline void skb_record_rx_queue(struct sk_buff *skb, u16 rx_queue)
{
skb->queue_mapping = rx_queue + 1;
}
static inline u16 skb_get_rx_queue(struct sk_buff *skb)
{
return skb->queue_mapping - 1;
}
static inline bool skb_rx_queue_recorded(struct sk_buff *skb)
{
return (skb->queue_mapping != 0);
}
#ifdef CONFIG_XFRM #ifdef CONFIG_XFRM
static inline struct sec_path *skb_sec_path(struct sk_buff *skb) static inline struct sec_path *skb_sec_path(struct sk_buff *skb)
{ {
......
...@@ -1722,6 +1722,13 @@ static u16 simple_tx_hash(struct net_device *dev, struct sk_buff *skb) ...@@ -1722,6 +1722,13 @@ static u16 simple_tx_hash(struct net_device *dev, struct sk_buff *skb)
simple_tx_hashrnd_initialized = 1; simple_tx_hashrnd_initialized = 1;
} }
if (skb_rx_queue_recorded(skb)) {
u32 val = skb_get_rx_queue(skb);
hash = jhash_1word(val, simple_tx_hashrnd);
goto out;
}
switch (skb->protocol) { switch (skb->protocol) {
case htons(ETH_P_IP): case htons(ETH_P_IP):
if (!(ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET))) if (!(ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)))
...@@ -1759,6 +1766,7 @@ static u16 simple_tx_hash(struct net_device *dev, struct sk_buff *skb) ...@@ -1759,6 +1766,7 @@ static u16 simple_tx_hash(struct net_device *dev, struct sk_buff *skb)
hash = jhash_3words(addr1, addr2, ports, simple_tx_hashrnd); hash = jhash_3words(addr1, addr2, ports, simple_tx_hashrnd);
out:
return (u16) (((u64) hash * dev->real_num_tx_queues) >> 32); return (u16) (((u64) hash * dev->real_num_tx_queues) >> 32);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册