Re: [net-next PATCH] csum: Update csum_block_add to use rotate instead of byteswap

2016-03-09 Thread Tom Herbert
On Wed, Mar 9, 2016 at 4:18 PM, Joe Perches wrote: > On Wed, 2016-03-09 at 08:08 -0800, Alexander Duyck wrote: >> On Tue, Mar 8, 2016 at 10:31 PM, Tom Herbert wrote: >> > I took a look inlining these. >> > >> > #define rol32(V, X) ({ \ >> > int word = V;

Re: [net-next PATCH] csum: Update csum_block_add to use rotate instead of byteswap

2016-03-09 Thread Joe Perches
On Wed, 2016-03-09 at 08:08 -0800, Alexander Duyck wrote: > On Tue, Mar 8, 2016 at 10:31 PM, Tom Herbert wrote: > > I took a look inlining these. > > > > #define rol32(V, X) ({  \ > > int word = V;   \ > > if (__builtin_constant_p(X)

Re: [net-next PATCH] csum: Update csum_block_add to use rotate instead of byteswap

2016-03-09 Thread Alexander Duyck
On Tue, Mar 8, 2016 at 10:31 PM, Tom Herbert wrote: > On Tue, Mar 8, 2016 at 10:08 PM, Alexander Duyck > wrote: >> On Tue, Mar 8, 2016 at 9:50 PM, Joe Perches wrote: >>> On Tue, 2016-03-08 at 21:23 -0800, Alexander Duyck wrote: On Tue, Mar 8, 2016 at 3:25 PM, Joe Perches wrote: > On T

Re: [net-next PATCH] csum: Update csum_block_add to use rotate instead of byteswap

2016-03-09 Thread Alexander Duyck
On Wed, Mar 9, 2016 at 2:54 AM, David Laight wrote: > From: Joe Perches >> Sent: 08 March 2016 23:26 > ... >> > + >> > + if (offset & 1) >> > + sum = (sum << 24) + (sum >> 8); >> >> Maybe use ror32(sum, 8); >> >> or maybe something like: >> >> { >> u32 sum; >> >> /* rotated

RE: [net-next PATCH] csum: Update csum_block_add to use rotate instead of byteswap

2016-03-09 Thread David Laight
From: Joe Perches > Sent: 08 March 2016 23:26 ... > > + > > + if (offset & 1) > > + sum = (sum << 24) + (sum >> 8); > > Maybe use ror32(sum, 8); > > or maybe something like: > > { > u32 sum; > > /* rotated csum2 of odd offset will be the right checksum */ > if (off

Re: [net-next PATCH] csum: Update csum_block_add to use rotate instead of byteswap

2016-03-08 Thread Tom Herbert
On Tue, Mar 8, 2016 at 10:08 PM, Alexander Duyck wrote: > On Tue, Mar 8, 2016 at 9:50 PM, Joe Perches wrote: >> On Tue, 2016-03-08 at 21:23 -0800, Alexander Duyck wrote: >>> On Tue, Mar 8, 2016 at 3:25 PM, Joe Perches wrote: >>> > On Tue, 2016-03-08 at 14:42 -0800, Alexander Duyck wrote: >>> > >

Re: [net-next PATCH] csum: Update csum_block_add to use rotate instead of byteswap

2016-03-08 Thread Alexander Duyck
On Tue, Mar 8, 2016 at 9:50 PM, Joe Perches wrote: > On Tue, 2016-03-08 at 21:23 -0800, Alexander Duyck wrote: >> On Tue, Mar 8, 2016 at 3:25 PM, Joe Perches wrote: >> > On Tue, 2016-03-08 at 14:42 -0800, Alexander Duyck wrote: >> > > The code for csum_block_add was doing a funky byteswap to swap

Re: [net-next PATCH] csum: Update csum_block_add to use rotate instead of byteswap

2016-03-08 Thread Joe Perches
On Tue, 2016-03-08 at 21:23 -0800, Alexander Duyck wrote: > On Tue, Mar 8, 2016 at 3:25 PM, Joe Perches wrote: > > On Tue, 2016-03-08 at 14:42 -0800, Alexander Duyck wrote: > > > The code for csum_block_add was doing a funky byteswap to swap the even > > > and > > > odd bytes of the checksum if t

Re: [net-next PATCH] csum: Update csum_block_add to use rotate instead of byteswap

2016-03-08 Thread Alexander Duyck
On Tue, Mar 8, 2016 at 3:25 PM, Joe Perches wrote: > On Tue, 2016-03-08 at 14:42 -0800, Alexander Duyck wrote: >> The code for csum_block_add was doing a funky byteswap to swap the even and >> odd bytes of the checksum if the offset was odd. Instead of doing this we >> can save ourselves some tro

Re: [net-next PATCH] csum: Update csum_block_add to use rotate instead of byteswap

2016-03-08 Thread Joe Perches
On Tue, 2016-03-08 at 14:42 -0800, Alexander Duyck wrote: > The code for csum_block_add was doing a funky byteswap to swap the even and > odd bytes of the checksum if the offset was odd.  Instead of doing this we > can save ourselves some trouble and just shift by 8 as this should have the > same e

[net-next PATCH] csum: Update csum_block_add to use rotate instead of byteswap

2016-03-08 Thread Alexander Duyck
The code for csum_block_add was doing a funky byteswap to swap the even and odd bytes of the checksum if the offset was odd. Instead of doing this we can save ourselves some trouble and just shift by 8 as this should have the same effect in terms of the final checksum value and only requires one i