net: Add priority to packet_offload objects.
authorDavid S. Miller <davem@davemloft.net>
Mon, 1 Jun 2015 21:56:09 +0000 (14:56 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 1 Jun 2015 21:56:09 +0000 (14:56 -0700)
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: Eric Dumazet <eric.dumazet@gmail.com>
Suggested-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/netdevice.h
net/core/dev.c
net/ethernet/eth.c
net/mpls/mpls_gso.c

index 51f8d2f5dc3fd025ba663a274e20837d69f38533..6f5f71ff51697686e5b549681181bfbdbcd55f90 100644 (file)
@@ -1997,6 +1997,7 @@ struct offload_callbacks {
 
 struct packet_offload {
        __be16                   type;  /* This is really htons(ether_type). */
+       u16                      priority;
        struct offload_callbacks callbacks;
        struct list_head         list;
 };
index 594163d0c6eb894ecc8985ec30edae8b460efc78..0602e917a3053ac9be3cc7f1f495e3eb7cdeadc5 100644 (file)
@@ -469,10 +469,14 @@ EXPORT_SYMBOL(dev_remove_pack);
  */
 void dev_add_offload(struct packet_offload *po)
 {
-       struct list_head *head = &offload_base;
+       struct packet_offload *elem;
 
        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);
 }
 EXPORT_SYMBOL(dev_add_offload);
index c3325bd2f3fbdc6afd5acc2f1a419c26c7d3815a..7d0e239a6755c66e0be12c39bca209bd2782f3b7 100644 (file)
@@ -470,6 +470,7 @@ EXPORT_SYMBOL(eth_gro_complete);
 
 static struct packet_offload eth_packet_offload __read_mostly = {
        .type = cpu_to_be16(ETH_P_TEB),
+       .priority = 10,
        .callbacks = {
                .gro_receive = eth_gro_receive,
                .gro_complete = eth_gro_complete,
index 809df534a7204916f10203ce55dcc3fdc0fe7b51..0183b32da9427d39aa761e00e080afeff7e4b6d5 100644 (file)
@@ -62,6 +62,7 @@ out:
 
 static struct packet_offload mpls_mc_offload __read_mostly = {
        .type = cpu_to_be16(ETH_P_MPLS_MC),
+       .priority = 15,
        .callbacks = {
                .gso_segment    =       mpls_gso_segment,
        },
@@ -69,6 +70,7 @@ static struct packet_offload mpls_mc_offload __read_mostly = {
 
 static struct packet_offload mpls_uc_offload __read_mostly = {
        .type = cpu_to_be16(ETH_P_MPLS_UC),
+       .priority = 15,
        .callbacks = {
                .gso_segment    =       mpls_gso_segment,
        },