Skip to content

Commit

Permalink
net: Add priority to packet_offload objects.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Suggested-by: Toshiaki Makita <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Jun 1, 2015
1 parent 493be55 commit bdef7de
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
8 changes: 6 additions & 2 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions net/ethernet/eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions net/mpls/mpls_gso.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ static struct sk_buff *mpls_gso_segment(struct sk_buff *skb,

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,
},
};

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,
},
Expand Down

0 comments on commit bdef7de

Please sign in to comment.