Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 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>

+10 -2
+1
include/linux/netdevice.h
··· 1997 1997 1998 1998 struct packet_offload { 1999 1999 __be16 type; /* This is really htons(ether_type). */ 2000 + u16 priority; 2000 2001 struct offload_callbacks callbacks; 2001 2002 struct list_head list; 2002 2003 };
+6 -2
net/core/dev.c
··· 469 469 */ 470 470 void dev_add_offload(struct packet_offload *po) 471 471 { 472 - struct list_head *head = &offload_base; 472 + struct packet_offload *elem; 473 473 474 474 spin_lock(&offload_lock); 475 - list_add_rcu(&po->list, head); 475 + list_for_each_entry(elem, &offload_base, list) { 476 + if (po->priority < elem->priority) 477 + break; 478 + } 479 + list_add_rcu(&po->list, elem->list.prev); 476 480 spin_unlock(&offload_lock); 477 481 } 478 482 EXPORT_SYMBOL(dev_add_offload);
+1
net/ethernet/eth.c
··· 470 470 471 471 static struct packet_offload eth_packet_offload __read_mostly = { 472 472 .type = cpu_to_be16(ETH_P_TEB), 473 + .priority = 10, 473 474 .callbacks = { 474 475 .gro_receive = eth_gro_receive, 475 476 .gro_complete = eth_gro_complete,
+2
net/mpls/mpls_gso.c
··· 62 62 63 63 static struct packet_offload mpls_mc_offload __read_mostly = { 64 64 .type = cpu_to_be16(ETH_P_MPLS_MC), 65 + .priority = 15, 65 66 .callbacks = { 66 67 .gso_segment = mpls_gso_segment, 67 68 }, ··· 70 69 71 70 static struct packet_offload mpls_uc_offload __read_mostly = { 72 71 .type = cpu_to_be16(ETH_P_MPLS_UC), 72 + .priority = 15, 73 73 .callbacks = { 74 74 .gso_segment = mpls_gso_segment, 75 75 },