Subject: Re: [PATCH net-next] vlan: Add GRO support for non hardware accelerated vlan

From: Toshiaki Makita <[email-masked]>
Date: Fri, 29 May 2015 23:48:08 +0900

On 15/05/28 (木) 21:02, Eric Dumazet wrote:
> On Thu, 2015-05-28 at 20:17 +0900, Toshiaki Makita wrote:
>> Currently packets with non-hardware-accelerated vlan cannot be handled
>> by GRO. This causes low performance for 802.1ad and stacked vlan, as their
>> vlan tags are currently not stripped by hardware.
>>
>> This patch adds GRO support for non-hardware-accelerated vlan and
>> improves receive performance of them.
>
> Very nice patch !
>
>>
>> Signed-off-by: Toshiaki Makita <[email-masked]>
>> ---
>>   net/8021q/vlan.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 94 insertions(+)
>>
>> diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
>> index 59555f0..0a9e8e1 100644
>> --- a/net/8021q/vlan.c
>> +++ b/net/8021q/vlan.c
>> @@ -618,6 +618,90 @@ out:
>>   	return err;
>>   }
>>
>> +		vhdr2 = (struct vlan_hdr *)(p->data + off_vlan);
>> +		if (memcmp(vhdr, vhdr2, VLAN_HLEN))
>> +			NAPI_GRO_CB(p)->same_flow = 0;
>> +	}
>
>
> This memcmp() is quite expensive, you better use a helper like :
>
> /* vlan header only guaranteed to be 16bit aligned */
> static bool vlan_hdr_compare(const struct vlan_hdr *h1, const struct vlan_hdr *h2)
> {
> #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
> 	return *(u32 *)h1 != *(u32 *)h2;
> #else
> 	return (((__force u32)h1->h_vlan_TCI ^ (__force u32)h2->h_vlan_TCI) |
> 		((__force u32)h1->h_vlan_encapsulated_proto ^
> 		 (__force u32)h2->h_vlan_encapsulated_proto)) != 0;
> #endif
> }

Hi Eric,

Thank you for your reviewing.
Indeed, memcmp() is not good for performance.
I'll include your feedback in v2.

Thanks,
Toshiaki Makita