Commit bdef7de4 authored by David S. Miller's avatar David S. Miller

net: Add priority to packet_offload objects.

When we scan a packet for GRO processing, we want to see the most
common packet types in the front of the offload_base list.

So add a priority field so we can handle this properly.

IPv4/IPv6 get the highest priority with the implicit zero priority
field.

Next comes ethernet with a priority of 10, and then we have the MPLS
types with a priority of 15.
Suggested-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Suggested-by: default avatarToshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 493be55a
...@@ -1997,6 +1997,7 @@ struct offload_callbacks { ...@@ -1997,6 +1997,7 @@ struct offload_callbacks {
struct packet_offload { struct packet_offload {
__be16 type; /* This is really htons(ether_type). */ __be16 type; /* This is really htons(ether_type). */
u16 priority;
struct offload_callbacks callbacks; struct offload_callbacks callbacks;
struct list_head list; struct list_head list;
}; };
......
...@@ -469,10 +469,14 @@ EXPORT_SYMBOL(dev_remove_pack); ...@@ -469,10 +469,14 @@ EXPORT_SYMBOL(dev_remove_pack);
*/ */
void dev_add_offload(struct packet_offload *po) void dev_add_offload(struct packet_offload *po)
{ {
struct list_head *head = &offload_base; struct packet_offload *elem;
spin_lock(&offload_lock); spin_lock(&offload_lock);
list_add_rcu(&po->list, head); list_for_each_entry(elem, &offload_base, list) {
if (po->priority < elem->priority)
break;
}
list_add_rcu(&po->list, elem->list.prev);
spin_unlock(&offload_lock); spin_unlock(&offload_lock);
} }
EXPORT_SYMBOL(dev_add_offload); EXPORT_SYMBOL(dev_add_offload);
......
...@@ -470,6 +470,7 @@ EXPORT_SYMBOL(eth_gro_complete); ...@@ -470,6 +470,7 @@ EXPORT_SYMBOL(eth_gro_complete);
static struct packet_offload eth_packet_offload __read_mostly = { static struct packet_offload eth_packet_offload __read_mostly = {
.type = cpu_to_be16(ETH_P_TEB), .type = cpu_to_be16(ETH_P_TEB),
.priority = 10,
.callbacks = { .callbacks = {
.gro_receive = eth_gro_receive, .gro_receive = eth_gro_receive,
.gro_complete = eth_gro_complete, .gro_complete = eth_gro_complete,
......
...@@ -62,6 +62,7 @@ static struct sk_buff *mpls_gso_segment(struct sk_buff *skb, ...@@ -62,6 +62,7 @@ static struct sk_buff *mpls_gso_segment(struct sk_buff *skb,
static struct packet_offload mpls_mc_offload __read_mostly = { static struct packet_offload mpls_mc_offload __read_mostly = {
.type = cpu_to_be16(ETH_P_MPLS_MC), .type = cpu_to_be16(ETH_P_MPLS_MC),
.priority = 15,
.callbacks = { .callbacks = {
.gso_segment = mpls_gso_segment, .gso_segment = mpls_gso_segment,
}, },
...@@ -69,6 +70,7 @@ static struct packet_offload mpls_mc_offload __read_mostly = { ...@@ -69,6 +70,7 @@ static struct packet_offload mpls_mc_offload __read_mostly = {
static struct packet_offload mpls_uc_offload __read_mostly = { static struct packet_offload mpls_uc_offload __read_mostly = {
.type = cpu_to_be16(ETH_P_MPLS_UC), .type = cpu_to_be16(ETH_P_MPLS_UC),
.priority = 15,
.callbacks = { .callbacks = {
.gso_segment = mpls_gso_segment, .gso_segment = mpls_gso_segment,
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment