mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-24 21:54:34 -04:00
gro: Optimise Ethernet header comparison
This patch optimises the Ethernet header comparison to use 2-byte and 4-byte xors instead of memcmp. In order to facilitate this, the actual comparison is now carried out by the callers of the shared dev_gro_receive function. This has a significant impact when receiving 1500B packets through 10GbE. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
4ae5544f9a
commit
aa4b9f533e
4 changed files with 33 additions and 22 deletions
|
|
@ -184,4 +184,25 @@ static inline unsigned compare_ether_addr_64bits(const u8 addr1[6+2],
|
|||
}
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
/**
|
||||
* compare_ether_header - Compare two Ethernet headers
|
||||
* @a: Pointer to Ethernet header
|
||||
* @b: Pointer to Ethernet header
|
||||
*
|
||||
* Compare two ethernet headers, returns 0 if equal.
|
||||
* This assumes that the network header (i.e., IP header) is 4-byte
|
||||
* aligned OR the platform can handle unaligned access. This is the
|
||||
* case for all packets coming into netif_receive_skb or similar
|
||||
* entry points.
|
||||
*/
|
||||
|
||||
static inline int compare_ether_header(const void *a, const void *b)
|
||||
{
|
||||
u32 *a32 = (u32 *)((u8 *)a + 2);
|
||||
u32 *b32 = (u32 *)((u8 *)b + 2);
|
||||
|
||||
return (*(u16 *)a ^ *(u16 *)b) | (a32[0] ^ b32[0]) |
|
||||
(a32[1] ^ b32[1]) | (a32[2] ^ b32[2]);
|
||||
}
|
||||
|
||||
#endif /* _LINUX_ETHERDEVICE_H */
|
||||
|
|
|
|||
|
|
@ -1117,6 +1117,13 @@ static inline void skb_gro_reset_offset(struct sk_buff *skb)
|
|||
NAPI_GRO_CB(skb)->data_offset = 0;
|
||||
}
|
||||
|
||||
static inline void *skb_gro_mac_header(struct sk_buff *skb)
|
||||
{
|
||||
return skb_mac_header(skb) < skb->data ? skb_mac_header(skb) :
|
||||
page_address(skb_shinfo(skb)->frags[0].page) +
|
||||
skb_shinfo(skb)->frags[0].page_offset;
|
||||
}
|
||||
|
||||
static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev,
|
||||
unsigned short type,
|
||||
const void *daddr, const void *saddr,
|
||||
|
|
|
|||
Loading…
Reference in a new issue